diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx index bff43bec81168..4c29d902e3883 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx @@ -767,34 +767,6 @@ export const RulesList = ({ } }; - const onEnable = useCallback(async () => { - setIsEnablingRules(true); - - const { errors, total } = await bulkEnableRules({ - ...(isAllSelected ? { filter: getFilter() } : {}), - ...(isAllSelected ? {} : { ids: selectedIds }), - http, - }); - - setIsEnablingRules(false); - showToast({ action: 'ENABLE', errors, total }); - await refreshRules(); - }, [http, selectedIds, getFilter, setIsEnablingRules, toasts]); - - const onDisable = useCallback(async () => { - setIsDisablingRules(true); - - const { errors, total } = await bulkDisableRules({ - ...(isAllSelected ? { filter: getFilter() } : {}), - ...(isAllSelected ? {} : { ids: selectedIds }), - http, - }); - - setIsDisablingRules(false); - showToast({ action: 'DISABLE', errors, total }); - await refreshRules(); - }, [http, selectedIds, getFilter, setIsDisablingRules, toasts]); - const table = ( <> { setIsDeleteModalVisibility(rulesToDelete.length > 0 || Boolean(rulesToDeleteFilter)); }, [rulesToDelete, rulesToDeleteFilter]); + const { showToast } = useBulkOperationToast({ onSearchPopulate }); + const onEnable = useCallback(async () => { + setIsEnablingRules(true); + + const { errors, total } = await bulkEnableRules({ + ...(isAllSelected ? { filter: getFilter() } : {}), + ...(isAllSelected ? {} : { ids: selectedIds }), + http, + }); + + setIsEnablingRules(false); + showToast({ action: 'ENABLE', errors, total }); + await refreshRules(); + }, [http, selectedIds, getFilter, setIsEnablingRules, showToast]); + + const onDisable = useCallback(async () => { + setIsDisablingRules(true); + + const { errors, total } = await bulkDisableRules({ + ...(isAllSelected ? { filter: getFilter() } : {}), + ...(isAllSelected ? {} : { ids: selectedIds }), + http, + }); + + setIsDisablingRules(false); + showToast({ action: 'DISABLE', errors, total }); + await refreshRules(); + }, [http, selectedIds, getFilter, setIsDisablingRules, showToast]); + const onDeleteCancel = () => { setIsDeleteModalVisibility(false); clearRulesToDelete();