Add batch run button to DeadTasksTable

This commit is contained in:
Ken Hibino
2020-12-15 06:46:23 -08:00
parent 706e80580d
commit 9bfd373f85
6 changed files with 132 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ import {
} from "../actions/queuesActions";
import {
BATCH_DELETE_DEAD_TASKS_SUCCESS,
BATCH_RUN_DEAD_TASKS_SUCCESS,
DELETE_DEAD_TASK_SUCCESS,
DELETE_RETRY_TASK_SUCCESS,
DELETE_SCHEDULED_TASK_SUCCESS,
@@ -217,6 +218,26 @@ function queuesReducer(
return { ...state, data: newData };
}
case BATCH_RUN_DEAD_TASKS_SUCCESS: {
const newData = state.data.map((queueInfo) => {
if (queueInfo.name !== action.queue) {
return queueInfo;
}
return {
...queueInfo,
currentStats: {
...queueInfo.currentStats,
pending:
queueInfo.currentStats.pending +
action.payload.pending_keys.length,
dead:
queueInfo.currentStats.dead - action.payload.pending_keys.length,
},
};
});
return { ...state, data: newData };
}
case BATCH_DELETE_DEAD_TASKS_SUCCESS: {
const newData = state.data.map((queueInfo) => {
if (queueInfo.name !== action.queue) {

View File

@@ -4,6 +4,7 @@ import {
} from "../actions/snackbarActions";
import {
BATCH_DELETE_DEAD_TASKS_SUCCESS,
BATCH_RUN_DEAD_TASKS_SUCCESS,
DELETE_DEAD_TASK_SUCCESS,
DELETE_RETRY_TASK_SUCCESS,
DELETE_SCHEDULED_TASK_SUCCESS,
@@ -62,6 +63,14 @@ function snackbarReducer(
message: `Dead task ${action.taskKey} deleted`,
};
case BATCH_RUN_DEAD_TASKS_SUCCESS: {
const n = action.payload.pending_keys.length;
return {
isOpen: true,
message: `${n} Dead ${n === 1 ? "task is" : "tasks are"} now pending`,
};
}
case BATCH_DELETE_DEAD_TASKS_SUCCESS: {
const n = action.payload.deleted_keys.length;
return {

View File

@@ -33,6 +33,9 @@ import {
RUN_DEAD_TASK_BEGIN,
RUN_DEAD_TASK_SUCCESS,
RUN_DEAD_TASK_ERROR,
BATCH_RUN_DEAD_TASKS_BEGIN,
BATCH_RUN_DEAD_TASKS_ERROR,
BATCH_RUN_DEAD_TASKS_SUCCESS,
} from "../actions/tasksActions";
import {
ActiveTask,
@@ -464,6 +467,7 @@ function tasksReducer(
},
};
case BATCH_RUN_DEAD_TASKS_BEGIN:
case BATCH_DELETE_DEAD_TASKS_BEGIN:
return {
...state,
@@ -473,6 +477,20 @@ function tasksReducer(
},
};
case BATCH_RUN_DEAD_TASKS_SUCCESS: {
const newData = state.deadTasks.data.filter(
(task) => !action.payload.pending_keys.includes(task.key)
);
return {
...state,
deadTasks: {
...state.deadTasks,
batchActionPending: false,
data: newData,
},
};
}
case BATCH_DELETE_DEAD_TASKS_SUCCESS: {
const newData = state.deadTasks.data.filter(
(task) => !action.payload.deleted_keys.includes(task.key)
@@ -487,6 +505,7 @@ function tasksReducer(
};
}
case BATCH_RUN_DEAD_TASKS_ERROR:
case BATCH_DELETE_DEAD_TASKS_ERROR:
return {
...state,