Add delete task button to RetryTasksTable

This commit is contained in:
Ken Hibino
2020-12-08 21:22:23 -08:00
parent 48c2cda3bf
commit 601a7c8add
6 changed files with 150 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import {
DELETE_QUEUE_SUCCESS,
} from "../actions/queuesActions";
import {
DELETE_RETRY_TASK_SUCCESS,
LIST_ACTIVE_TASKS_SUCCESS,
LIST_DEAD_TASKS_SUCCESS,
LIST_PENDING_TASKS_SUCCESS,
@@ -147,6 +148,22 @@ function queuesReducer(
return { ...state, data: newData };
}
case DELETE_RETRY_TASK_SUCCESS: {
const newData = state.data.map((queueInfo) => {
if (queueInfo.name !== action.queue) {
return queueInfo;
}
return {
...queueInfo,
currentStats: {
...queueInfo.currentStats,
retry: queueInfo.currentStats.retry - 1,
},
};
});
return { ...state, data: newData };
}
default:
return state;
}

View File

@@ -18,6 +18,9 @@ import {
CANCEL_ACTIVE_TASK_BEGIN,
CANCEL_ACTIVE_TASK_SUCCESS,
CANCEL_ACTIVE_TASK_ERROR,
DELETE_RETRY_TASK_BEGIN,
DELETE_RETRY_TASK_SUCCESS,
DELETE_RETRY_TASK_ERROR,
} from "../actions/tasksActions";
import {
ActiveTask,
@@ -37,6 +40,12 @@ export interface ActiveTaskExtended extends ActiveTask {
canceling: boolean;
}
export interface RetryTaskExtended extends RetryTask {
// Indicates that a request has been sent for this
// task and awaiting for a response.
requestPending: boolean;
}
interface TasksState {
activeTasks: {
loading: boolean;
@@ -56,7 +65,7 @@ interface TasksState {
retryTasks: {
loading: boolean;
error: string;
data: RetryTask[];
data: RetryTaskExtended[];
};
deadTasks: {
loading: boolean;
@@ -208,7 +217,10 @@ function tasksReducer(
retryTasks: {
loading: false,
error: "",
data: action.payload.tasks,
data: action.payload.tasks.map((task) => ({
...task,
requestPending: false,
})),
},
};
@@ -299,6 +311,45 @@ function tasksReducer(
},
};
case DELETE_RETRY_TASK_BEGIN:
return {
...state,
retryTasks: {
...state.retryTasks,
data: state.retryTasks.data.map((task) => {
if (task.key !== action.taskKey) {
return task;
}
return { ...task, requestPending: true };
}),
},
};
case DELETE_RETRY_TASK_SUCCESS:
return {
...state,
retryTasks: {
...state.retryTasks,
data: state.retryTasks.data.filter(
(task) => task.key !== action.taskKey
),
},
};
case DELETE_RETRY_TASK_ERROR:
return {
...state,
retryTasks: {
...state.retryTasks,
data: state.retryTasks.data.map((task) => {
if (task.key !== action.taskKey) {
return task;
}
return { ...task, requestPending: false };
}),
},
};
default:
return state;
}