2020-11-24 22:54:00 +08:00
|
|
|
import {
|
|
|
|
LIST_ACTIVE_TASKS_BEGIN,
|
|
|
|
LIST_ACTIVE_TASKS_SUCCESS,
|
|
|
|
LIST_ACTIVE_TASKS_ERROR,
|
|
|
|
TasksActionTypes,
|
|
|
|
LIST_PENDING_TASKS_BEGIN,
|
|
|
|
LIST_PENDING_TASKS_SUCCESS,
|
|
|
|
LIST_PENDING_TASKS_ERROR,
|
|
|
|
LIST_SCHEDULED_TASKS_BEGIN,
|
|
|
|
LIST_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
LIST_SCHEDULED_TASKS_ERROR,
|
|
|
|
LIST_RETRY_TASKS_BEGIN,
|
|
|
|
LIST_RETRY_TASKS_SUCCESS,
|
|
|
|
LIST_RETRY_TASKS_ERROR,
|
2021-01-13 03:59:44 +08:00
|
|
|
LIST_ARCHIVED_TASKS_BEGIN,
|
|
|
|
LIST_ARCHIVED_TASKS_SUCCESS,
|
|
|
|
LIST_ARCHIVED_TASKS_ERROR,
|
2020-12-06 01:24:42 +08:00
|
|
|
CANCEL_ACTIVE_TASK_BEGIN,
|
|
|
|
CANCEL_ACTIVE_TASK_SUCCESS,
|
|
|
|
CANCEL_ACTIVE_TASK_ERROR,
|
2020-12-09 13:22:23 +08:00
|
|
|
DELETE_RETRY_TASK_BEGIN,
|
|
|
|
DELETE_RETRY_TASK_SUCCESS,
|
|
|
|
DELETE_RETRY_TASK_ERROR,
|
2020-12-09 22:56:44 +08:00
|
|
|
DELETE_SCHEDULED_TASK_BEGIN,
|
|
|
|
DELETE_SCHEDULED_TASK_SUCCESS,
|
|
|
|
DELETE_SCHEDULED_TASK_ERROR,
|
2021-01-13 03:59:44 +08:00
|
|
|
DELETE_ARCHIVED_TASK_BEGIN,
|
|
|
|
DELETE_ARCHIVED_TASK_SUCCESS,
|
|
|
|
DELETE_ARCHIVED_TASK_ERROR,
|
|
|
|
BATCH_DELETE_ARCHIVED_TASKS_BEGIN,
|
|
|
|
BATCH_DELETE_ARCHIVED_TASKS_SUCCESS,
|
|
|
|
BATCH_DELETE_ARCHIVED_TASKS_ERROR,
|
|
|
|
RUN_ARCHIVED_TASK_BEGIN,
|
|
|
|
RUN_ARCHIVED_TASK_SUCCESS,
|
|
|
|
RUN_ARCHIVED_TASK_ERROR,
|
|
|
|
BATCH_RUN_ARCHIVED_TASKS_BEGIN,
|
|
|
|
BATCH_RUN_ARCHIVED_TASKS_ERROR,
|
|
|
|
BATCH_RUN_ARCHIVED_TASKS_SUCCESS,
|
|
|
|
DELETE_ALL_ARCHIVED_TASKS_BEGIN,
|
|
|
|
DELETE_ALL_ARCHIVED_TASKS_SUCCESS,
|
|
|
|
DELETE_ALL_ARCHIVED_TASKS_ERROR,
|
|
|
|
RUN_ALL_ARCHIVED_TASKS_BEGIN,
|
|
|
|
RUN_ALL_ARCHIVED_TASKS_ERROR,
|
|
|
|
RUN_ALL_ARCHIVED_TASKS_SUCCESS,
|
2020-12-19 22:07:23 +08:00
|
|
|
BATCH_DELETE_RETRY_TASKS_ERROR,
|
|
|
|
BATCH_RUN_RETRY_TASKS_ERROR,
|
|
|
|
BATCH_DELETE_RETRY_TASKS_SUCCESS,
|
|
|
|
BATCH_RUN_RETRY_TASKS_SUCCESS,
|
|
|
|
BATCH_DELETE_RETRY_TASKS_BEGIN,
|
|
|
|
BATCH_RUN_RETRY_TASKS_BEGIN,
|
|
|
|
DELETE_ALL_RETRY_TASKS_ERROR,
|
|
|
|
RUN_ALL_RETRY_TASKS_ERROR,
|
|
|
|
DELETE_ALL_RETRY_TASKS_SUCCESS,
|
|
|
|
RUN_ALL_RETRY_TASKS_SUCCESS,
|
|
|
|
DELETE_ALL_RETRY_TASKS_BEGIN,
|
|
|
|
RUN_ALL_RETRY_TASKS_BEGIN,
|
|
|
|
BATCH_DELETE_SCHEDULED_TASKS_ERROR,
|
|
|
|
BATCH_RUN_SCHEDULED_TASKS_ERROR,
|
|
|
|
BATCH_DELETE_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
BATCH_RUN_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
BATCH_DELETE_SCHEDULED_TASKS_BEGIN,
|
|
|
|
BATCH_RUN_SCHEDULED_TASKS_BEGIN,
|
|
|
|
DELETE_ALL_SCHEDULED_TASKS_ERROR,
|
|
|
|
RUN_ALL_SCHEDULED_TASKS_ERROR,
|
|
|
|
DELETE_ALL_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
RUN_ALL_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
DELETE_ALL_SCHEDULED_TASKS_BEGIN,
|
|
|
|
RUN_ALL_SCHEDULED_TASKS_BEGIN,
|
2020-12-19 22:35:08 +08:00
|
|
|
RUN_RETRY_TASK_BEGIN,
|
|
|
|
RUN_RETRY_TASK_SUCCESS,
|
|
|
|
RUN_RETRY_TASK_ERROR,
|
|
|
|
RUN_SCHEDULED_TASK_BEGIN,
|
|
|
|
RUN_SCHEDULED_TASK_SUCCESS,
|
|
|
|
RUN_SCHEDULED_TASK_ERROR,
|
2021-01-13 03:59:44 +08:00
|
|
|
ARCHIVE_SCHEDULED_TASK_BEGIN,
|
|
|
|
ARCHIVE_SCHEDULED_TASK_SUCCESS,
|
|
|
|
ARCHIVE_SCHEDULED_TASK_ERROR,
|
|
|
|
ARCHIVE_ALL_SCHEDULED_TASKS_BEGIN,
|
|
|
|
ARCHIVE_ALL_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
ARCHIVE_ALL_SCHEDULED_TASKS_ERROR,
|
|
|
|
BATCH_ARCHIVE_SCHEDULED_TASKS_BEGIN,
|
|
|
|
BATCH_ARCHIVE_SCHEDULED_TASKS_ERROR,
|
|
|
|
BATCH_ARCHIVE_SCHEDULED_TASKS_SUCCESS,
|
|
|
|
ARCHIVE_RETRY_TASK_BEGIN,
|
|
|
|
ARCHIVE_RETRY_TASK_SUCCESS,
|
|
|
|
ARCHIVE_RETRY_TASK_ERROR,
|
|
|
|
ARCHIVE_ALL_RETRY_TASKS_BEGIN,
|
|
|
|
ARCHIVE_ALL_RETRY_TASKS_SUCCESS,
|
|
|
|
ARCHIVE_ALL_RETRY_TASKS_ERROR,
|
|
|
|
BATCH_ARCHIVE_RETRY_TASKS_SUCCESS,
|
|
|
|
BATCH_ARCHIVE_RETRY_TASKS_BEGIN,
|
|
|
|
BATCH_ARCHIVE_RETRY_TASKS_ERROR,
|
2020-12-23 22:59:44 +08:00
|
|
|
BATCH_CANCEL_ACTIVE_TASKS_BEGIN,
|
|
|
|
BATCH_CANCEL_ACTIVE_TASKS_SUCCESS,
|
|
|
|
BATCH_CANCEL_ACTIVE_TASKS_ERROR,
|
|
|
|
CANCEL_ALL_ACTIVE_TASKS_BEGIN,
|
|
|
|
CANCEL_ALL_ACTIVE_TASKS_SUCCESS,
|
|
|
|
CANCEL_ALL_ACTIVE_TASKS_ERROR,
|
2020-11-24 22:54:00 +08:00
|
|
|
} from "../actions/tasksActions";
|
|
|
|
import {
|
|
|
|
ActiveTask,
|
2021-01-13 03:59:44 +08:00
|
|
|
ArchivedTask,
|
2020-11-24 22:54:00 +08:00
|
|
|
PendingTask,
|
|
|
|
RetryTask,
|
|
|
|
ScheduledTask,
|
|
|
|
} from "../api";
|
|
|
|
|
2020-12-06 06:31:33 +08:00
|
|
|
export interface ActiveTaskExtended extends ActiveTask {
|
2020-12-06 01:24:42 +08:00
|
|
|
// Indicates that a request has been sent for this
|
|
|
|
// task and awaiting for a response.
|
|
|
|
requestPending: boolean;
|
|
|
|
|
|
|
|
// Incidates that a cancelation signal has been
|
|
|
|
// published for this task.
|
|
|
|
canceling: boolean;
|
|
|
|
}
|
|
|
|
|
2020-12-09 22:56:44 +08:00
|
|
|
export interface ScheduledTaskExtended extends ScheduledTask {
|
|
|
|
// Indicates that a request has been sent for this
|
|
|
|
// task and awaiting for a response.
|
|
|
|
requestPending: boolean;
|
|
|
|
}
|
|
|
|
|
2020-12-09 13:22:23 +08:00
|
|
|
export interface RetryTaskExtended extends RetryTask {
|
|
|
|
// Indicates that a request has been sent for this
|
|
|
|
// task and awaiting for a response.
|
|
|
|
requestPending: boolean;
|
|
|
|
}
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
export interface ArchivedTaskExtended extends ArchivedTask {
|
2020-12-09 22:56:44 +08:00
|
|
|
// Indicates that a request has been sent for this
|
|
|
|
// task and awaiting for a response.
|
|
|
|
requestPending: boolean;
|
|
|
|
}
|
|
|
|
|
2020-11-24 22:54:00 +08:00
|
|
|
interface TasksState {
|
|
|
|
activeTasks: {
|
|
|
|
loading: boolean;
|
2020-12-23 22:59:44 +08:00
|
|
|
batchActionPending: boolean;
|
|
|
|
allActionPending: boolean;
|
2020-11-24 22:54:00 +08:00
|
|
|
error: string;
|
2020-12-06 01:24:42 +08:00
|
|
|
data: ActiveTaskExtended[];
|
2020-11-24 22:54:00 +08:00
|
|
|
};
|
|
|
|
pendingTasks: {
|
|
|
|
loading: boolean;
|
|
|
|
error: string;
|
|
|
|
data: PendingTask[];
|
|
|
|
};
|
|
|
|
scheduledTasks: {
|
|
|
|
loading: boolean;
|
2020-12-19 04:48:05 +08:00
|
|
|
batchActionPending: boolean;
|
|
|
|
allActionPending: boolean;
|
2020-11-24 22:54:00 +08:00
|
|
|
error: string;
|
2020-12-09 22:56:44 +08:00
|
|
|
data: ScheduledTaskExtended[];
|
2020-11-24 22:54:00 +08:00
|
|
|
};
|
|
|
|
retryTasks: {
|
|
|
|
loading: boolean;
|
2020-12-19 04:48:05 +08:00
|
|
|
batchActionPending: boolean;
|
|
|
|
allActionPending: boolean;
|
2020-11-24 22:54:00 +08:00
|
|
|
error: string;
|
2020-12-09 13:22:23 +08:00
|
|
|
data: RetryTaskExtended[];
|
2020-11-24 22:54:00 +08:00
|
|
|
};
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: boolean;
|
2020-12-13 23:51:40 +08:00
|
|
|
batchActionPending: boolean;
|
2020-12-17 22:57:30 +08:00
|
|
|
allActionPending: boolean;
|
2020-11-24 22:54:00 +08:00
|
|
|
error: string;
|
2021-01-13 03:59:44 +08:00
|
|
|
data: ArchivedTaskExtended[];
|
2020-11-24 22:54:00 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const initialState: TasksState = {
|
|
|
|
activeTasks: {
|
|
|
|
loading: false,
|
2020-12-23 22:59:44 +08:00
|
|
|
batchActionPending: false,
|
|
|
|
allActionPending: false,
|
2020-11-24 22:54:00 +08:00
|
|
|
error: "",
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
pendingTasks: {
|
|
|
|
loading: false,
|
|
|
|
error: "",
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
scheduledTasks: {
|
|
|
|
loading: false,
|
2020-12-19 04:48:05 +08:00
|
|
|
batchActionPending: false,
|
|
|
|
allActionPending: false,
|
2020-11-24 22:54:00 +08:00
|
|
|
error: "",
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
retryTasks: {
|
|
|
|
loading: false,
|
2020-12-19 04:48:05 +08:00
|
|
|
batchActionPending: false,
|
|
|
|
allActionPending: false,
|
2020-11-24 22:54:00 +08:00
|
|
|
error: "",
|
|
|
|
data: [],
|
|
|
|
},
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
2020-12-13 23:51:40 +08:00
|
|
|
batchActionPending: false,
|
2020-12-17 22:57:30 +08:00
|
|
|
allActionPending: false,
|
2020-11-24 22:54:00 +08:00
|
|
|
error: "",
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function tasksReducer(
|
|
|
|
state = initialState,
|
|
|
|
action: TasksActionTypes
|
|
|
|
): TasksState {
|
|
|
|
switch (action.type) {
|
|
|
|
case LIST_ACTIVE_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
error: "",
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_ACTIVE_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
2020-12-23 22:59:44 +08:00
|
|
|
...state.activeTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
|
|
|
error: "",
|
2020-12-06 01:24:42 +08:00
|
|
|
data: action.payload.tasks.map((task) => ({
|
|
|
|
...task,
|
|
|
|
canceling: false,
|
|
|
|
requestPending: false,
|
|
|
|
})),
|
2020-11-24 22:54:00 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_ACTIVE_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
loading: false,
|
|
|
|
error: action.error,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_PENDING_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingTasks: {
|
|
|
|
...state.pendingTasks,
|
|
|
|
error: "",
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_PENDING_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingTasks: {
|
|
|
|
loading: false,
|
|
|
|
error: "",
|
|
|
|
data: action.payload.tasks,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_PENDING_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingTasks: {
|
|
|
|
...state.pendingTasks,
|
|
|
|
loading: false,
|
|
|
|
error: action.error,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_SCHEDULED_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
error: "",
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_SCHEDULED_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
2020-12-19 04:48:05 +08:00
|
|
|
...state.scheduledTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
|
|
|
error: "",
|
2020-12-09 22:56:44 +08:00
|
|
|
data: action.payload.tasks.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
})),
|
2020-11-24 22:54:00 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_SCHEDULED_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
loading: false,
|
|
|
|
error: action.error,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_RETRY_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
error: "",
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_RETRY_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
2020-12-19 04:48:05 +08:00
|
|
|
...state.retryTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
|
|
|
error: "",
|
2020-12-09 13:22:23 +08:00
|
|
|
data: action.payload.tasks.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
})),
|
2020-11-24 22:54:00 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case LIST_RETRY_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
loading: false,
|
|
|
|
error: action.error,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case LIST_ARCHIVED_TASKS_BEGIN:
|
2020-11-24 22:54:00 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
error: "",
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case LIST_ARCHIVED_TASKS_SUCCESS:
|
2020-11-24 22:54:00 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
|
|
|
error: "",
|
2020-12-09 22:56:44 +08:00
|
|
|
data: action.payload.tasks.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
})),
|
2020-11-24 22:54:00 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case LIST_ARCHIVED_TASKS_ERROR:
|
2020-11-24 22:54:00 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-11-24 22:54:00 +08:00
|
|
|
loading: false,
|
|
|
|
error: action.error,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-06 01:24:42 +08:00
|
|
|
case CANCEL_ACTIVE_TASK_BEGIN: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
if (task.id !== action.taskId) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: true };
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case CANCEL_ACTIVE_TASK_SUCCESS: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
if (task.id !== action.taskId) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: false, canceling: true };
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case CANCEL_ACTIVE_TASK_ERROR:
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
if (task.id !== action.taskId) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: false };
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-23 22:59:44 +08:00
|
|
|
case BATCH_CANCEL_ACTIVE_TASKS_BEGIN: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
if (!action.taskIds.includes(task.id)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: true };
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
batchActionPending: true,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case BATCH_CANCEL_ACTIVE_TASKS_SUCCESS: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
if (action.payload.canceled_ids.includes(task.id)) {
|
|
|
|
return { ...task, canceling: true, requestPending: false };
|
|
|
|
}
|
|
|
|
if (action.payload.error_ids.includes(task.id)) {
|
|
|
|
return { ...task, requestPending: false };
|
|
|
|
}
|
|
|
|
return task;
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case BATCH_CANCEL_ACTIVE_TASKS_ERROR: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => {
|
|
|
|
return { ...task, requestPending: false };
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case CANCEL_ALL_ACTIVE_TASKS_BEGIN: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: true,
|
|
|
|
}));
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
allActionPending: true,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case CANCEL_ALL_ACTIVE_TASKS_SUCCESS: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
canceling: true,
|
|
|
|
}));
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case CANCEL_ALL_ACTIVE_TASKS_ERROR: {
|
|
|
|
const newData = state.activeTasks.data.map((task) => ({
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
}));
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeTasks: {
|
|
|
|
...state.activeTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_SCHEDULED_TASK_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_SCHEDULED_TASK_BEGIN:
|
2020-12-09 22:56:44 +08:00
|
|
|
case DELETE_SCHEDULED_TASK_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
data: state.scheduledTasks.data.map((task) => {
|
|
|
|
if (task.key !== action.taskKey) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: true };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_SCHEDULED_TASK_SUCCESS:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_SCHEDULED_TASK_SUCCESS:
|
2020-12-09 22:56:44 +08:00
|
|
|
case DELETE_SCHEDULED_TASK_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
data: state.scheduledTasks.data.filter(
|
|
|
|
(task) => task.key !== action.taskKey
|
|
|
|
),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_SCHEDULED_TASK_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_SCHEDULED_TASK_ERROR:
|
2020-12-09 22:56:44 +08:00
|
|
|
case DELETE_SCHEDULED_TASK_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
data: state.scheduledTasks.data.map((task) => {
|
|
|
|
if (task.key !== action.taskKey) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: false };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:07:23 +08:00
|
|
|
case RUN_ALL_SCHEDULED_TASKS_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_SCHEDULED_TASKS_BEGIN:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_SCHEDULED_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
allActionPending: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case RUN_ALL_SCHEDULED_TASKS_SUCCESS:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_SCHEDULED_TASKS_SUCCESS:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_SCHEDULED_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case RUN_ALL_SCHEDULED_TASKS_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_SCHEDULED_TASKS_ERROR:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_SCHEDULED_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case BATCH_RUN_SCHEDULED_TASKS_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_SCHEDULED_TASKS_BEGIN:
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_SCHEDULED_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
batchActionPending: true,
|
|
|
|
data: state.scheduledTasks.data.map((task) => {
|
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: true,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case BATCH_RUN_SCHEDULED_TASKS_SUCCESS: {
|
|
|
|
const newData = state.scheduledTasks.data.filter(
|
|
|
|
(task) => !action.payload.pending_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_SCHEDULED_TASKS_SUCCESS: {
|
2020-12-19 23:38:23 +08:00
|
|
|
const newData = state.scheduledTasks.data.filter(
|
2021-01-13 03:59:44 +08:00
|
|
|
(task) => !action.payload.archived_keys.includes(task.key)
|
2020-12-19 23:38:23 +08:00
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_SCHEDULED_TASKS_SUCCESS: {
|
|
|
|
const newData = state.scheduledTasks.data.filter(
|
|
|
|
(task) => !action.payload.deleted_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case BATCH_RUN_SCHEDULED_TASKS_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_SCHEDULED_TASKS_ERROR:
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_SCHEDULED_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
scheduledTasks: {
|
|
|
|
...state.scheduledTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: state.scheduledTasks.data.map((task) => {
|
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_RETRY_TASK_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_RETRY_TASK_BEGIN:
|
2020-12-09 13:22:23 +08:00
|
|
|
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 };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_RETRY_TASK_SUCCESS:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_RETRY_TASK_SUCCESS:
|
2020-12-09 13:22:23 +08:00
|
|
|
case DELETE_RETRY_TASK_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
data: state.retryTasks.data.filter(
|
|
|
|
(task) => task.key !== action.taskKey
|
|
|
|
),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:35:08 +08:00
|
|
|
case RUN_RETRY_TASK_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_RETRY_TASK_ERROR:
|
2020-12-09 13:22:23 +08:00
|
|
|
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 };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-12-19 22:07:23 +08:00
|
|
|
case RUN_ALL_RETRY_TASKS_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_RETRY_TASKS_BEGIN:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_RETRY_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
allActionPending: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case RUN_ALL_RETRY_TASKS_SUCCESS:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_RETRY_TASKS_SUCCESS:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_RETRY_TASKS_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case RUN_ALL_RETRY_TASKS_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case ARCHIVE_ALL_RETRY_TASKS_ERROR:
|
2020-12-19 22:07:23 +08:00
|
|
|
case DELETE_ALL_RETRY_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
allActionPending: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case BATCH_RUN_RETRY_TASKS_BEGIN:
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_RETRY_TASKS_BEGIN:
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_RETRY_TASKS_BEGIN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
batchActionPending: true,
|
|
|
|
data: state.retryTasks.data.map((task) => {
|
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: true,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
case BATCH_RUN_RETRY_TASKS_SUCCESS: {
|
|
|
|
const newData = state.retryTasks.data.filter(
|
|
|
|
(task) => !action.payload.pending_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_RETRY_TASKS_SUCCESS: {
|
2020-12-19 23:38:23 +08:00
|
|
|
const newData = state.retryTasks.data.filter(
|
2021-01-13 03:59:44 +08:00
|
|
|
(task) => !action.payload.archived_keys.includes(task.key)
|
2020-12-19 23:38:23 +08:00
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_RETRY_TASKS_SUCCESS: {
|
|
|
|
const newData = state.retryTasks.data.filter(
|
|
|
|
(task) => !action.payload.deleted_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case BATCH_RUN_RETRY_TASKS_ERROR:
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_ARCHIVE_RETRY_TASKS_ERROR:
|
2020-12-19 22:07:23 +08:00
|
|
|
case BATCH_DELETE_RETRY_TASKS_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
retryTasks: {
|
|
|
|
...state.retryTasks,
|
|
|
|
batchActionPending: false,
|
|
|
|
data: state.retryTasks.data.map((task) => {
|
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ARCHIVED_TASK_BEGIN:
|
|
|
|
case DELETE_ARCHIVED_TASK_BEGIN:
|
2020-12-09 22:56:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
|
|
|
data: state.archivedTasks.data.map((task) => {
|
2020-12-09 22:56:44 +08:00
|
|
|
if (task.key !== action.taskKey) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: true };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ARCHIVED_TASK_SUCCESS:
|
|
|
|
case DELETE_ARCHIVED_TASK_SUCCESS:
|
2020-12-09 22:56:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
|
|
|
data: state.archivedTasks.data.filter(
|
2020-12-09 22:56:44 +08:00
|
|
|
(task) => task.key !== action.taskKey
|
|
|
|
),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ARCHIVED_TASK_ERROR:
|
|
|
|
case DELETE_ARCHIVED_TASK_ERROR:
|
2020-12-09 22:56:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
|
|
|
data: state.archivedTasks.data.map((task) => {
|
2020-12-09 22:56:44 +08:00
|
|
|
if (task.key !== action.taskKey) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return { ...task, requestPending: false };
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ALL_ARCHIVED_TASKS_BEGIN:
|
|
|
|
case DELETE_ALL_ARCHIVED_TASKS_BEGIN:
|
2020-12-16 22:55:51 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-17 22:57:30 +08:00
|
|
|
allActionPending: true,
|
2020-12-16 22:55:51 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ALL_ARCHIVED_TASKS_SUCCESS:
|
|
|
|
case DELETE_ALL_ARCHIVED_TASKS_SUCCESS:
|
2020-12-16 22:55:51 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-17 22:57:30 +08:00
|
|
|
allActionPending: false,
|
2020-12-16 22:55:51 +08:00
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case RUN_ALL_ARCHIVED_TASKS_ERROR:
|
|
|
|
case DELETE_ALL_ARCHIVED_TASKS_ERROR:
|
2020-12-16 22:55:51 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-17 22:57:30 +08:00
|
|
|
allActionPending: false,
|
2020-12-16 22:55:51 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_RUN_ARCHIVED_TASKS_BEGIN:
|
|
|
|
case BATCH_DELETE_ARCHIVED_TASKS_BEGIN:
|
2020-12-13 23:51:40 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-13 23:51:40 +08:00
|
|
|
batchActionPending: true,
|
2021-01-13 03:59:44 +08:00
|
|
|
data: state.archivedTasks.data.map((task) => {
|
2020-12-16 23:04:22 +08:00
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: true,
|
|
|
|
};
|
|
|
|
}),
|
2020-12-13 23:51:40 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_RUN_ARCHIVED_TASKS_SUCCESS: {
|
|
|
|
const newData = state.archivedTasks.data.filter(
|
2020-12-15 22:46:23 +08:00
|
|
|
(task) => !action.payload.pending_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-15 22:46:23 +08:00
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_DELETE_ARCHIVED_TASKS_SUCCESS: {
|
|
|
|
const newData = state.archivedTasks.data.filter(
|
2020-12-13 23:51:40 +08:00
|
|
|
(task) => !action.payload.deleted_keys.includes(task.key)
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-13 23:51:40 +08:00
|
|
|
batchActionPending: false,
|
|
|
|
data: newData,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-13 03:59:44 +08:00
|
|
|
case BATCH_RUN_ARCHIVED_TASKS_ERROR:
|
|
|
|
case BATCH_DELETE_ARCHIVED_TASKS_ERROR:
|
2020-12-13 23:51:40 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-01-13 03:59:44 +08:00
|
|
|
archivedTasks: {
|
|
|
|
...state.archivedTasks,
|
2020-12-13 23:51:40 +08:00
|
|
|
batchActionPending: false,
|
2021-01-13 03:59:44 +08:00
|
|
|
data: state.archivedTasks.data.map((task) => {
|
2020-12-16 23:04:22 +08:00
|
|
|
if (!action.taskKeys.includes(task.key)) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...task,
|
|
|
|
requestPending: false,
|
|
|
|
};
|
|
|
|
}),
|
2020-12-13 23:51:40 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-24 22:54:00 +08:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default tasksReducer;
|