mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-31 17:10:11 +08:00
(ui): Make list tasks action generic
This commit is contained in:
parent
ea78dacaf6
commit
c98cc411b7
@ -68,27 +68,6 @@ import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
|||||||
export const GET_TASK_INFO_BEGIN = "GET_TASK_INFO_BEGIN";
|
export const GET_TASK_INFO_BEGIN = "GET_TASK_INFO_BEGIN";
|
||||||
export const GET_TASK_INFO_SUCCESS = "GET_TASK_INFO_SUCCESS";
|
export const GET_TASK_INFO_SUCCESS = "GET_TASK_INFO_SUCCESS";
|
||||||
export const GET_TASK_INFO_ERROR = "GET_TASK_INFO_ERROR";
|
export const GET_TASK_INFO_ERROR = "GET_TASK_INFO_ERROR";
|
||||||
export const LIST_ACTIVE_TASKS_BEGIN = "LIST_ACTIVE_TASKS_BEGIN";
|
|
||||||
export const LIST_ACTIVE_TASKS_SUCCESS = "LIST_ACTIVE_TASKS_SUCCESS";
|
|
||||||
export const LIST_ACTIVE_TASKS_ERROR = "LIST_ACTIVE_TASKS_ERROR";
|
|
||||||
export const LIST_PENDING_TASKS_BEGIN = "LIST_PENDING_TASKS_BEGIN";
|
|
||||||
export const LIST_PENDING_TASKS_SUCCESS = "LIST_PENDING_TASKS_SUCCESS";
|
|
||||||
export const LIST_PENDING_TASKS_ERROR = "LIST_PENDING_TASKS_ERROR";
|
|
||||||
export const LIST_SCHEDULED_TASKS_BEGIN = "LIST_SCHEDULED_TASKS_BEGIN";
|
|
||||||
export const LIST_SCHEDULED_TASKS_SUCCESS = "LIST_SCHEDULED_TASKS_SUCCESS";
|
|
||||||
export const LIST_SCHEDULED_TASKS_ERROR = "LIST_SCHEDULED_TASKS_ERROR";
|
|
||||||
export const LIST_RETRY_TASKS_BEGIN = "LIST_RETRY_TASKS_BEGIN";
|
|
||||||
export const LIST_RETRY_TASKS_SUCCESS = "LIST_RETRY_TASKS_SUCCESS";
|
|
||||||
export const LIST_RETRY_TASKS_ERROR = "LIST_RETRY_TASKS_ERROR";
|
|
||||||
export const LIST_ARCHIVED_TASKS_BEGIN = "LIST_ARCHIVED_TASKS_BEGIN";
|
|
||||||
export const LIST_ARCHIVED_TASKS_SUCCESS = "LIST_ARCHIVED_TASKS_SUCCESS";
|
|
||||||
export const LIST_ARCHIVED_TASKS_ERROR = "LIST_ARCHIVED_TASKS_ERROR";
|
|
||||||
export const LIST_COMPLETED_TASKS_BEGIN = "LIST_COMPLETED_TASKS_BEGIN";
|
|
||||||
export const LIST_COMPLETED_TASKS_SUCCESS = "LIST_COMPLETED_TASKS_SUCCESS";
|
|
||||||
export const LIST_COMPLETED_TASKS_ERROR = "LIST_COMPLETED_TASKS_ERROR";
|
|
||||||
export const LIST_AGGREGATING_TASKS_BEGIN = "LIST_AGGREGATING_TASKS_BEGIN";
|
|
||||||
export const LIST_AGGREGATING_TASKS_SUCCESS = "LIST_AGGREGATING_TASKS_SUCCESS";
|
|
||||||
export const LIST_AGGREGATING_TASKS_ERROR = "LIST_AGGREGATING_TASKS_ERROR";
|
|
||||||
export const CANCEL_ACTIVE_TASK_BEGIN = "CANCEL_ACTIVE_TASK_BEGIN";
|
export const CANCEL_ACTIVE_TASK_BEGIN = "CANCEL_ACTIVE_TASK_BEGIN";
|
||||||
export const CANCEL_ACTIVE_TASK_SUCCESS = "CANCEL_ACTIVE_TASK_SUCCESS";
|
export const CANCEL_ACTIVE_TASK_SUCCESS = "CANCEL_ACTIVE_TASK_SUCCESS";
|
||||||
export const CANCEL_ACTIVE_TASK_ERROR = "CANCEL_ACTIVE_TASK_ERROR";
|
export const CANCEL_ACTIVE_TASK_ERROR = "CANCEL_ACTIVE_TASK_ERROR";
|
||||||
@ -293,6 +272,10 @@ export const DELETE_ALL_AGGREGATING_TASKS_SUCCESS =
|
|||||||
export const DELETE_ALL_AGGREGATING_TASKS_ERROR =
|
export const DELETE_ALL_AGGREGATING_TASKS_ERROR =
|
||||||
"DELETE_ALL_AGGREGATING_TASKS_ERROR";
|
"DELETE_ALL_AGGREGATING_TASKS_ERROR";
|
||||||
|
|
||||||
|
export const LIST_TASKS_BEGIN = "LIST_TASKS_BEGIN";
|
||||||
|
export const LIST_TASKS_ERROR = "LIST_TASKS_ERROR";
|
||||||
|
export const LIST_TASKS_SUCCESS = "LIST_TASKS_SUCCESS";
|
||||||
|
|
||||||
interface GetTaskInfoBeginAction {
|
interface GetTaskInfoBeginAction {
|
||||||
type: typeof GET_TASK_INFO_BEGIN;
|
type: typeof GET_TASK_INFO_BEGIN;
|
||||||
}
|
}
|
||||||
@ -307,126 +290,50 @@ interface GetTaskInfoSuccessAction {
|
|||||||
payload: TaskInfo;
|
payload: TaskInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListActiveTasksBeginAction {
|
type TaskState =
|
||||||
type: typeof LIST_ACTIVE_TASKS_BEGIN;
|
| "active"
|
||||||
|
| "pending"
|
||||||
|
| "aggregating"
|
||||||
|
| "scheduled"
|
||||||
|
| "retry"
|
||||||
|
| "archived"
|
||||||
|
| "completed";
|
||||||
|
|
||||||
|
interface ListTasksBeginAction {
|
||||||
|
type: typeof LIST_TASKS_BEGIN;
|
||||||
|
taskState: TaskState;
|
||||||
queue: string;
|
queue: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListActiveTasksSuccessAction {
|
interface ListTasksErrorAction {
|
||||||
type: typeof LIST_ACTIVE_TASKS_SUCCESS;
|
type: typeof LIST_TASKS_ERROR;
|
||||||
queue: string;
|
taskState: TaskState;
|
||||||
payload: ListTasksResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListActiveTasksErrorAction {
|
|
||||||
type: typeof LIST_ACTIVE_TASKS_ERROR;
|
|
||||||
queue: string;
|
queue: string;
|
||||||
error: string; // error description
|
error: string; // error description
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListPendingTasksBeginAction {
|
interface ListTasksSuccessAction {
|
||||||
type: typeof LIST_PENDING_TASKS_BEGIN;
|
type: typeof LIST_TASKS_SUCCESS;
|
||||||
queue: string;
|
taskState: TaskState;
|
||||||
}
|
|
||||||
|
|
||||||
interface ListPendingTasksSuccessAction {
|
|
||||||
type: typeof LIST_PENDING_TASKS_SUCCESS;
|
|
||||||
queue: string;
|
queue: string;
|
||||||
payload: ListTasksResponse;
|
payload: ListTasksResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListPendingTasksErrorAction {
|
export interface ListAggregatingTasksBeginAction extends ListTasksBeginAction {
|
||||||
type: typeof LIST_PENDING_TASKS_ERROR;
|
taskState: "aggregating";
|
||||||
queue: string;
|
|
||||||
error: string; // error description
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListScheduledTasksBeginAction {
|
|
||||||
type: typeof LIST_SCHEDULED_TASKS_BEGIN;
|
|
||||||
queue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListScheduledTasksSuccessAction {
|
|
||||||
type: typeof LIST_SCHEDULED_TASKS_SUCCESS;
|
|
||||||
queue: string;
|
|
||||||
payload: ListTasksResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListScheduledTasksErrorAction {
|
|
||||||
type: typeof LIST_SCHEDULED_TASKS_ERROR;
|
|
||||||
queue: string;
|
|
||||||
error: string; // error description
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListRetryTasksBeginAction {
|
|
||||||
type: typeof LIST_RETRY_TASKS_BEGIN;
|
|
||||||
queue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListRetryTasksSuccessAction {
|
|
||||||
type: typeof LIST_RETRY_TASKS_SUCCESS;
|
|
||||||
queue: string;
|
|
||||||
payload: ListTasksResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListRetryTasksErrorAction {
|
|
||||||
type: typeof LIST_RETRY_TASKS_ERROR;
|
|
||||||
queue: string;
|
|
||||||
error: string; // error description
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListArchivedTasksBeginAction {
|
|
||||||
type: typeof LIST_ARCHIVED_TASKS_BEGIN;
|
|
||||||
queue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListArchivedTasksSuccessAction {
|
|
||||||
type: typeof LIST_ARCHIVED_TASKS_SUCCESS;
|
|
||||||
queue: string;
|
|
||||||
payload: ListTasksResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListArchivedTasksErrorAction {
|
|
||||||
type: typeof LIST_ARCHIVED_TASKS_ERROR;
|
|
||||||
queue: string;
|
|
||||||
error: string; // error description
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListCompletedTasksBeginAction {
|
|
||||||
type: typeof LIST_COMPLETED_TASKS_BEGIN;
|
|
||||||
queue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListCompletedTasksSuccessAction {
|
|
||||||
type: typeof LIST_COMPLETED_TASKS_SUCCESS;
|
|
||||||
queue: string;
|
|
||||||
payload: ListTasksResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListCompletedTasksErrorAction {
|
|
||||||
type: typeof LIST_COMPLETED_TASKS_ERROR;
|
|
||||||
queue: string;
|
|
||||||
error: string; // error description
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ListAggregatingTasksBeginAction {
|
|
||||||
type: typeof LIST_AGGREGATING_TASKS_BEGIN;
|
|
||||||
queue: string;
|
|
||||||
group: string;
|
group: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListAggregatingTasksSuccessAction {
|
export interface ListAggregatingTasksSuccessAction
|
||||||
type: typeof LIST_AGGREGATING_TASKS_SUCCESS;
|
extends ListTasksSuccessAction {
|
||||||
queue: string;
|
taskState: "aggregating";
|
||||||
group: string;
|
group: string;
|
||||||
payload: ListAggregatingTasksResponse;
|
payload: ListAggregatingTasksResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListAggregatingTasksErrorAction {
|
export interface ListAggregatingTasksErrorAction extends ListTasksErrorAction {
|
||||||
type: typeof LIST_AGGREGATING_TASKS_ERROR;
|
taskState: "aggregating";
|
||||||
queue: string;
|
|
||||||
group: string;
|
group: string;
|
||||||
error: string; // error description
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CancelActiveTaskBeginAction {
|
interface CancelActiveTaskBeginAction {
|
||||||
@ -1270,24 +1177,9 @@ export type TasksActionTypes =
|
|||||||
| GetTaskInfoBeginAction
|
| GetTaskInfoBeginAction
|
||||||
| GetTaskInfoErrorAction
|
| GetTaskInfoErrorAction
|
||||||
| GetTaskInfoSuccessAction
|
| GetTaskInfoSuccessAction
|
||||||
| ListActiveTasksBeginAction
|
| ListTasksBeginAction
|
||||||
| ListActiveTasksSuccessAction
|
| ListTasksErrorAction
|
||||||
| ListActiveTasksErrorAction
|
| ListTasksSuccessAction
|
||||||
| ListPendingTasksBeginAction
|
|
||||||
| ListPendingTasksSuccessAction
|
|
||||||
| ListPendingTasksErrorAction
|
|
||||||
| ListScheduledTasksBeginAction
|
|
||||||
| ListScheduledTasksSuccessAction
|
|
||||||
| ListScheduledTasksErrorAction
|
|
||||||
| ListRetryTasksBeginAction
|
|
||||||
| ListRetryTasksSuccessAction
|
|
||||||
| ListRetryTasksErrorAction
|
|
||||||
| ListArchivedTasksBeginAction
|
|
||||||
| ListArchivedTasksSuccessAction
|
|
||||||
| ListArchivedTasksErrorAction
|
|
||||||
| ListCompletedTasksBeginAction
|
|
||||||
| ListCompletedTasksSuccessAction
|
|
||||||
| ListCompletedTasksErrorAction
|
|
||||||
| ListAggregatingTasksBeginAction
|
| ListAggregatingTasksBeginAction
|
||||||
| ListAggregatingTasksSuccessAction
|
| ListAggregatingTasksSuccessAction
|
||||||
| ListAggregatingTasksErrorAction
|
| ListAggregatingTasksErrorAction
|
||||||
@ -1451,11 +1343,12 @@ export function listActiveTasksAsync(
|
|||||||
pageOpts?: PaginationOptions
|
pageOpts?: PaginationOptions
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
dispatch({ type: LIST_ACTIVE_TASKS_BEGIN, queue: qname });
|
dispatch({ type: LIST_TASKS_BEGIN, taskState: "active", queue: qname });
|
||||||
try {
|
try {
|
||||||
const response = await listActiveTasks(qname, pageOpts);
|
const response = await listActiveTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_ACTIVE_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "active",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1465,7 +1358,8 @@ export function listActiveTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_ACTIVE_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "active",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1478,11 +1372,12 @@ export function listPendingTasksAsync(
|
|||||||
pageOpts?: PaginationOptions
|
pageOpts?: PaginationOptions
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
dispatch({ type: LIST_PENDING_TASKS_BEGIN, queue: qname });
|
dispatch({ type: LIST_TASKS_BEGIN, taskState: "pending", queue: qname });
|
||||||
try {
|
try {
|
||||||
const response = await listPendingTasks(qname, pageOpts);
|
const response = await listPendingTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_PENDING_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "pending",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1492,7 +1387,8 @@ export function listPendingTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_PENDING_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "pending",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1505,11 +1401,12 @@ export function listScheduledTasksAsync(
|
|||||||
pageOpts?: PaginationOptions
|
pageOpts?: PaginationOptions
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
dispatch({ type: LIST_SCHEDULED_TASKS_BEGIN, queue: qname });
|
dispatch({ type: LIST_TASKS_BEGIN, taskState: "scheduled", queue: qname });
|
||||||
try {
|
try {
|
||||||
const response = await listScheduledTasks(qname, pageOpts);
|
const response = await listScheduledTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_SCHEDULED_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "scheduled",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1519,7 +1416,8 @@ export function listScheduledTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_SCHEDULED_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "scheduled",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1532,11 +1430,12 @@ export function listRetryTasksAsync(
|
|||||||
pageOpts?: PaginationOptions
|
pageOpts?: PaginationOptions
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
dispatch({ type: LIST_RETRY_TASKS_BEGIN, queue: qname });
|
dispatch({ type: LIST_TASKS_BEGIN, taskState: "retry", queue: qname });
|
||||||
try {
|
try {
|
||||||
const response = await listRetryTasks(qname, pageOpts);
|
const response = await listRetryTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_RETRY_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "retry",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1546,7 +1445,8 @@ export function listRetryTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_RETRY_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "retry",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1559,11 +1459,12 @@ export function listArchivedTasksAsync(
|
|||||||
pageOpts?: PaginationOptions
|
pageOpts?: PaginationOptions
|
||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
dispatch({ type: LIST_ARCHIVED_TASKS_BEGIN, queue: qname });
|
dispatch({ type: LIST_TASKS_BEGIN, taskState: "archived", queue: qname });
|
||||||
try {
|
try {
|
||||||
const response = await listArchivedTasks(qname, pageOpts);
|
const response = await listArchivedTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_ARCHIVED_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "archived",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1573,7 +1474,8 @@ export function listArchivedTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_ARCHIVED_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "archived",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1587,10 +1489,15 @@ export function listCompletedTasksAsync(
|
|||||||
) {
|
) {
|
||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
try {
|
try {
|
||||||
dispatch({ type: LIST_COMPLETED_TASKS_BEGIN, queue: qname });
|
dispatch({
|
||||||
|
type: LIST_TASKS_BEGIN,
|
||||||
|
taskState: "completed",
|
||||||
|
queue: qname,
|
||||||
|
});
|
||||||
const response = await listCompletedTasks(qname, pageOpts);
|
const response = await listCompletedTasks(qname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_COMPLETED_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "completed",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
@ -1600,7 +1507,8 @@ export function listCompletedTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_COMPLETED_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "completed",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
});
|
});
|
||||||
@ -1616,13 +1524,15 @@ export function listAggregatingTasksAsync(
|
|||||||
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
return async (dispatch: Dispatch<TasksActionTypes>) => {
|
||||||
try {
|
try {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_AGGREGATING_TASKS_BEGIN,
|
type: LIST_TASKS_BEGIN,
|
||||||
|
taskState: "aggregating",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
group: gname,
|
group: gname,
|
||||||
});
|
});
|
||||||
const response = await listAggregatingTasks(qname, gname, pageOpts);
|
const response = await listAggregatingTasks(qname, gname, pageOpts);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_AGGREGATING_TASKS_SUCCESS,
|
type: LIST_TASKS_SUCCESS,
|
||||||
|
taskState: "aggregating",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
group: gname,
|
group: gname,
|
||||||
payload: response,
|
payload: response,
|
||||||
@ -1633,7 +1543,8 @@ export function listAggregatingTasksAsync(
|
|||||||
toErrorStringWithHttpStatus(error)
|
toErrorStringWithHttpStatus(error)
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: LIST_AGGREGATING_TASKS_ERROR,
|
type: LIST_TASKS_ERROR,
|
||||||
|
taskState: "aggregating",
|
||||||
queue: qname,
|
queue: qname,
|
||||||
group: gname,
|
group: gname,
|
||||||
error: toErrorString(error),
|
error: toErrorString(error),
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
LIST_GROUPS_SUCCESS,
|
LIST_GROUPS_SUCCESS,
|
||||||
} from "../actions/groupsActions";
|
} from "../actions/groupsActions";
|
||||||
import {
|
import {
|
||||||
LIST_AGGREGATING_TASKS_SUCCESS,
|
ListAggregatingTasksSuccessAction,
|
||||||
|
LIST_TASKS_SUCCESS,
|
||||||
TasksActionTypes,
|
TasksActionTypes,
|
||||||
} from "../actions/tasksActions";
|
} from "../actions/tasksActions";
|
||||||
import { GroupInfo } from "../api";
|
import { GroupInfo } from "../api";
|
||||||
@ -41,10 +42,12 @@ function groupsReducer(
|
|||||||
data: action.payload.groups,
|
data: action.payload.groups,
|
||||||
};
|
};
|
||||||
|
|
||||||
case LIST_AGGREGATING_TASKS_SUCCESS:
|
case LIST_TASKS_SUCCESS:
|
||||||
|
if (action.taskState !== "aggregating") return state;
|
||||||
|
let act = action as ListAggregatingTasksSuccessAction;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: action.payload.groups,
|
data: act.payload.groups,
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -36,11 +36,6 @@ import {
|
|||||||
ARCHIVE_ALL_SCHEDULED_TASKS_SUCCESS,
|
ARCHIVE_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||||
ARCHIVE_RETRY_TASK_SUCCESS,
|
ARCHIVE_RETRY_TASK_SUCCESS,
|
||||||
ARCHIVE_SCHEDULED_TASK_SUCCESS,
|
ARCHIVE_SCHEDULED_TASK_SUCCESS,
|
||||||
LIST_ACTIVE_TASKS_SUCCESS,
|
|
||||||
LIST_ARCHIVED_TASKS_SUCCESS,
|
|
||||||
LIST_PENDING_TASKS_SUCCESS,
|
|
||||||
LIST_RETRY_TASKS_SUCCESS,
|
|
||||||
LIST_SCHEDULED_TASKS_SUCCESS,
|
|
||||||
RUN_ALL_ARCHIVED_TASKS_SUCCESS,
|
RUN_ALL_ARCHIVED_TASKS_SUCCESS,
|
||||||
RUN_ALL_RETRY_TASKS_SUCCESS,
|
RUN_ALL_RETRY_TASKS_SUCCESS,
|
||||||
RUN_ALL_SCHEDULED_TASKS_SUCCESS,
|
RUN_ALL_SCHEDULED_TASKS_SUCCESS,
|
||||||
@ -66,7 +61,7 @@ import {
|
|||||||
DELETE_AGGREGATING_TASK_SUCCESS,
|
DELETE_AGGREGATING_TASK_SUCCESS,
|
||||||
RUN_AGGREGATING_TASK_SUCCESS,
|
RUN_AGGREGATING_TASK_SUCCESS,
|
||||||
ARCHIVE_AGGREGATING_TASK_SUCCESS,
|
ARCHIVE_AGGREGATING_TASK_SUCCESS,
|
||||||
LIST_AGGREGATING_TASKS_SUCCESS,
|
LIST_TASKS_SUCCESS,
|
||||||
} from "../actions/tasksActions";
|
} from "../actions/tasksActions";
|
||||||
import { Queue } from "../api";
|
import { Queue } from "../api";
|
||||||
|
|
||||||
@ -174,12 +169,7 @@ function queuesReducer(
|
|||||||
return { ...state, data: newData };
|
return { ...state, data: newData };
|
||||||
}
|
}
|
||||||
|
|
||||||
case LIST_ACTIVE_TASKS_SUCCESS:
|
case LIST_TASKS_SUCCESS: {
|
||||||
case LIST_PENDING_TASKS_SUCCESS:
|
|
||||||
case LIST_AGGREGATING_TASKS_SUCCESS:
|
|
||||||
case LIST_SCHEDULED_TASKS_SUCCESS:
|
|
||||||
case LIST_RETRY_TASKS_SUCCESS:
|
|
||||||
case LIST_ARCHIVED_TASKS_SUCCESS: {
|
|
||||||
const newData = state.data
|
const newData = state.data
|
||||||
.filter((queueInfo) => queueInfo.name !== action.queue)
|
.filter((queueInfo) => queueInfo.name !== action.queue)
|
||||||
.concat({
|
.concat({
|
||||||
|
@ -1,23 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
LIST_ACTIVE_TASKS_BEGIN,
|
|
||||||
LIST_ACTIVE_TASKS_SUCCESS,
|
|
||||||
LIST_ACTIVE_TASKS_ERROR,
|
|
||||||
TasksActionTypes,
|
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,
|
|
||||||
LIST_ARCHIVED_TASKS_BEGIN,
|
|
||||||
LIST_ARCHIVED_TASKS_SUCCESS,
|
|
||||||
LIST_ARCHIVED_TASKS_ERROR,
|
|
||||||
LIST_COMPLETED_TASKS_BEGIN,
|
|
||||||
LIST_COMPLETED_TASKS_SUCCESS,
|
|
||||||
LIST_COMPLETED_TASKS_ERROR,
|
|
||||||
CANCEL_ACTIVE_TASK_BEGIN,
|
CANCEL_ACTIVE_TASK_BEGIN,
|
||||||
CANCEL_ACTIVE_TASK_SUCCESS,
|
CANCEL_ACTIVE_TASK_SUCCESS,
|
||||||
CANCEL_ACTIVE_TASK_ERROR,
|
CANCEL_ACTIVE_TASK_ERROR,
|
||||||
@ -129,9 +111,6 @@ import {
|
|||||||
BATCH_DELETE_COMPLETED_TASKS_BEGIN,
|
BATCH_DELETE_COMPLETED_TASKS_BEGIN,
|
||||||
BATCH_DELETE_COMPLETED_TASKS_ERROR,
|
BATCH_DELETE_COMPLETED_TASKS_ERROR,
|
||||||
BATCH_DELETE_COMPLETED_TASKS_SUCCESS,
|
BATCH_DELETE_COMPLETED_TASKS_SUCCESS,
|
||||||
LIST_AGGREGATING_TASKS_BEGIN,
|
|
||||||
LIST_AGGREGATING_TASKS_SUCCESS,
|
|
||||||
LIST_AGGREGATING_TASKS_ERROR,
|
|
||||||
DELETE_ALL_AGGREGATING_TASKS_BEGIN,
|
DELETE_ALL_AGGREGATING_TASKS_BEGIN,
|
||||||
DELETE_ALL_AGGREGATING_TASKS_SUCCESS,
|
DELETE_ALL_AGGREGATING_TASKS_SUCCESS,
|
||||||
DELETE_ALL_AGGREGATING_TASKS_ERROR,
|
DELETE_ALL_AGGREGATING_TASKS_ERROR,
|
||||||
@ -159,6 +138,12 @@ import {
|
|||||||
RUN_AGGREGATING_TASK_SUCCESS,
|
RUN_AGGREGATING_TASK_SUCCESS,
|
||||||
ARCHIVE_AGGREGATING_TASK_SUCCESS,
|
ARCHIVE_AGGREGATING_TASK_SUCCESS,
|
||||||
DELETE_AGGREGATING_TASK_SUCCESS,
|
DELETE_AGGREGATING_TASK_SUCCESS,
|
||||||
|
LIST_TASKS_BEGIN,
|
||||||
|
LIST_TASKS_SUCCESS,
|
||||||
|
LIST_TASKS_ERROR,
|
||||||
|
ListAggregatingTasksBeginAction,
|
||||||
|
ListAggregatingTasksErrorAction,
|
||||||
|
ListAggregatingTasksSuccessAction,
|
||||||
} from "../actions/tasksActions";
|
} from "../actions/tasksActions";
|
||||||
import { TaskInfo } from "../api";
|
import { TaskInfo } from "../api";
|
||||||
|
|
||||||
@ -326,7 +311,9 @@ function tasksReducer(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
case LIST_ACTIVE_TASKS_BEGIN:
|
case LIST_TASKS_BEGIN:
|
||||||
|
switch (action.taskState) {
|
||||||
|
case "active":
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
activeTasks: {
|
activeTasks: {
|
||||||
@ -334,8 +321,142 @@ function tasksReducer(
|
|||||||
loading: true,
|
loading: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "pending":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
pendingTasks: {
|
||||||
|
...state.pendingTasks,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "aggregating": {
|
||||||
|
let act = action as ListAggregatingTasksBeginAction;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
aggregatingTasks: {
|
||||||
|
...state.aggregatingTasks,
|
||||||
|
group: act.group,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case "scheduled":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
scheduledTasks: {
|
||||||
|
...state.scheduledTasks,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "retry":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
retryTasks: {
|
||||||
|
...state.retryTasks,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "archived":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
archivedTasks: {
|
||||||
|
...state.archivedTasks,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "completed":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
completedTasks: {
|
||||||
|
...state.completedTasks,
|
||||||
|
loading: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
case LIST_ACTIVE_TASKS_SUCCESS:
|
case LIST_TASKS_ERROR:
|
||||||
|
switch (action.taskState) {
|
||||||
|
case "active":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
activeTasks: {
|
||||||
|
...state.activeTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "pending":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
pendingTasks: {
|
||||||
|
...state.pendingTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "aggregating":
|
||||||
|
let act = action as ListAggregatingTasksErrorAction;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
aggregatingTasks: {
|
||||||
|
...state.aggregatingTasks,
|
||||||
|
group: act.group,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "scheduled":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
scheduledTasks: {
|
||||||
|
...state.scheduledTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "retry":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
retryTasks: {
|
||||||
|
...state.retryTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "archived":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
archivedTasks: {
|
||||||
|
...state.archivedTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case "completed":
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
completedTasks: {
|
||||||
|
...state.completedTasks,
|
||||||
|
loading: false,
|
||||||
|
error: action.error,
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LIST_TASKS_SUCCESS:
|
||||||
|
switch (action.taskState) {
|
||||||
|
case "active":
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
activeTasks: {
|
activeTasks: {
|
||||||
@ -349,28 +470,7 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "pending":
|
||||||
case LIST_ACTIVE_TASKS_ERROR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
activeTasks: {
|
|
||||||
...state.activeTasks,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_PENDING_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
pendingTasks: {
|
|
||||||
...state.pendingTasks,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_PENDING_TASKS_SUCCESS:
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
pendingTasks: {
|
pendingTasks: {
|
||||||
@ -383,28 +483,22 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "aggregating":
|
||||||
case LIST_PENDING_TASKS_ERROR:
|
let act = action as ListAggregatingTasksSuccessAction;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
pendingTasks: {
|
aggregatingTasks: {
|
||||||
...state.pendingTasks,
|
...state.aggregatingTasks,
|
||||||
|
group: act.group,
|
||||||
loading: false,
|
loading: false,
|
||||||
error: action.error,
|
error: "",
|
||||||
data: [],
|
data: action.payload.tasks.map((task) => ({
|
||||||
|
...task,
|
||||||
|
requestPending: false,
|
||||||
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "scheduled":
|
||||||
case LIST_SCHEDULED_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
scheduledTasks: {
|
|
||||||
...state.scheduledTasks,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_SCHEDULED_TASKS_SUCCESS:
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
scheduledTasks: {
|
scheduledTasks: {
|
||||||
@ -417,28 +511,7 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "retry":
|
||||||
case LIST_SCHEDULED_TASKS_ERROR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
scheduledTasks: {
|
|
||||||
...state.scheduledTasks,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_RETRY_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
retryTasks: {
|
|
||||||
...state.retryTasks,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_RETRY_TASKS_SUCCESS:
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
retryTasks: {
|
retryTasks: {
|
||||||
@ -451,28 +524,7 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "archived":
|
||||||
case LIST_RETRY_TASKS_ERROR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
retryTasks: {
|
|
||||||
...state.retryTasks,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_ARCHIVED_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
archivedTasks: {
|
|
||||||
...state.archivedTasks,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_ARCHIVED_TASKS_SUCCESS:
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
archivedTasks: {
|
archivedTasks: {
|
||||||
@ -485,28 +537,7 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
case "completed":
|
||||||
case LIST_ARCHIVED_TASKS_ERROR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
archivedTasks: {
|
|
||||||
...state.archivedTasks,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_COMPLETED_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
completedTasks: {
|
|
||||||
...state.completedTasks,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_COMPLETED_TASKS_SUCCESS:
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
completedTasks: {
|
completedTasks: {
|
||||||
@ -519,54 +550,9 @@ function tasksReducer(
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
default:
|
||||||
case LIST_COMPLETED_TASKS_ERROR:
|
return state;
|
||||||
return {
|
}
|
||||||
...state,
|
|
||||||
completedTasks: {
|
|
||||||
...state.completedTasks,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_AGGREGATING_TASKS_BEGIN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
aggregatingTasks: {
|
|
||||||
...state.aggregatingTasks,
|
|
||||||
group: action.group,
|
|
||||||
loading: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_AGGREGATING_TASKS_SUCCESS:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
aggregatingTasks: {
|
|
||||||
...state.aggregatingTasks,
|
|
||||||
group: action.group,
|
|
||||||
loading: false,
|
|
||||||
error: "",
|
|
||||||
data: action.payload.tasks.map((task) => ({
|
|
||||||
...task,
|
|
||||||
requestPending: false,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case LIST_AGGREGATING_TASKS_ERROR:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
aggregatingTasks: {
|
|
||||||
...state.aggregatingTasks,
|
|
||||||
group: action.group,
|
|
||||||
loading: false,
|
|
||||||
error: action.error,
|
|
||||||
data: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
case DELETE_COMPLETED_TASK_BEGIN:
|
case DELETE_COMPLETED_TASK_BEGIN:
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user