Skip to content

Commit

Permalink
use getFilter instead of filter
Browse files Browse the repository at this point in the history
  • Loading branch information
guskovaue committed Nov 24, 2022
1 parent b44c57a commit e250d9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -261,7 +245,6 @@ export function useBulkEditSelect(props: UseBulkEditSelectProps) {
onSelectAll,
onSelectPage,
onClearSelection,
filter,
};
}, [
state,
Expand All @@ -273,6 +256,5 @@ export function useBulkEditSelect(props: UseBulkEditSelectProps) {
onSelectAll,
onSelectPage,
onClearSelection,
filter,
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ export const RulesList = ({
onSelectAll,
onSelectPage,
onClearSelection,
filter,
} = useBulkEditSelect({
totalItemCount: rulesState.totalItemCount,
items: tableItems,
Expand Down Expand Up @@ -772,29 +771,29 @@ export const RulesList = ({
setIsEnablingRules(true);

const { errors, total } = await bulkEnableRules({
...(isAllSelected ? { filter } : {}),
...(isAllSelected ? { filter: getFilter() } : {}),
ids: selectedIds,
http,
});

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,
});

setIsDisablingRules(false);
showToast({ action: 'DISABLE', errors, total });
await refreshRules();
}, [http, selectedIds, filter, setIsDisablingRules, toasts]);
}, [http, selectedIds, getFilter, setIsDisablingRules, toasts]);

const table = (
<>
Expand Down

0 comments on commit e250d9f

Please sign in to comment.