Add run-all dead tasks action button to DeadTasksTable

This commit is contained in:
Ken Hibino
2020-12-17 06:57:30 -08:00
parent 4d5de30a57
commit bf81787115
6 changed files with 104 additions and 13 deletions

View File

@@ -25,6 +25,7 @@ import {
LIST_PENDING_TASKS_SUCCESS,
LIST_RETRY_TASKS_SUCCESS,
LIST_SCHEDULED_TASKS_SUCCESS,
RUN_ALL_DEAD_TASKS_SUCCESS,
RUN_DEAD_TASK_SUCCESS,
TasksActionTypes,
} from "../actions/tasksActions";
@@ -256,6 +257,24 @@ function queuesReducer(
return { ...state, data: newData };
}
case RUN_ALL_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 + queueInfo.currentStats.dead,
dead: 0,
},
};
});
return { ...state, data: newData };
}
case DELETE_ALL_DEAD_TASKS_SUCCESS: {
const newData = state.data.map((queueInfo) => {
if (queueInfo.name !== action.queue) {

View File

@@ -9,6 +9,7 @@ import {
DELETE_DEAD_TASK_SUCCESS,
DELETE_RETRY_TASK_SUCCESS,
DELETE_SCHEDULED_TASK_SUCCESS,
RUN_ALL_DEAD_TASKS_SUCCESS,
RUN_DEAD_TASK_SUCCESS,
TasksActionTypes,
} from "../actions/tasksActions";
@@ -80,10 +81,16 @@ function snackbarReducer(
};
}
case RUN_ALL_DEAD_TASKS_SUCCESS:
return {
isOpen: true,
message: "All dead tasks are now pending",
};
case DELETE_ALL_DEAD_TASKS_SUCCESS:
return {
isOpen: true,
message: `All dead tasks delete`,
message: "All dead tasks delete",
};
default:

View File

@@ -39,6 +39,9 @@ import {
DELETE_ALL_DEAD_TASKS_BEGIN,
DELETE_ALL_DEAD_TASKS_SUCCESS,
DELETE_ALL_DEAD_TASKS_ERROR,
RUN_ALL_DEAD_TASKS_BEGIN,
RUN_ALL_DEAD_TASKS_ERROR,
RUN_ALL_DEAD_TASKS_SUCCESS,
} from "../actions/tasksActions";
import {
ActiveTask,
@@ -100,7 +103,7 @@ interface TasksState {
deadTasks: {
loading: boolean;
batchActionPending: boolean;
deleteAllRequestPending: boolean;
allActionPending: boolean;
error: string;
data: DeadTaskExtended[];
};
@@ -130,7 +133,7 @@ const initialState: TasksState = {
deadTasks: {
loading: false,
batchActionPending: false,
deleteAllRequestPending: false,
allActionPending: false,
error: "",
data: [],
},
@@ -472,31 +475,34 @@ function tasksReducer(
},
};
case RUN_ALL_DEAD_TASKS_BEGIN:
case DELETE_ALL_DEAD_TASKS_BEGIN:
return {
...state,
deadTasks: {
...state.deadTasks,
deleteAllRequestPending: true,
allActionPending: true,
},
};
case RUN_ALL_DEAD_TASKS_SUCCESS:
case DELETE_ALL_DEAD_TASKS_SUCCESS:
return {
...state,
deadTasks: {
...state.deadTasks,
deleteAllRequestPending: false,
allActionPending: false,
data: [],
},
};
case RUN_ALL_DEAD_TASKS_ERROR:
case DELETE_ALL_DEAD_TASKS_ERROR:
return {
...state,
deadTasks: {
...state.deadTasks,
deleteAllRequestPending: false,
allActionPending: false,
},
};