From e250d9fc4a5eb8961799173cea3656fdfc41a66f Mon Sep 17 00:00:00 2001 From: Julia Guskova Date: Thu, 24 Nov 2022 11:36:16 +0100 Subject: [PATCH] use getFilter instead of filter --- .../application/hooks/use_bulk_edit_select.tsx | 18 ------------------ .../rules_list/components/rules_list.tsx | 9 ++++----- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/hooks/use_bulk_edit_select.tsx b/x-pack/plugins/triggers_actions_ui/public/application/hooks/use_bulk_edit_select.tsx index 908bfb57bd742..e2410801dd5b4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/hooks/use_bulk_edit_select.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/hooks/use_bulk_edit_select.tsx @@ -233,22 +233,6 @@ export function useBulkEditSelect(props: UseBulkEditSelectProps) { return getFilterKueryNode(); }, [state, getFilterKueryNode]); - const filter = useMemo(() => { - const { selectedIds, isAllSelected } = state; - const idsArray = [...selectedIds]; - - if (isAllSelected) { - // Select all but nothing is selected to exclude - if (idsArray.length === 0) { - return getFilterKueryNode(); - } - // Select all, exclude certain alerts - return getFilterKueryNode(idsArray); - } - - return getFilterKueryNode(); - }, [state, getFilterKueryNode]); - return useMemo(() => { return { selectedIds: [...state.selectedIds], @@ -261,7 +245,6 @@ export function useBulkEditSelect(props: UseBulkEditSelectProps) { onSelectAll, onSelectPage, onClearSelection, - filter, }; }, [ state, @@ -273,6 +256,5 @@ export function useBulkEditSelect(props: UseBulkEditSelectProps) { onSelectAll, onSelectPage, onClearSelection, - filter, ]); } 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 7fef423e95d44..cf51dfa22ee6d 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 @@ -666,7 +666,6 @@ export const RulesList = ({ onSelectAll, onSelectPage, onClearSelection, - filter, } = useBulkEditSelect({ totalItemCount: rulesState.totalItemCount, items: tableItems, @@ -772,7 +771,7 @@ export const RulesList = ({ setIsEnablingRules(true); const { errors, total } = await bulkEnableRules({ - ...(isAllSelected ? { filter } : {}), + ...(isAllSelected ? { filter: getFilter() } : {}), ids: selectedIds, http, }); @@ -780,13 +779,13 @@ export const RulesList = ({ setIsEnablingRules(false); showToast({ action: 'ENABLE', errors, total }); await refreshRules(); - }, [http, selectedIds, filter, setIsEnablingRules, toasts]); + }, [http, selectedIds, getFilter, setIsEnablingRules, toasts]); const onDisable = useCallback(async () => { setIsDisablingRules(true); const { errors, total } = await bulkDisableRules({ - ...(isAllSelected ? { filter } : {}), + ...(isAllSelected ? { filter: getFilter() } : {}), ids: selectedIds, http, }); @@ -794,7 +793,7 @@ export const RulesList = ({ setIsDisablingRules(false); showToast({ action: 'DISABLE', errors, total }); await refreshRules(); - }, [http, selectedIds, filter, setIsDisablingRules, toasts]); + }, [http, selectedIds, getFilter, setIsDisablingRules, toasts]); const table = ( <>