MCPcopy Create free account
hub / github.com/coder/coder / useBatchTaskActions

Function useBatchTaskActions

site/src/pages/TasksPage/batchActions.ts:15–36  ·  view source on GitHub ↗
(
	options: UseBatchTaskActionsOptions,
)

Source from the content-addressed store, hash-verified

13}>;
14
15export function useBatchTaskActions(
16 options: UseBatchTaskActionsOptions,
17): UseBatchTaskActionsResult {
18 const { onSuccess } = options;
19
20 const deleteAllMutation = useMutation({
21 mutationFn: async (tasks: readonly Task[]): Promise<void> => {
22 await Promise.all(
23 tasks.map((task) => API.deleteTask(task.owner_name, task.id)),
24 );
25 },
26 onSuccess,
27 onError: () => {
28 toast.error("Failed to delete some tasks.");
29 },
30 });
31
32 return {
33 delete: deleteAllMutation.mutateAsync,
34 isProcessing: deleteAllMutation.isPending,
35 };
36}

Callers 1

TasksPageFunction · 0.90

Calls 1

allMethod · 0.80

Tested by

no test coverage detected