Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export const BULK_FILL_RULE_GAPS_CONFIRMATION_CONFIRM = i18n.translate(
export const BULK_MANUAL_RULE_RUN_LIMIT_ERROR_TITLE = i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allRules.bulkActions.bulkManualRuleRunLimitErrorMessage',
{
defaultMessage: 'This action can only be applied',
defaultMessage: 'Cannot execute the bulk action',
}
);

Expand All @@ -415,6 +415,30 @@ export const BULK_MANUAL_RULE_RUN_LIMIT_ERROR_CLOSE_BUTTON = i18n.translate(
}
);

export const BULK_FILL_RULE_GAPS_LIMIT_ERROR_TITLE = i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allRules.bulkActions.bulkFillRuleGapsRuleLimitErrorMessage',
{
defaultMessage: 'Cannot execute the bulk action',
}
);

export const BULK_FILL_RULE_GAPS_LIMIT_ERROR_MESSAGE = (rulesCount: number) =>
i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allRules.bulkActions.bulkFillRuleGapsRuleLimitErrorTitle',
{
values: { rulesCount },
defaultMessage:
'Cannot schedule gap fills for more than {rulesCount, plural, =1 {# rule} other {# rules}}.',
}
);

export const BULK_FILL_RULE_GAPS_LIMIT_ERROR_CLOSE_BUTTON = i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allRules.bulkActions.bulkFillRuleGapsRuleLimitErrorCloseButton',
{
defaultMessage: 'Close',
}
);

export const BULK_EDIT_FLYOUT_FORM_SAVE = i18n.translate(
'xpack.securitySolution.detectionEngine.components.allRules.bulkActions.bulkEditFlyoutForm.saveButtonLabel',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const BulkFillRuleGapsModalComponent = ({
<EuiCallOut
size="s"
iconType="warning"
title={i18n.BULK_FILL_RULE_GAPS_NOTIFIACTIONS_LIMITATIONS}
title={i18n.BULK_FILL_RULE_GAPS_NOTIFICATIONS_LIMITATIONS}
/>,
];
if (rulesCount > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const BULK_FILL_RULE_GAPS_END_AT_TITLE = i18n.translate(
export const BULK_FILL_RULE_GAPS_CONFIRM_BUTTON = i18n.translate(
'xpack.securitySolution.bulkFillRuleGapsModal.confirmButton',
{
defaultMessage: 'Run',
defaultMessage: 'Schedule gap fills',
}
);

Expand Down Expand Up @@ -69,7 +69,7 @@ export const BULK_FILL_RULE_GAPS_START_DATE_OUT_OF_RANGE_ERROR = (maxDaysLookbac
'Rule gap fills cannot be scheduled earlier than {maxDaysLookback, plural, =1 {# day} other {# days}} ago',
});

export const BULK_FILL_RULE_GAPS_NOTIFIACTIONS_LIMITATIONS = i18n.translate(
export const BULK_FILL_RULE_GAPS_NOTIFICATIONS_LIMITATIONS = i18n.translate(
'xpack.securitySolution.bulkFillRuleGapsModal.notificationsLimitations',
{
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import {
EuiButton,
EuiModal,
EuiModalBody,
EuiModalFooter,
EuiModalHeader,
EuiModalHeaderTitle,
} from '@elastic/eui';

interface BulkManualRuleRunRulesLimitErrorModalProps {
onClose: () => void;
text: {
title: string;
message: string;
closeButton: string;
};
}

const BulkActionRuleLimitErrorModalComponent = ({
onClose,
text,
}: BulkManualRuleRunRulesLimitErrorModalProps) => {
return (
<EuiModal onClose={onClose}>
<EuiModalHeader>
<EuiModalHeaderTitle>{text.title}</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>{text.message}</EuiModalBody>
<EuiModalFooter>
<EuiButton onClick={onClose} fill>
{text.closeButton}
</EuiButton>
</EuiModalFooter>
</EuiModal>
);
};

export const BulkActionRuleLimitErrorModal = React.memo(BulkActionRuleLimitErrorModalComponent);

BulkActionRuleLimitErrorModal.displayName = 'BulkActionRuleLimitErrorModal';
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,24 @@
*/

import React from 'react';
import {
EuiButton,
EuiModal,
EuiModalBody,
EuiModalFooter,
EuiModalHeader,
EuiModalHeaderTitle,
} from '@elastic/eui';

import { MAX_MANUAL_RULE_RUN_BULK_SIZE } from '../../../../../../common/constants';
import * as i18n from '../../../../common/translations';
import { BulkActionRuleLimitErrorModal } from './bulk_action_rule_limit_error_modal';

interface BulkManualRuleRunRulesLimitErrorModalProps {
onClose: () => void;
}

const text = {
title: i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_TITLE,
message: i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_MESSAGE(MAX_MANUAL_RULE_RUN_BULK_SIZE),
closeButton: i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_CLOSE_BUTTON,
};

const BulkManualRuleRunLimitErrorModalComponent = ({
onClose,
}: BulkManualRuleRunRulesLimitErrorModalProps) => {
// if the amount of selected rules is more than the limit, modal window the appropriate error will be displayed
return (
<EuiModal onClose={onClose}>
<EuiModalHeader>
<EuiModalHeaderTitle>{i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_TITLE}</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
{i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_MESSAGE(MAX_MANUAL_RULE_RUN_BULK_SIZE)}
</EuiModalBody>
<EuiModalFooter>
<EuiButton onClick={onClose} fill>
{i18n.BULK_MANUAL_RULE_RUN_LIMIT_ERROR_CLOSE_BUTTON}
</EuiButton>
</EuiModalFooter>
</EuiModal>
);
return <BulkActionRuleLimitErrorModal onClose={onClose} text={text} />;
};

export const BulkManualRuleRunLimitErrorModal = React.memo(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { MAX_BULK_FILL_RULE_GAPS_BULK_SIZE } from '../../../../../../common/constants';
import * as i18n from '../../../../common/translations';
import { BulkActionRuleLimitErrorModal } from './bulk_action_rule_limit_error_modal';

interface BulkManualRuleRunRulesLimitErrorModalProps {
onClose: () => void;
}

const text = {
title: i18n.BULK_FILL_RULE_GAPS_LIMIT_ERROR_TITLE,
message: i18n.BULK_FILL_RULE_GAPS_LIMIT_ERROR_MESSAGE(MAX_BULK_FILL_RULE_GAPS_BULK_SIZE),
closeButton: i18n.BULK_FILL_RULE_GAPS_LIMIT_ERROR_CLOSE_BUTTON,
};

const BulkFillRuleGapsRuleLimitErrorModalComponent = ({
onClose,
}: BulkManualRuleRunRulesLimitErrorModalProps) => {
return <BulkActionRuleLimitErrorModal onClose={onClose} text={text} />;
};

export const BulkFillRuleGapsRuleLimitErrorModal = React.memo(
BulkFillRuleGapsRuleLimitErrorModalComponent
);

BulkFillRuleGapsRuleLimitErrorModal.displayName = 'BulkFillRuleGapsRuleLimitErrorModal';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { euiThemeVars } from '@kbn/ui-theme';
import React, { useCallback, useMemo } from 'react';
import { BulkFillRuleGapsEventTypes } from '../../../../../common/lib/telemetry/events/bulk_fill_rule_gaps/types';
import { ML_RULES_UNAVAILABLE } from './translations';
import { MAX_MANUAL_RULE_RUN_BULK_SIZE } from '../../../../../../common/constants';
import {
MAX_BULK_FILL_RULE_GAPS_BULK_SIZE,
MAX_MANUAL_RULE_RUN_BULK_SIZE,
} from '../../../../../../common/constants';
import type { TimeRange } from '../../../../rule_gaps/types';
import { useKibana } from '../../../../../common/lib/kibana';
import { useUserPrivileges } from '../../../../../common/components/user_privileges';
Expand Down Expand Up @@ -66,6 +69,7 @@ interface UseBulkActionsArgs {
showManualRuleRunConfirmation: () => Promise<TimeRange | null>;
showBulkFillRuleGapsConfirmation: () => Promise<TimeRange | null>;
showManualRuleRunLimitError: () => void;
showBulkFillRuleGapsRuleLimitError: () => void;
completeBulkEditForm: (
bulkActionEditType: BulkActionEditType
) => Promise<BulkActionEditPayload | null>;
Expand All @@ -80,6 +84,7 @@ export const useBulkActions = ({
showManualRuleRunConfirmation,
showBulkFillRuleGapsConfirmation,
showManualRuleRunLimitError,
showBulkFillRuleGapsRuleLimitError,
completeBulkEditForm,
executeBulkActionsDryRun,
}: UseBulkActionsArgs) => {
Expand Down Expand Up @@ -314,8 +319,8 @@ export const useBulkActions = ({

setIsPreflightInProgress(false);

if ((dryRunResult?.succeededRulesCount ?? 0) > MAX_MANUAL_RULE_RUN_BULK_SIZE) {
showManualRuleRunLimitError();
if ((dryRunResult?.succeededRulesCount ?? 0) > MAX_BULK_FILL_RULE_GAPS_BULK_SIZE) {
showBulkFillRuleGapsRuleLimitError();
return;
}

Expand Down Expand Up @@ -776,6 +781,7 @@ export const useBulkActions = ({
showBulkDuplicateConfirmation,
showManualRuleRunConfirmation,
showManualRuleRunLimitError,
showBulkFillRuleGapsRuleLimitError,
clearRulesSelection,
confirmDeletion,
bulkExport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { BulkEditDeleteAlertSuppressionConfirmation } from './bulk_actions/bulk_
import { BulkActionEditTypeEnum } from '../../../../../common/api/detection_engine/rule_management';
import { BulkFillRuleGapsModal } from '../../../rule_gaps/components/bulk_fill_rule_gaps';
import { useBulkFillRuleGapsConfirmation } from '../../../rule_gaps/components/bulk_fill_rule_gaps/use_bulk_fill_rule_gaps_confirmation';
import { BulkFillRuleGapsRuleLimitErrorModal } from './bulk_actions/bulk_schedule_gap_fills_rule_limit_error_modal';

const INITIAL_SORT_FIELD = 'enabled';

Expand Down Expand Up @@ -142,6 +143,12 @@ export const RulesTables = React.memo<RulesTableProps>(({ selectedTab }) => {
hideManualRuleRunLimitError,
] = useBoolState();

const [
isBulkFillRuleGapsRuleLimitErrorVisible,
showBulkFillRuleGapsRuleLimitError,
hideBulkFillRuleGapsRuleLimitError,
] = useBoolState();

const {
bulkEditActionType,
isBulkEditFlyoutVisible,
Expand All @@ -160,6 +167,7 @@ export const RulesTables = React.memo<RulesTableProps>(({ selectedTab }) => {
showManualRuleRunConfirmation,
showBulkFillRuleGapsConfirmation,
showManualRuleRunLimitError,
showBulkFillRuleGapsRuleLimitError,
completeBulkEditForm,
executeBulkActionsDryRun,
});
Expand Down Expand Up @@ -314,6 +322,9 @@ export const RulesTables = React.memo<RulesTableProps>(({ selectedTab }) => {
{isManualRuleRunLimitErrorVisible && (
<BulkManualRuleRunLimitErrorModal onClose={hideManualRuleRunLimitError} />
)}
{isBulkFillRuleGapsRuleLimitErrorVisible && (
<BulkFillRuleGapsRuleLimitErrorModal onClose={hideBulkFillRuleGapsRuleLimitError} />
)}
{isBulkActionConfirmationVisible && bulkAction && (
<BulkActionDryRunConfirmation
bulkAction={bulkAction}
Expand Down