Skip to content

Commit 69557f1

Browse files
dplumleeelasticmachine
authored andcommitted
[Security Solution] Add support for editing prebuilt rules to the Rule Editing page (elastic#199550)
**Resolves: elastic#180172 ## Summary > [!NOTE] > Feature is behind the `prebuiltRulesCustomizationEnabled` feature flag. Removes the logic gates preventing prebuilt rules from being edited via the Rule Edit page behind the `prebuiltRulesCustomizationEnabled` feature flag. This allows all rules types to be fully editable via the UI. Also removes the muting logic we had in place for `Definition` tab warnings ([implemented here](elastic#191487)) ### Screenshots #### _Before_ **Prebuilt rule only has the "Actions" tab enabled, users cannot customize anything else in the form** ![Screenshot 2024-11-08 at 3 08 15 PM](https://github.com/user-attachments/assets/b83836e6-f78f-4b3a-9fbc-55a5208250dd) #### _After_ **Prebuilt rule now has all tabs/fields available for editing and rule info is populated into the form** ![Screenshot 2024-11-08 at 3 02 43 PM](https://github.com/user-attachments/assets/184f6fc4-b64c-4e20-a987-76e460c61786) ### Checklist Delete any items that are not applicable to this PR. - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels) - [ ] This will appear in the **Release Notes** and follow the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent 7748a7e commit 69557f1

File tree

1 file changed

+14
-8
lines changed
  • x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing

1 file changed

+14
-8
lines changed

x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { useRuleForms, useRuleFormsErrors, useRuleIndexPattern } from '../form';
6969
import { useEsqlIndex, useEsqlQueryForAboutStep } from '../../hooks';
7070
import { CustomHeaderPageMemo } from '..';
7171
import { SaveWithErrorsModal } from '../../components/save_with_errors_confirmation';
72+
import { useIsPrebuiltRulesCustomizationEnabled } from '../../../rule_management/hooks/use_is_prebuilt_rules_customization_enabled';
7273
import { ALERT_SUPPRESSION_FIELDS_FIELD_NAME } from '../../../rule_creation/components/alert_suppression_edit';
7374

7475
const 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

Comments
 (0)