mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
refactor(plugin-workflow): change tasks api (#6640)
* refactor(plugin-workflow): change tasks api * refactor(plugin-workflow): change task center popup logic * refactor(preset): remove some builtin plugins
This commit is contained in:
parent
75c8265392
commit
23d7e09fa5
@ -72,7 +72,7 @@ const InternalActionBar: FC = (props: any) => {
|
|||||||
<Portal>
|
<Portal>
|
||||||
<DndContext>
|
<DndContext>
|
||||||
<div
|
<div
|
||||||
style={{ display: 'flex', alignItems: 'center', gap: 8, ...style, marginTop: 0 }}
|
style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 0, ...style }}
|
||||||
{...others}
|
{...others}
|
||||||
className={cx(others.className, 'nb-action-bar')}
|
className={cx(others.className, 'nb-action-bar')}
|
||||||
>
|
>
|
||||||
|
@ -158,7 +158,7 @@ const InternalList = withSkeletonComponent(
|
|||||||
>
|
>
|
||||||
<AntdList
|
<AntdList
|
||||||
{...props}
|
{...props}
|
||||||
pagination={!meta || !field.value?.length ? false : paginationProps}
|
pagination={!meta || !field.value?.length || count <= field.value?.length ? false : paginationProps}
|
||||||
loading={service?.loading}
|
loading={service?.loading}
|
||||||
>
|
>
|
||||||
{field.value?.length
|
{field.value?.length
|
||||||
|
@ -8,3 +8,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './List';
|
export * from './List';
|
||||||
|
export { useListBlockContext } from './List.Decorator';
|
||||||
|
@ -33,9 +33,12 @@ import {
|
|||||||
useActionContext,
|
useActionContext,
|
||||||
useCurrentUserContext,
|
useCurrentUserContext,
|
||||||
useFormBlockContext,
|
useFormBlockContext,
|
||||||
useTableBlockContext,
|
useListBlockContext,
|
||||||
List,
|
List,
|
||||||
OpenModeProvider,
|
OpenModeProvider,
|
||||||
|
ActionContextProvider,
|
||||||
|
useRequest,
|
||||||
|
CollectionRecordProvider,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import WorkflowPlugin, {
|
import WorkflowPlugin, {
|
||||||
DetailsBlockProvider,
|
DetailsBlockProvider,
|
||||||
@ -46,12 +49,15 @@ import WorkflowPlugin, {
|
|||||||
EXECUTION_STATUS,
|
EXECUTION_STATUS,
|
||||||
JOB_STATUS,
|
JOB_STATUS,
|
||||||
WorkflowTitle,
|
WorkflowTitle,
|
||||||
|
TASK_STATUS,
|
||||||
|
usePopupRecordContext,
|
||||||
} from '@nocobase/plugin-workflow/client';
|
} from '@nocobase/plugin-workflow/client';
|
||||||
|
|
||||||
import { NAMESPACE, useLang } from '../locale';
|
import { NAMESPACE, useLang } from '../locale';
|
||||||
import { FormBlockProvider } from './instruction/FormBlockProvider';
|
import { FormBlockProvider } from './instruction/FormBlockProvider';
|
||||||
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
|
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
|
||||||
import { TaskStatusOptionsMap } from '../common/constants';
|
import { TaskStatusOptionsMap } from '../common/constants';
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
function TaskStatusColumn(props) {
|
function TaskStatusColumn(props) {
|
||||||
const recordData = useCollectionRecordData();
|
const recordData = useCollectionRecordData();
|
||||||
@ -291,11 +297,12 @@ function useSubmit() {
|
|||||||
const { values, submit } = useForm();
|
const { values, submit } = useForm();
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const buttonSchema = useFieldSchema();
|
const buttonSchema = useFieldSchema();
|
||||||
const { service } = useTableBlockContext();
|
const { service } = useListBlockContext();
|
||||||
const { userJob, execution } = useFlowContext();
|
const { userJob, execution } = useFlowContext();
|
||||||
const { name: actionKey } = buttonSchema;
|
const { name: actionKey } = buttonSchema;
|
||||||
const { name: formKey } = buttonSchema.parent.parent;
|
const { name: formKey } = buttonSchema.parent.parent;
|
||||||
const { assignedValues = {} } = buttonSchema?.['x-action-settings'] ?? {};
|
const { assignedValues = {} } = buttonSchema?.['x-action-settings'] ?? {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
if (execution.status || userJob.status) {
|
if (execution.status || userJob.status) {
|
||||||
@ -611,39 +618,23 @@ function ContentDetailWithTitle(props) {
|
|||||||
|
|
||||||
function TaskItem() {
|
function TaskItem() {
|
||||||
const token = useAntdToken();
|
const token = useAntdToken();
|
||||||
const [visible, setVisible] = useState(false);
|
|
||||||
const record = useCollectionRecordData();
|
const record = useCollectionRecordData();
|
||||||
const { t } = useTranslation();
|
const navigate = useNavigate();
|
||||||
// const { defaultOpenMode } = useOpenModeContext();
|
const { setRecord } = usePopupRecordContext();
|
||||||
// const { openPopup } = usePopupUtils();
|
const onOpen = useCallback(
|
||||||
// const { isPopupVisibleControlledByURL } = usePopupSettings();
|
(e: React.MouseEvent) => {
|
||||||
const onOpen = useCallback((e: React.MouseEvent) => {
|
|
||||||
const targetElement = e.target as Element; // 将事件目标转换为Element类型
|
const targetElement = e.target as Element; // 将事件目标转换为Element类型
|
||||||
const currentTargetElement = e.currentTarget as Element;
|
const currentTargetElement = e.currentTarget as Element;
|
||||||
if (currentTargetElement.contains(targetElement)) {
|
if (currentTargetElement.contains(targetElement)) {
|
||||||
setVisible(true);
|
setRecord(record);
|
||||||
// if (!isPopupVisibleControlledByURL()) {
|
navigate(`./${record.id}`);
|
||||||
// } else {
|
|
||||||
// openPopup({
|
|
||||||
// // popupUidUsedInURL: 'job',
|
|
||||||
// customActionSchema: {
|
|
||||||
// type: 'void',
|
|
||||||
// 'x-uid': 'job-view',
|
|
||||||
// 'x-action-context': {
|
|
||||||
// dataSource: 'main',
|
|
||||||
// collection: 'workflowManualTasks',
|
|
||||||
// doNotUpdateContext: true,
|
|
||||||
// },
|
|
||||||
// properties: {},
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}, []);
|
},
|
||||||
|
[navigate, record.id],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<Card
|
<Card
|
||||||
onClick={onOpen}
|
onClick={onOpen}
|
||||||
hoverable
|
hoverable
|
||||||
@ -658,10 +649,6 @@ function TaskItem() {
|
|||||||
>
|
>
|
||||||
<ContentDetail />
|
<ContentDetail />
|
||||||
</Card>
|
</Card>
|
||||||
<PopupContextProvider visible={visible} setVisible={setVisible} openMode="modal">
|
|
||||||
<Drawer />
|
|
||||||
</PopupContextProvider>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,7 +721,9 @@ function TodoExtraActions() {
|
|||||||
export const manualTodo = {
|
export const manualTodo = {
|
||||||
title: `{{t("My manual tasks", { ns: "${NAMESPACE}" })}}`,
|
title: `{{t("My manual tasks", { ns: "${NAMESPACE}" })}}`,
|
||||||
collection: 'workflowManualTasks',
|
collection: 'workflowManualTasks',
|
||||||
|
action: 'listMine',
|
||||||
useActionParams: useTodoActionParams,
|
useActionParams: useTodoActionParams,
|
||||||
component: TaskItem,
|
Actions: TodoExtraActions,
|
||||||
extraActions: TodoExtraActions,
|
Item: TaskItem,
|
||||||
|
Detail: Drawer,
|
||||||
};
|
};
|
||||||
|
@ -16,13 +16,14 @@ import * as jobActions from './actions';
|
|||||||
|
|
||||||
import ManualInstruction from './ManualInstruction';
|
import ManualInstruction from './ManualInstruction';
|
||||||
import { MANUAL_TASK_TYPE } from '../common/constants';
|
import { MANUAL_TASK_TYPE } from '../common/constants';
|
||||||
|
import { Model } from '@nocobase/database';
|
||||||
|
|
||||||
interface WorkflowManualTaskModel {
|
class WorkflowManualTaskModel extends Model {
|
||||||
id: number;
|
declare id: number;
|
||||||
userId: number;
|
declare userId: number;
|
||||||
workflowId: number;
|
declare workflowId: number;
|
||||||
executionId: number;
|
declare executionId: number;
|
||||||
status: number;
|
declare status: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class extends Plugin {
|
export default class extends Plugin {
|
||||||
@ -55,7 +56,13 @@ export default class extends Plugin {
|
|||||||
const workflowPlugin = this.app.pm.get(WorkflowPlugin) as WorkflowPlugin;
|
const workflowPlugin = this.app.pm.get(WorkflowPlugin) as WorkflowPlugin;
|
||||||
workflowPlugin.registerInstruction('manual', ManualInstruction);
|
workflowPlugin.registerInstruction('manual', ManualInstruction);
|
||||||
|
|
||||||
this.db.on('workflowManualTasks.afterSave', async (task: WorkflowManualTaskModel, options) => {
|
this.db.on('workflowManualTasks.afterSave', async (task: WorkflowManualTaskModel, { transaction }) => {
|
||||||
|
// const allCount = await (task.constructor as typeof WorkflowManualTaskModel).count({
|
||||||
|
// where: {
|
||||||
|
// userId: task.userId,
|
||||||
|
// },
|
||||||
|
// transaction,
|
||||||
|
// });
|
||||||
await workflowPlugin.toggleTaskStatus(
|
await workflowPlugin.toggleTaskStatus(
|
||||||
{
|
{
|
||||||
type: MANUAL_TASK_TYPE,
|
type: MANUAL_TASK_TYPE,
|
||||||
@ -63,8 +70,9 @@ export default class extends Plugin {
|
|||||||
userId: task.userId,
|
userId: task.userId,
|
||||||
workflowId: task.workflowId,
|
workflowId: task.workflowId,
|
||||||
},
|
},
|
||||||
Boolean(task.status),
|
task.status === JOB_STATUS.PENDING,
|
||||||
options,
|
// allCount,
|
||||||
|
{ transaction },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Context, utils } from '@nocobase/actions';
|
import actions, { Context, utils } from '@nocobase/actions';
|
||||||
import WorkflowPlugin, { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
import WorkflowPlugin, { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
||||||
|
|
||||||
import ManualInstruction from './ManualInstruction';
|
import ManualInstruction from './ManualInstruction';
|
||||||
@ -111,3 +111,24 @@ export async function submit(context: Context, next) {
|
|||||||
|
|
||||||
plugin.resume(task.job);
|
plugin.resume(task.job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listMine(context, next) {
|
||||||
|
context.action.mergeParams({
|
||||||
|
filter: {
|
||||||
|
userId: context.state.currentUser.id,
|
||||||
|
$or: [
|
||||||
|
{
|
||||||
|
'workflow.enabled': true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'workflow.enabled': false,
|
||||||
|
status: {
|
||||||
|
$ne: JOB_STATUS.PENDING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return actions.list(context, next);
|
||||||
|
}
|
||||||
|
@ -11,14 +11,17 @@ import { PageHeader } from '@ant-design/pro-layout';
|
|||||||
import { Badge, Button, Layout, Menu, Tabs, Tooltip } from 'antd';
|
import { Badge, Button, Layout, Menu, Tabs, Tooltip } from 'antd';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||||
import { Link, Outlet, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ActionContextProvider,
|
||||||
|
CollectionRecordProvider,
|
||||||
css,
|
css,
|
||||||
PinnedPluginListProvider,
|
PinnedPluginListProvider,
|
||||||
SchemaComponent,
|
SchemaComponent,
|
||||||
SchemaComponentContext,
|
SchemaComponentContext,
|
||||||
SchemaComponentOptions,
|
SchemaComponentOptions,
|
||||||
|
useAPIClient,
|
||||||
useApp,
|
useApp,
|
||||||
useCompile,
|
useCompile,
|
||||||
useDocumentTitle,
|
useDocumentTitle,
|
||||||
@ -44,9 +47,11 @@ const contentClass = css`
|
|||||||
export interface TaskTypeOptions {
|
export interface TaskTypeOptions {
|
||||||
title: string;
|
title: string;
|
||||||
collection: string;
|
collection: string;
|
||||||
|
action: string;
|
||||||
useActionParams: Function;
|
useActionParams: Function;
|
||||||
component: React.ComponentType;
|
Actions?: React.ComponentType;
|
||||||
extraActions?: React.ComponentType;
|
Item: React.ComponentType;
|
||||||
|
Detail: React.ComponentType;
|
||||||
// children?: TaskTypeOptions[];
|
// children?: TaskTypeOptions[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +70,7 @@ function MenuLink({ type }: any) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
to={`/admin/workflow/tasks/${type}`}
|
to={`/admin/workflow/tasks/${type}/${TASK_STATUS.PENDING}`}
|
||||||
className={css`
|
className={css`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -85,7 +90,7 @@ function MenuLink({ type }: any) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TASK_STATUS = {
|
export const TASK_STATUS = {
|
||||||
ALL: 'all',
|
ALL: 'all',
|
||||||
PENDING: 'pending',
|
PENDING: 'pending',
|
||||||
COMPLETED: 'completed',
|
COMPLETED: 'completed',
|
||||||
@ -95,7 +100,7 @@ function StatusTabs() {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { taskType, status = TASK_STATUS.PENDING } = useParams();
|
const { taskType, status = TASK_STATUS.PENDING } = useParams();
|
||||||
const type = useCurrentTaskType();
|
const type = useCurrentTaskType();
|
||||||
const { extraActions: ExtraActions } = type;
|
const { Actions } = type;
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
activeKey={status}
|
activeKey={status}
|
||||||
@ -122,9 +127,9 @@ function StatusTabs() {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={
|
||||||
ExtraActions
|
Actions
|
||||||
? {
|
? {
|
||||||
right: <ExtraActions />,
|
right: <Actions />,
|
||||||
}
|
}
|
||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
@ -157,16 +162,45 @@ function useCurrentTaskType() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PopupContext(props: any) {
|
||||||
|
const { popupId } = useParams();
|
||||||
|
const { record } = usePopupRecordContext();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
if (!popupId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<ActionContextProvider
|
||||||
|
visible={Boolean(popupId)}
|
||||||
|
setVisible={(visible) => {
|
||||||
|
if (!visible) {
|
||||||
|
navigate(-1);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
openMode="modal"
|
||||||
|
>
|
||||||
|
<CollectionRecordProvider record={record}>{props.children}</CollectionRecordProvider>
|
||||||
|
</ActionContextProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const PopupRecordContext = createContext<any>({ record: null, setRecord: (record) => {} });
|
||||||
|
export function usePopupRecordContext() {
|
||||||
|
return useContext(PopupRecordContext);
|
||||||
|
}
|
||||||
|
|
||||||
export function WorkflowTasks() {
|
export function WorkflowTasks() {
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const { setTitle } = useDocumentTitle();
|
const { setTitle } = useDocumentTitle();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { taskType, status = TASK_STATUS.PENDING } = useParams();
|
const apiClient = useAPIClient();
|
||||||
|
const { taskType, status = TASK_STATUS.PENDING, popupId } = useParams();
|
||||||
const { token } = useToken();
|
const { token } = useToken();
|
||||||
|
const [currentRecord, setCurrentRecord] = useState<any>(null);
|
||||||
|
|
||||||
const items = useTaskTypeItems();
|
const items = useTaskTypeItems();
|
||||||
|
|
||||||
const { title, collection, useActionParams, component: Component } = useCurrentTaskType();
|
const { title, collection, action = 'list', useActionParams, Item, Detail } = useCurrentTaskType();
|
||||||
|
|
||||||
const params = useActionParams(status);
|
const params = useActionParams(status);
|
||||||
|
|
||||||
@ -180,6 +214,24 @@ export function WorkflowTasks() {
|
|||||||
}
|
}
|
||||||
}, [items, navigate, status, taskType]);
|
}, [items, navigate, status, taskType]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (popupId && !currentRecord) {
|
||||||
|
apiClient
|
||||||
|
.resource(collection)
|
||||||
|
.get({
|
||||||
|
filterByTk: popupId,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data?.data) {
|
||||||
|
setCurrentRecord(res.data.data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [popupId, collection, currentRecord, apiClient]);
|
||||||
|
|
||||||
const typeKey = taskType ?? items[0].key;
|
const typeKey = taskType ?? items[0].key;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -204,6 +256,12 @@ export function WorkflowTasks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
|
>
|
||||||
|
<PopupRecordContext.Provider
|
||||||
|
value={{
|
||||||
|
record: currentRecord,
|
||||||
|
setRecord: setCurrentRecord,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<SchemaComponentContext.Provider value={{ designable: false }}>
|
<SchemaComponentContext.Provider value={{ designable: false }}>
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
@ -218,7 +276,7 @@ export function WorkflowTasks() {
|
|||||||
'x-decorator': 'List.Decorator',
|
'x-decorator': 'List.Decorator',
|
||||||
'x-decorator-props': {
|
'x-decorator-props': {
|
||||||
collection,
|
collection,
|
||||||
action: 'list',
|
action,
|
||||||
params: {
|
params: {
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
sort: ['-createdAt'],
|
sort: ['-createdAt'],
|
||||||
@ -271,18 +329,23 @@ export function WorkflowTasks() {
|
|||||||
item: {
|
item: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
'x-decorator': 'List.Item',
|
'x-decorator': 'List.Item',
|
||||||
'x-component': Component,
|
'x-component': Item,
|
||||||
'x-read-pretty': true,
|
'x-read-pretty': true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
popup: {
|
||||||
|
type: 'void',
|
||||||
|
'x-decorator': PopupContext,
|
||||||
|
'x-component': Detail,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Outlet />
|
|
||||||
</SchemaComponentContext.Provider>
|
</SchemaComponentContext.Provider>
|
||||||
|
</PopupRecordContext.Provider>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
@ -296,7 +359,7 @@ function WorkflowTasksLink() {
|
|||||||
return types.length ? (
|
return types.length ? (
|
||||||
<Tooltip title={lang('Workflow todos')}>
|
<Tooltip title={lang('Workflow todos')}>
|
||||||
<Button>
|
<Button>
|
||||||
<Link to={`/admin/workflow/tasks/${types[0]}`} onClick={reload}>
|
<Link to={`/admin/workflow/tasks/${types[0]}/${TASK_STATUS.PENDING}`} onClick={reload}>
|
||||||
<Badge count={total} size="small">
|
<Badge count={total} size="small">
|
||||||
<CheckCircleOutlined />
|
<CheckCircleOutlined />
|
||||||
</Badge>
|
</Badge>
|
||||||
@ -357,7 +420,7 @@ function TasksCountsProvider(props: any) {
|
|||||||
return <TasksCountsContext.Provider value={{ reload, total, counts }}>{props.children}</TasksCountsContext.Provider>;
|
return <TasksCountsContext.Provider value={{ reload, total, counts }}>{props.children}</TasksCountsContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TasksProvider = (props: any) => {
|
export function TasksProvider(props: any) {
|
||||||
const isLoggedIn = useIsLoggedIn();
|
const isLoggedIn = useIsLoggedIn();
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
@ -377,4 +440,4 @@ export const TasksProvider = (props: any) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return isLoggedIn ? <TasksCountsProvider>{content}</TasksCountsProvider> : content;
|
return isLoggedIn ? <TasksCountsProvider>{content}</TasksCountsProvider> : content;
|
||||||
};
|
}
|
||||||
|
@ -120,15 +120,10 @@ export default class PluginWorkflowClient extends Plugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.router.add('admin.workflow.tasks', {
|
this.router.add('admin.workflow.tasks', {
|
||||||
path: '/admin/workflow/tasks/:taskType/:status?',
|
path: '/admin/workflow/tasks/:taskType/:status/:popupId?',
|
||||||
Component: WorkflowTasks,
|
Component: WorkflowTasks,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.add('admin.workflow.tasks.popup', {
|
|
||||||
path: '/admin/workflow/tasks/:taskType/:status/popups/*',
|
|
||||||
Component: PagePopups,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.app.pluginSettingsManager.add(NAMESPACE, {
|
this.app.pluginSettingsManager.add(NAMESPACE, {
|
||||||
icon: 'PartitionOutlined',
|
icon: 'PartitionOutlined',
|
||||||
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`,
|
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`,
|
||||||
@ -193,3 +188,4 @@ export { default as useStyles } from './style';
|
|||||||
export { Trigger, useTrigger } from './triggers';
|
export { Trigger, useTrigger } from './triggers';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './variable';
|
export * from './variable';
|
||||||
|
export { TASK_STATUS, usePopupRecordContext } from './WorkflowTasks';
|
||||||
|
@ -793,10 +793,16 @@ export default class PluginWorkflowServer extends Plugin {
|
|||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
public async toggleTaskStatus(task: WorkflowTaskModel, done: boolean, { transaction }: Transactionable) {
|
public async toggleTaskStatus(task: WorkflowTaskModel, on: boolean, { transaction }: Transactionable) {
|
||||||
const { db } = this.app;
|
const { db } = this.app;
|
||||||
const repository = db.getRepository('workflowTasks') as WorkflowTasksRepository;
|
const repository = db.getRepository('workflowTasks') as WorkflowTasksRepository;
|
||||||
if (done) {
|
if (on) {
|
||||||
|
await repository.updateOrCreate({
|
||||||
|
filterKeys: ['key', 'type'],
|
||||||
|
values: task,
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
await repository.destroy({
|
await repository.destroy({
|
||||||
filter: {
|
filter: {
|
||||||
type: task.type,
|
type: task.type,
|
||||||
@ -804,12 +810,6 @@ export default class PluginWorkflowServer extends Plugin {
|
|||||||
},
|
},
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
await repository.updateOrCreate({
|
|
||||||
filterKeys: ['key', 'type'],
|
|
||||||
values: task,
|
|
||||||
transaction,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
|
@ -128,9 +128,7 @@
|
|||||||
"@nocobase/plugin-workflow-action-trigger",
|
"@nocobase/plugin-workflow-action-trigger",
|
||||||
"@nocobase/plugin-workflow-aggregate",
|
"@nocobase/plugin-workflow-aggregate",
|
||||||
"@nocobase/plugin-workflow-delay",
|
"@nocobase/plugin-workflow-delay",
|
||||||
"@nocobase/plugin-workflow-dynamic-calculation",
|
|
||||||
"@nocobase/plugin-workflow-loop",
|
"@nocobase/plugin-workflow-loop",
|
||||||
"@nocobase/plugin-workflow-manual",
|
|
||||||
"@nocobase/plugin-workflow-parallel",
|
"@nocobase/plugin-workflow-parallel",
|
||||||
"@nocobase/plugin-workflow-request",
|
"@nocobase/plugin-workflow-request",
|
||||||
"@nocobase/plugin-workflow-sql",
|
"@nocobase/plugin-workflow-sql",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user