@@ -69,6 +69,7 @@ import { useRuleForms, useRuleFormsErrors, useRuleIndexPattern } from '../form';
6969import { useEsqlIndex , useEsqlQueryForAboutStep } from '../../hooks' ;
7070import { CustomHeaderPageMemo } from '..' ;
7171import { SaveWithErrorsModal } from '../../components/save_with_errors_confirmation' ;
72+ import { useIsPrebuiltRulesCustomizationEnabled } from '../../../rule_management/hooks/use_is_prebuilt_rules_customization_enabled' ;
7273import { ALERT_SUPPRESSION_FIELDS_FIELD_NAME } from '../../../rule_creation/components/alert_suppression_edit' ;
7374
7475const EditRulePageComponent : FC < { rule : RuleResponse } > = ( { rule } ) => {
@@ -86,11 +87,14 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
8687 useListsConfig ( ) ;
8788 const { application, triggersActionsUi } = useKibana ( ) . services ;
8889 const { navigateToApp } = application ;
90+ const isPrebuiltRulesCustomizationEnabled = useIsPrebuiltRulesCustomizationEnabled ( ) ;
8991
9092 const { detailName : ruleId } = useParams < { detailName : string } > ( ) ;
9193
9294 const [ activeStep , setActiveStep ] = useState < RuleStep > (
93- rule . immutable ? RuleStep . ruleActions : RuleStep . defineRule
95+ ! isPrebuiltRulesCustomizationEnabled && rule . immutable
96+ ? RuleStep . ruleActions
97+ : RuleStep . defineRule
9498 ) ;
9599 const { mutateAsync : updateRule , isLoading } = useUpdateRule ( ) ;
96100 const [ isRulePreviewVisible , setIsRulePreviewVisible ] = useState ( true ) ;
@@ -211,7 +215,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
211215 'data-test-subj' : 'edit-rule-define-tab' ,
212216 id : RuleStep . defineRule ,
213217 name : ruleI18n . DEFINITION ,
214- disabled : rule ?. immutable ,
218+ disabled : ! isPrebuiltRulesCustomizationEnabled && rule ?. immutable ,
215219 content : (
216220 < div
217221 style = { {
@@ -256,7 +260,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
256260 'data-test-subj' : 'edit-rule-about-tab' ,
257261 id : RuleStep . aboutRule ,
258262 name : ruleI18n . ABOUT ,
259- disabled : rule ?. immutable ,
263+ disabled : ! isPrebuiltRulesCustomizationEnabled && rule ?. immutable ,
260264 content : (
261265 < div
262266 style = { {
@@ -288,7 +292,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
288292 'data-test-subj' : 'edit-rule-schedule-tab' ,
289293 id : RuleStep . scheduleRule ,
290294 name : ruleI18n . SCHEDULE ,
291- disabled : rule ?. immutable ,
295+ disabled : ! isPrebuiltRulesCustomizationEnabled && rule ?. immutable ,
292296 content : (
293297 < div
294298 style = { {
@@ -340,6 +344,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
340344 } ,
341345 ] ,
342346 [
347+ isPrebuiltRulesCustomizationEnabled ,
343348 rule ?. immutable ,
344349 rule ?. id ,
345350 activeStep ,
@@ -356,15 +361,15 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
356361 isIndexPatternLoading ,
357362 isQueryBarValid ,
358363 defineStepData ,
364+ memoizedIndex ,
359365 aboutStepData ,
360366 aboutStepForm ,
367+ esqlQueryForAboutStep ,
361368 scheduleStepData ,
362369 scheduleStepForm ,
363370 actionsStepData ,
364371 actionMessageParams ,
365372 actionsStepForm ,
366- memoizedIndex ,
367- esqlQueryForAboutStep ,
368373 ]
369374 ) ;
370375
@@ -414,7 +419,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
414419 setNonBlockingRuleErrors ( [ ] ) ;
415420
416421 const actionsStepFormValid = await actionsStepForm . validate ( ) ;
417- if ( rule . immutable ) {
422+ if ( ! isPrebuiltRulesCustomizationEnabled && rule . immutable ) {
418423 // Since users cannot edit Define, About and Schedule tabs of the rule, we skip validation of those to avoid
419424 // user confusion of seeing that those tabs have error and not being able to see or do anything about that.
420425 // We will need to remove this condition once rule customization work is done.
@@ -451,11 +456,12 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
451456 showSaveWithErrorsModal ( ) ;
452457 }
453458 } , [
459+ actionsStepForm ,
460+ isPrebuiltRulesCustomizationEnabled ,
454461 rule . immutable ,
455462 defineStepForm ,
456463 aboutStepForm ,
457464 scheduleStepForm ,
458- actionsStepForm ,
459465 getRuleFormsErrors ,
460466 saveChanges ,
461467 showSaveWithErrorsModal ,
0 commit comments