Skip to content

Commit

Permalink
change depends for useCallback from taost to showToast
Browse files Browse the repository at this point in the history
  • Loading branch information
guskovaue committed Nov 24, 2022
1 parent 0750c6e commit 5374251
Showing 1 changed file with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<>
<RulesListErrorBanner
Expand Down Expand Up @@ -1060,8 +1032,37 @@ export const RulesList = ({
useEffect(() => {
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();
Expand Down

0 comments on commit 5374251

Please sign in to comment.