diff --git a/ui/src/actions/tasksActions.ts b/ui/src/actions/tasksActions.ts index 2e7be94..7e4858a 100644 --- a/ui/src/actions/tasksActions.ts +++ b/ui/src/actions/tasksActions.ts @@ -1,6 +1,8 @@ import { batchDeleteDeadTasks, BatchDeleteTasksResponse, + batchRunDeadTasks, + BatchRunTasksResponse, cancelActiveTask, deleteDeadTask, deleteRetryTask, @@ -51,6 +53,9 @@ export const DELETE_RETRY_TASK_ERROR = "DELETE_RETRY_TASK_ERROR"; export const DELETE_DEAD_TASK_BEGIN = "DELETE_DEAD_TASK_BEGIN"; export const DELETE_DEAD_TASK_SUCCESS = "DELETE_DEAD_TASK_SUCCESS"; export const DELETE_DEAD_TASK_ERROR = "DELETE_DEAD_TASK_ERROR"; +export const BATCH_RUN_DEAD_TASKS_BEGIN = "BATCH_RUN_DEAD_TASKS_BEGIN"; +export const BATCH_RUN_DEAD_TASKS_SUCCESS = "BATCH_RUN_DEAD_TASKS_SUCCESS"; +export const BATCH_RUN_DEAD_TASKS_ERROR = "BATCH_RUN_DEAD_TASKS_ERROR"; export const BATCH_DELETE_DEAD_TASKS_BEGIN = "BATCH_DELETE_DEAD_TASKS_BEGIN"; export const BATCH_DELETE_DEAD_TASKS_SUCCESS = "BATCH_DELETE_DEAD_TASKS_SUCCESS"; @@ -255,6 +260,25 @@ interface BatchDeleteDeadTasksErrorAction { error: string; } +interface BatchRunDeadTasksBeginAction { + type: typeof BATCH_RUN_DEAD_TASKS_BEGIN; + queue: string; + taskKeys: string[]; +} + +interface BatchRunDeadTasksSuccessAction { + type: typeof BATCH_RUN_DEAD_TASKS_SUCCESS; + queue: string; + payload: BatchRunTasksResponse; +} + +interface BatchRunDeadTasksErrorAction { + type: typeof BATCH_RUN_DEAD_TASKS_ERROR; + queue: string; + taskKeys: string[]; + error: string; +} + // Union of all tasks related action types. export type TasksActionTypes = | ListActiveTasksBeginAction @@ -289,7 +313,10 @@ export type TasksActionTypes = | DeleteDeadTaskErrorAction | BatchDeleteDeadTasksBeginAction | BatchDeleteDeadTasksSuccessAction - | BatchDeleteDeadTasksErrorAction; + | BatchDeleteDeadTasksErrorAction + | BatchRunDeadTasksBeginAction + | BatchRunDeadTasksSuccessAction + | BatchRunDeadTasksErrorAction; export function listActiveTasksAsync( qname: string, @@ -516,3 +543,25 @@ export function batchDeleteDeadTasksAsync(queue: string, taskKeys: string[]) { } }; } + +export function batchRunDeadTasksAsync(queue: string, taskKeys: string[]) { + return async (dispatch: Dispatch) => { + dispatch({ type: BATCH_RUN_DEAD_TASKS_BEGIN, queue, taskKeys }); + try { + const response = await batchRunDeadTasks(queue, taskKeys); + dispatch({ + type: BATCH_RUN_DEAD_TASKS_SUCCESS, + queue: queue, + payload: response, + }); + } catch (error) { + console.error("batchRunDeadTasksAsync: ", error); + dispatch({ + type: BATCH_RUN_DEAD_TASKS_ERROR, + error: `Could not batch run tasks: ${taskKeys}`, + queue, + taskKeys, + }); + } + }; +} diff --git a/ui/src/api.ts b/ui/src/api.ts index d891535..3ec622d 100644 --- a/ui/src/api.ts +++ b/ui/src/api.ts @@ -46,6 +46,11 @@ export interface BatchDeleteTasksResponse { failed_keys: string[]; } +export interface BatchRunTasksResponse { + pending_keys: string[]; + error_keys: string[]; +} + export interface Queue { queue: string; paused: boolean; @@ -299,7 +304,20 @@ export async function batchDeleteDeadTasks( task_keys: taskKeys, }, }); - console.log("debug: response:", resp); + return resp.data; +} + +export async function batchRunDeadTasks( + qname: string, + taskKeys: string[] +): Promise { + const resp = await axios({ + method: "post", + url: `${BASE_URL}/queues/${qname}/dead_tasks:batch_run`, + data: { + task_keys: taskKeys, + }, + }); return resp.data; } diff --git a/ui/src/components/DeadTasksTable.tsx b/ui/src/components/DeadTasksTable.tsx index 6eca407..eb72388 100644 --- a/ui/src/components/DeadTasksTable.tsx +++ b/ui/src/components/DeadTasksTable.tsx @@ -26,10 +26,11 @@ import SyntaxHighlighter from "react-syntax-highlighter"; import syntaxHighlightStyle from "react-syntax-highlighter/dist/esm/styles/hljs/github"; import { AppState } from "../store"; import { + batchDeleteDeadTasksAsync, + batchRunDeadTasksAsync, + deleteDeadTaskAsync, listDeadTasksAsync, runDeadTaskAsync, - deleteDeadTaskAsync, - batchDeleteDeadTasksAsync, } from "../actions/tasksActions"; import TablePaginationActions, { defaultPageSize, @@ -72,6 +73,7 @@ const mapDispatchToProps = { listDeadTasksAsync, runDeadTaskAsync, deleteDeadTaskAsync, + batchRunDeadTasksAsync, batchDeleteDeadTasksAsync, }; @@ -153,7 +155,16 @@ function DeadTasksTable(props: Props & ReduxProps) { color="primary" aria-label="text primary button group" > - +