Skip to content

Commit 02e4edc

Browse files
[Security Solution] Allows editing and exporting prebuilt rules from the Rule Management and Rule Details pages (#198202)
**Resolves: #180171 **Resolves: #180176 **Resolves: #180173 ## Summary > [!NOTE] > Feature is behind the `prebuiltRulesCustomizationEnabled` feature flag. Adds logic to allow users to edit and export prebuilt rules from both the Rule management page and Rule details page via the bulk action menu and the singular overflow menu ### Acceptance criteria - [x] Feature is hidden behind prebuiltRulesCustomizationEnabled feature flag - [x] Modified components still work as expected when feature flag is off - [x] Bulk actions are able to performed on all rule types from Rule management page bulk actions menu - [x] Editing - [x] Index patterns - [x] Tags - [x] Highlighted fields - [x] Schedule - [x] Export - [x] Singular rule actions are able to be performed on all rule types from rule management page overflow column - [x] Export - [x] Singular rule actions are able to be performed on all rule types from rule details page - [x] Export ### Screenshots *** ### Rule management table overflow menu #### Before **Export button is disabled for prebuilt rules** ![Screenshot 2024-11-07 at 7 38 12 PM](https://github.com/user-attachments/assets/13f8cd87-a9e5-486c-ab0f-d206de8bab4b) #### After **Export button is enabled for all rule types** ![Screenshot 2024-11-07 at 7 34 27 PM](https://github.com/user-attachments/assets/4b3d9364-02d5-406a-9f8a-c9ad8fed8486) ### Rule details page overflow menu #### Before **Export button is disabled for prebuilt rules** ![Screenshot 2024-11-07 at 7 37 40 PM](https://github.com/user-attachments/assets/621b56e3-1f47-49db-aedb-fd05a3b75007) #### After **Export button is enabled for all rule types** ![Screenshot 2024-11-07 at 7 34 38 PM](https://github.com/user-attachments/assets/d533f288-4393-4acf-ba88-91c32ab32955) --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent 20e023b commit 02e4edc

File tree

2 files changed

+19
-11
lines changed
  • x-pack/plugins/security_solution/public

2 files changed

+19
-11
lines changed

x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/use_rules_table_actions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { useDownloadExportedRules } from '../../../rule_management/logic/bulk_ac
2525
import { useHasActionsPrivileges } from './use_has_actions_privileges';
2626
import type { TimeRange } from '../../../rule_gaps/types';
2727
import { useScheduleRuleRun } from '../../../rule_gaps/logic/use_schedule_rule_run';
28+
import { useIsPrebuiltRulesCustomizationEnabled } from '../../../rule_management/hooks/use_is_prebuilt_rules_customization_enabled';
2829
import { ManualRuleRunEventTypes } from '../../../../common/lib/telemetry';
2930

3031
export const useRulesTableActions = ({
@@ -46,6 +47,7 @@ export const useRulesTableActions = ({
4647
const { bulkExport } = useBulkExport();
4748
const downloadExportedRules = useDownloadExportedRules();
4849
const { scheduleRuleRun } = useScheduleRuleRun();
50+
const isPrebuiltRulesCustomizationEnabled = useIsPrebuiltRulesCustomizationEnabled();
4951

5052
return [
5153
{
@@ -116,7 +118,7 @@ export const useRulesTableActions = ({
116118
await downloadExportedRules(response);
117119
}
118120
},
119-
enabled: (rule: Rule) => !rule.immutable,
121+
enabled: (rule: Rule) => isPrebuiltRulesCustomizationEnabled || !rule.immutable,
120122
},
121123
{
122124
type: 'icon',

x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_overflow/index.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '@elastic/eui';
1515
import React, { useCallback, useMemo } from 'react';
1616
import styled from 'styled-components';
17+
import { useIsPrebuiltRulesCustomizationEnabled } from '../../../../detection_engine/rule_management/hooks/use_is_prebuilt_rules_customization_enabled';
1718
import { useScheduleRuleRun } from '../../../../detection_engine/rule_gaps/logic/use_schedule_rule_run';
1819
import type { TimeRange } from '../../../../detection_engine/rule_gaps/types';
1920
import { APP_UI_ID, SecurityPageName } from '../../../../../common/constants';
@@ -72,6 +73,7 @@ const RuleActionsOverflowComponent = ({
7273
application: { navigateToApp },
7374
telemetry,
7475
} = useKibana().services;
76+
const isPrebuiltRulesCustomizationEnabled = useIsPrebuiltRulesCustomizationEnabled();
7577
const { startTransaction } = useStartTransaction();
7678
const { executeBulkAction } = useExecuteBulkAction({ suppressSuccessToast: true });
7779
const { bulkExport } = useBulkExport();
@@ -137,7 +139,10 @@ const RuleActionsOverflowComponent = ({
137139
<EuiContextMenuItem
138140
key={i18nActions.EXPORT_RULE}
139141
icon="exportAction"
140-
disabled={!userHasPermissions || rule.immutable}
142+
disabled={
143+
!userHasPermissions ||
144+
(isPrebuiltRulesCustomizationEnabled === false && rule.immutable)
145+
}
141146
data-test-subj="rules-details-export-rule"
142147
onClick={async () => {
143148
startTransaction({ name: SINGLE_RULE_ACTIONS.EXPORT });
@@ -203,21 +208,22 @@ const RuleActionsOverflowComponent = ({
203208
]
204209
: [],
205210
[
206-
bulkExport,
211+
rule,
207212
canDuplicateRuleWithActions,
213+
userHasPermissions,
214+
isPrebuiltRulesCustomizationEnabled,
215+
startTransaction,
208216
closePopover,
217+
showBulkDuplicateExceptionsConfirmation,
209218
executeBulkAction,
210219
navigateToApp,
211-
onRuleDeletedCallback,
212-
rule,
213-
showBulkDuplicateExceptionsConfirmation,
214-
showManualRuleRunConfirmation,
215-
startTransaction,
216-
userHasPermissions,
220+
bulkExport,
217221
downloadExportedRules,
218-
confirmDeletion,
219-
scheduleRuleRun,
222+
showManualRuleRunConfirmation,
220223
telemetry,
224+
scheduleRuleRun,
225+
confirmDeletion,
226+
onRuleDeletedCallback,
221227
]
222228
);
223229

0 commit comments

Comments
 (0)