Skip to content

Commit

Permalink
adds boolean logic behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Oct 29, 2024
1 parent c7b8ca0 commit dc005b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type { DefaultItemAction } from '@elastic/eui';
import { EuiToolTip } from '@elastic/eui';
import React from 'react';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { DuplicateOptions } from '../../../../../common/detection_engine/rule_management/constants';
import { BulkActionTypeEnum } from '../../../../../common/api/detection_engine/rule_management';
import { SINGLE_RULE_ACTIONS } from '../../../../common/lib/apm/user_actions';
Expand Down Expand Up @@ -45,6 +46,9 @@ export const useRulesTableActions = ({
const { bulkExport } = useBulkExport();
const downloadExportedRules = useDownloadExportedRules();
const { scheduleRuleRun } = useScheduleRuleRun();
const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled(
'prebuiltRulesCustomizationEnabled'
);

return [
{
Expand Down Expand Up @@ -115,7 +119,7 @@ export const useRulesTableActions = ({
await downloadExportedRules(response);
}
},
enabled: (rule: Rule) => !rule.immutable,
enabled: (rule: Rule) => isPrebuiltRulesCustomizationEnabled || !rule.immutable,
},
{
type: 'icon',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@elastic/eui';
import React, { useCallback, useMemo } from 'react';
import styled from 'styled-components';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { useScheduleRuleRun } from '../../../../detection_engine/rule_gaps/logic/use_schedule_rule_run';
import type { TimeRange } from '../../../../detection_engine/rule_gaps/types';
import { APP_UI_ID, SecurityPageName } from '../../../../../common/constants';
Expand Down Expand Up @@ -71,6 +72,9 @@ const RuleActionsOverflowComponent = ({
application: { navigateToApp },
telemetry,
} = useKibana().services;
const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled(
'prebuiltRulesCustomizationEnabled'
);
const { startTransaction } = useStartTransaction();
const { executeBulkAction } = useExecuteBulkAction({ suppressSuccessToast: true });
const { bulkExport } = useBulkExport();
Expand Down Expand Up @@ -136,7 +140,10 @@ const RuleActionsOverflowComponent = ({
<EuiContextMenuItem
key={i18nActions.EXPORT_RULE}
icon="exportAction"
disabled={!userHasPermissions || rule.immutable}
disabled={
!userHasPermissions ||
(isPrebuiltRulesCustomizationEnabled === false && rule.immutable)
}
data-test-subj="rules-details-export-rule"
onClick={async () => {
startTransaction({ name: SINGLE_RULE_ACTIONS.EXPORT });
Expand Down Expand Up @@ -202,21 +209,22 @@ const RuleActionsOverflowComponent = ({
]
: [],
[
bulkExport,
rule,
canDuplicateRuleWithActions,
userHasPermissions,
isPrebuiltRulesCustomizationEnabled,
startTransaction,
closePopover,
showBulkDuplicateExceptionsConfirmation,
executeBulkAction,
navigateToApp,
onRuleDeletedCallback,
rule,
showBulkDuplicateExceptionsConfirmation,
showManualRuleRunConfirmation,
startTransaction,
userHasPermissions,
bulkExport,
downloadExportedRules,
confirmDeletion,
scheduleRuleRun,
showManualRuleRunConfirmation,
telemetry,
scheduleRuleRun,
confirmDeletion,
onRuleDeletedCallback,
]
);

Expand Down

0 comments on commit dc005b7

Please sign in to comment.