diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.test.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.test.ts index d8a1823622bdff..6937026e8ba0a0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.test.ts @@ -10,7 +10,12 @@ import { getExceptionListSchemaMock } from '@kbn/lists-plugin/common/schemas/res import { ExceptionListTypeEnum } from '@kbn/securitysolution-io-ts-list-types'; import { getRulesSchemaMock } from '../../../../../common/api/detection_engine/model/rule_schema/rule_response_schema.mock'; -import { isSubmitDisabled, prepareNewItemsForSubmission, prepareToCloseAlerts } from './helpers'; +import { + isSubmitDisabled, + prepareNewItemsForSubmission, + prepareToCloseAlerts, + getSuccessToastTitle, +} from './helpers'; import type { Rule } from '../../../rule_management/logic/types'; import type { AlertData } from '../../utils/types'; @@ -469,4 +474,18 @@ describe('add_exception_flyout#helpers', () => { expect(ruleStaticIds).toEqual(['query-rule-id']); }); }); + + describe('getSuccessToastTitle', () => { + it('returns endpoint title when list type is "endpoint"', () => { + expect(getSuccessToastTitle(ExceptionListTypeEnum.ENDPOINT)).toEqual( + 'Endpoint exception added to shared exception list' + ); + }); + + it('returns non endpoint title when list type is not "endpoint"', () => { + expect(getSuccessToastTitle(ExceptionListTypeEnum.DETECTION)).toEqual( + 'Rule exception added to shared exception list' + ); + }); + }); }); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.ts index 23d20f699780d1..76478ddc670238 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/helpers.ts @@ -14,6 +14,7 @@ import type { ExceptionsBuilderReturnExceptionItem } from '@kbn/securitysolution import type { Rule } from '../../../rule_management/logic/types'; import { enrichNewExceptionItems } from '../flyout_components/utils'; import type { AlertData } from '../../utils/types'; +import * as i18n from './translations'; const RULE_DEFAULT_OPTIONS = ['add_to_rule', 'add_to_rules', 'select_rules_to_add_to']; @@ -183,3 +184,14 @@ export const prepareToCloseAlerts = ({ ruleStaticIds, }; }; + +export const getSuccessToastTitle = (listType: ExceptionListTypeEnum) => + listType === ExceptionListTypeEnum.ENDPOINT + ? i18n.ADD_ENDPOINT_EXCEPTION_SUCCESS + : i18n.ADD_EXCEPTION_SUCCESS; + +export const getSuccessToastText = (listType: ExceptionListTypeEnum, sharedListNames: string[]) => + i18n.ADD_EXCEPTION_SUCCESS_DETAILS( + listType === ExceptionListTypeEnum.ENDPOINT ? 'Endpoint' : 'Rule', + sharedListNames.join(',') + ); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/translations.ts index d27d7994bb375e..a8dbde51b2b567 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/translations.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/translations.ts @@ -53,14 +53,18 @@ export const ADD_EXCEPTION_SUCCESS = i18n.translate( } ); -export const ADD_EXCEPTION_SUCCESS_DETAILS = (listNames: string) => - i18n.translate( - 'xpack.securitySolution.ruleExceptions.addExceptionFlyout.closeAlerts.successDetails', - { - values: { listNames }, - defaultMessage: 'Rule exception has been added to shared lists: {listNames}.', - } - ); +export const ADD_ENDPOINT_EXCEPTION_SUCCESS = i18n.translate( + 'xpack.securitySolution.ruleExceptions.addEndpointException.success', + { + defaultMessage: 'Endpoint exception added to shared exception list', + } +); + +export const ADD_EXCEPTION_SUCCESS_DETAILS = (listType: string, listNames: string) => + i18n.translate('xpack.securitySolution.ruleExceptions.addExceptionFlyout.successDetails', { + values: { listNames, listType }, + defaultMessage: '{listType} exception has been added to shared lists: {listNames}.', + }); export const ADD_RULE_EXCEPTION_SUCCESS_TITLE = i18n.translate( 'xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessTitle', diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/use_add_new_exceptions.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/use_add_new_exceptions.ts index 7aa686ed43cdf5..136a93ab133293 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/use_add_new_exceptions.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/add_exception_flyout/use_add_new_exceptions.ts @@ -25,6 +25,7 @@ import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; import type { Rule } from '../../../rule_management/logic/types'; import { useCreateOrUpdateException } from '../../logic/use_create_update_exception'; import { useAddRuleDefaultException } from '../../logic/use_add_rule_exception'; +import { getSuccessToastText, getSuccessToastTitle } from './helpers'; export interface AddNewExceptionItemHookProps { itemsToAdd: ExceptionsBuilderReturnExceptionItem[]; @@ -110,10 +111,12 @@ export const useAddNewExceptionItems = (): ReturnUseAddNewExceptionItems => { result = await addSharedExceptions(itemsToAdd); const sharedListNames = sharedLists.map(({ name }) => name); + const title = getSuccessToastTitle(listType); + const text = getSuccessToastText(listType, sharedListNames); addSuccess({ - title: i18n.ADD_EXCEPTION_SUCCESS, - text: i18n.ADD_EXCEPTION_SUCCESS_DETAILS(sharedListNames.join(',')), + title, + text, }); } diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 9d86049531ed78..3b5a402334797b 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -40635,7 +40635,6 @@ "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionFromAlertComment": "Les conditions d'exceptions sont préremplies avec les données pertinentes d'une alerte possédant l'identifiant d'alerte (_id) : {alertId}.", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessText": "L'exception a été ajoutée aux règles - {ruleName}.", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessTitle": "Exception à la règle ajoutée", - "xpack.securitySolution.ruleExceptions.addExceptionFlyout.closeAlerts.successDetails": "L'exception de la règle a été ajoutée aux listes partagées : {listNames}.", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.commentsTitle": "Ajouter des commentaires ({comments})", "xpack.securitySolution.ruleExceptions.allExceptionItems.activeDetectionsLabel": "Exceptions actives", "xpack.securitySolution.ruleExceptions.allExceptionItems.addExceptionsEmptyPromptTitle": "Ajouter des exceptions à cette règle", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 260c61347241da..f88fabd25833db 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -40618,7 +40618,6 @@ "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionFromAlertComment": "例外条件は、アラートID(_id)のアラートからの関連データがあらかじめ入力されます:{alertId}。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessText": "例外がルール - {ruleName}に追加されました。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessTitle": "ルール例外が追加されました", - "xpack.securitySolution.ruleExceptions.addExceptionFlyout.closeAlerts.successDetails": "ルール例外が共有リストに追加されました:{listNames}。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.commentsTitle": "コメントの追加({comments})", "xpack.securitySolution.ruleExceptions.allExceptionItems.activeDetectionsLabel": "アクティブな例外", "xpack.securitySolution.ruleExceptions.allExceptionItems.addExceptionsEmptyPromptTitle": "このルールに例外を追加", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 690519b75013fa..2ae9e055b1f01d 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -40661,7 +40661,6 @@ "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionFromAlertComment": "将使用具有告警 ID (_id) 的告警中的相关数据预填充例外条件:{alertId}。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessText": "例外已添加到规则 - {ruleName}。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.addRuleExceptionToastSuccessTitle": "已添加规则例外", - "xpack.securitySolution.ruleExceptions.addExceptionFlyout.closeAlerts.successDetails": "规则例外已添加到共享列表:{listNames}。", "xpack.securitySolution.ruleExceptions.addExceptionFlyout.commentsTitle": "添加注释 ({comments})", "xpack.securitySolution.ruleExceptions.allExceptionItems.activeDetectionsLabel": "活动例外", "xpack.securitySolution.ruleExceptions.allExceptionItems.addExceptionsEmptyPromptTitle": "将例外添加到此规则",