mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-08 05:02:01 +08:00
(ui): Add redux action/reducer for aggregating tasks
This commit is contained in:
@@ -129,6 +129,9 @@ import {
|
||||
BATCH_DELETE_COMPLETED_TASKS_BEGIN,
|
||||
BATCH_DELETE_COMPLETED_TASKS_ERROR,
|
||||
BATCH_DELETE_COMPLETED_TASKS_SUCCESS,
|
||||
LIST_AGGREGATING_TASKS_BEGIN,
|
||||
LIST_AGGREGATING_TASKS_SUCCESS,
|
||||
LIST_AGGREGATING_TASKS_ERROR,
|
||||
} from "../actions/tasksActions";
|
||||
import { TaskInfo } from "../api";
|
||||
|
||||
@@ -191,6 +194,13 @@ interface TasksState {
|
||||
error: string;
|
||||
data: TaskInfoExtended[];
|
||||
};
|
||||
aggregatingTasks: {
|
||||
loading: boolean;
|
||||
batchActionPending: boolean;
|
||||
allActionPending: boolean;
|
||||
error: string;
|
||||
data: TaskInfoExtended[];
|
||||
};
|
||||
taskInfo: {
|
||||
loading: boolean;
|
||||
error: string;
|
||||
@@ -241,6 +251,13 @@ const initialState: TasksState = {
|
||||
error: "",
|
||||
data: [],
|
||||
},
|
||||
aggregatingTasks: {
|
||||
loading: false,
|
||||
batchActionPending: false,
|
||||
allActionPending: false,
|
||||
error: "",
|
||||
data: [],
|
||||
},
|
||||
taskInfo: {
|
||||
loading: false,
|
||||
error: "",
|
||||
@@ -485,6 +502,40 @@ function tasksReducer(
|
||||
},
|
||||
};
|
||||
|
||||
case LIST_AGGREGATING_TASKS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
aggregatingTasks: {
|
||||
...state.aggregatingTasks,
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
|
||||
case LIST_AGGREGATING_TASKS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
aggregatingTasks: {
|
||||
...state.aggregatingTasks,
|
||||
loading: false,
|
||||
error: "",
|
||||
data: action.payload.tasks.map((task) => ({
|
||||
...task,
|
||||
requestPending: false,
|
||||
})),
|
||||
},
|
||||
};
|
||||
|
||||
case LIST_AGGREGATING_TASKS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
aggregatingTasks: {
|
||||
...state.aggregatingTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
case DELETE_COMPLETED_TASK_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
|
Reference in New Issue
Block a user