From f0fcc90bb299f9a1454b09078d2829f94df65793 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 6 Sep 2023 15:50:21 +0800 Subject: [PATCH] Add validation check to bulk action --- packages/web/pages/tools/bulk.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/web/pages/tools/bulk.tsx b/packages/web/pages/tools/bulk.tsx index 9779f0cda..ab74aed27 100644 --- a/packages/web/pages/tools/bulk.tsx +++ b/packages/web/pages/tools/bulk.tsx @@ -47,16 +47,24 @@ export default function BulkPerformer(): JSX.Element { const performAction = useCallback(() => { ;(async () => { console.log('performing action: ', action) + if (isValidating) { + showErrorToast('Query still being validated.') + return + } if (!action) { showErrorToast('Unable to run action, no action set.') return } + if (!expectedCount) { + showErrorToast('No items matching this query or query still running.') + return + } + if (!action) { + showErrorToast('No action selected') + return + } try { - // action: BulkAction, - // query: string, - // expectedCount: number, - // labelIds?: string[] - const success = await bulkActionMutation(action, query, size) + const success = await bulkActionMutation(action, query, expectedCount) if (!success) { throw 'Success not returned' } @@ -66,7 +74,7 @@ export default function BulkPerformer(): JSX.Element { showErrorToast('Error performing bulk action.') } })() - }, [action]) + }, [action, query, expectedCount]) return (