Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ram 145739 use bulk enable disable in UI #145928

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change depends for useCallback from taost to showToast
guskovaue committed Nov 24, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5374251268f57fae091cee9a6b7bec6095db9ed9
Original file line number Diff line number Diff line change
@@ -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
@@ -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();