diff --git a/packages/core/client/src/schema-component/antd/list/index.ts b/packages/core/client/src/schema-component/antd/list/index.ts
index 5e8ff290de..afe657ed04 100644
--- a/packages/core/client/src/schema-component/antd/list/index.ts
+++ b/packages/core/client/src/schema-component/antd/list/index.ts
@@ -8,3 +8,4 @@
*/
export * from './List';
+export { useListBlockContext } from './List.Decorator';
diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx
index beeae222c4..591a16e5bf 100644
--- a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx
+++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx
@@ -33,9 +33,12 @@ import {
useActionContext,
useCurrentUserContext,
useFormBlockContext,
- useTableBlockContext,
+ useListBlockContext,
List,
OpenModeProvider,
+ ActionContextProvider,
+ useRequest,
+ CollectionRecordProvider,
} from '@nocobase/client';
import WorkflowPlugin, {
DetailsBlockProvider,
@@ -46,12 +49,14 @@ import WorkflowPlugin, {
EXECUTION_STATUS,
JOB_STATUS,
WorkflowTitle,
+ TASK_STATUS,
} from '@nocobase/plugin-workflow/client';
import { NAMESPACE, useLang } from '../locale';
import { FormBlockProvider } from './instruction/FormBlockProvider';
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
import { TaskStatusOptionsMap } from '../common/constants';
+import { useNavigate, useParams } from 'react-router-dom';
function TaskStatusColumn(props) {
const recordData = useCollectionRecordData();
@@ -291,11 +296,12 @@ function useSubmit() {
const { values, submit } = useForm();
const field = useField();
const buttonSchema = useFieldSchema();
- const { service } = useTableBlockContext();
+ const { service } = useListBlockContext();
const { userJob, execution } = useFlowContext();
const { name: actionKey } = buttonSchema;
const { name: formKey } = buttonSchema.parent.parent;
const { assignedValues = {} } = buttonSchema?.['x-action-settings'] ?? {};
+
return {
async run() {
if (execution.status || userJob.status) {
@@ -611,57 +617,35 @@ function ContentDetailWithTitle(props) {
function TaskItem() {
const token = useAntdToken();
- const [visible, setVisible] = useState(false);
const record = useCollectionRecordData();
- const { t } = useTranslation();
- // const { defaultOpenMode } = useOpenModeContext();
- // const { openPopup } = usePopupUtils();
- // const { isPopupVisibleControlledByURL } = usePopupSettings();
- const onOpen = useCallback((e: React.MouseEvent) => {
- const targetElement = e.target as Element; // 将事件目标转换为Element类型
- const currentTargetElement = e.currentTarget as Element;
- if (currentTargetElement.contains(targetElement)) {
- setVisible(true);
- // if (!isPopupVisibleControlledByURL()) {
- // } else {
- // openPopup({
- // // popupUidUsedInURL: 'job',
- // customActionSchema: {
- // type: 'void',
- // 'x-uid': 'job-view',
- // 'x-action-context': {
- // dataSource: 'main',
- // collection: 'workflowManualTasks',
- // doNotUpdateContext: true,
- // },
- // properties: {},
- // },
- // });
- // }
- }
- e.stopPropagation();
- }, []);
+ const navigate = useNavigate();
+ const onOpen = useCallback(
+ (e: React.MouseEvent) => {
+ const targetElement = e.target as Element; // 将事件目标转换为Element类型
+ const currentTargetElement = e.currentTarget as Element;
+ if (currentTargetElement.contains(targetElement)) {
+ navigate(`./${record.id}`);
+ }
+ e.stopPropagation();
+ },
+ [navigate, record.id],
+ );
return (
- <>
- }
- className={css`
- .ant-card-extra {
- color: ${token.colorTextDescription};
- }
- `}
- >
-
-
-
-
-
- >
+ }
+ className={css`
+ .ant-card-extra {
+ color: ${token.colorTextDescription};
+ }
+ `}
+ >
+
+
);
}
@@ -734,7 +718,9 @@ function TodoExtraActions() {
export const manualTodo = {
title: `{{t("My manual tasks", { ns: "${NAMESPACE}" })}}`,
collection: 'workflowManualTasks',
+ action: 'listMine',
useActionParams: useTodoActionParams,
- component: TaskItem,
- extraActions: TodoExtraActions,
+ Actions: TodoExtraActions,
+ Item: TaskItem,
+ Detail: Drawer,
};
diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/actions.ts b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/actions.ts
index 33dccdbeb5..a9ac4c9768 100644
--- a/packages/plugins/@nocobase/plugin-workflow-manual/src/server/actions.ts
+++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/server/actions.ts
@@ -7,7 +7,7 @@
* 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 ManualInstruction from './ManualInstruction';
@@ -111,3 +111,24 @@ export async function submit(context: Context, next) {
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);
+}
diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/WorkflowTasks.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/WorkflowTasks.tsx
index c8415ad0b9..fba25b06d1 100644
--- a/packages/plugins/@nocobase/plugin-workflow/src/client/WorkflowTasks.tsx
+++ b/packages/plugins/@nocobase/plugin-workflow/src/client/WorkflowTasks.tsx
@@ -14,6 +14,8 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo, useS
import { Link, Outlet, useNavigate, useParams } from 'react-router-dom';
import {
+ ActionContextProvider,
+ CollectionRecordProvider,
css,
PinnedPluginListProvider,
SchemaComponent,
@@ -58,9 +60,11 @@ const contentClass = css`
export interface TaskTypeOptions {
title: string;
collection: string;
+ action: string;
useActionParams: Function;
- component: React.ComponentType;
- extraActions?: React.ComponentType;
+ Actions?: React.ComponentType;
+ Item: React.ComponentType;
+ Detail: React.ComponentType;
// children?: TaskTypeOptions[];
}
@@ -79,7 +83,7 @@ function MenuLink({ type }: any) {
return (
,
+ right: ,
}
: {}
}
@@ -171,18 +175,36 @@ function useCurrentTaskType() {
);
}
+function PopupContext(props: any) {
+ const { popupId } = useParams();
+ const navigate = useNavigate();
+ return (
+ {
+ if (!visible) {
+ navigate(-1);
+ }
+ }}
+ openMode="modal"
+ >
+ {props.children}
+
+ );
+}
+
export function WorkflowTasks() {
const compile = useCompile();
const { setTitle } = useDocumentTitle();
const navigate = useNavigate();
- const { taskType, status = TASK_STATUS.PENDING } = useParams();
+ const { taskType, status = TASK_STATUS.PENDING, popupId } = useParams();
const {
token: { colorBgContainer },
} = useToken();
const items = useTaskTypeItems();
- const { title, collection, useActionParams, component: Component } = useCurrentTaskType();
+ const { title, collection, action = 'list', useActionParams, Item, Detail } = useCurrentTaskType();
const params = useActionParams(status);
@@ -234,7 +256,7 @@ export function WorkflowTasks() {
'x-decorator': 'List.Decorator',
'x-decorator-props': {
collection,
- action: 'list',
+ action,
params: {
pageSize: 20,
sort: ['-createdAt'],
@@ -284,17 +306,21 @@ export function WorkflowTasks() {
item: {
type: 'object',
'x-decorator': 'List.Item',
- 'x-component': Component,
+ 'x-component': Item,
'x-read-pretty': true,
},
},
},
},
},
+ popup: {
+ type: 'void',
+ 'x-decorator': PopupContext,
+ 'x-component': Detail,
+ },
},
}}
/>
-
@@ -309,7 +335,7 @@ function WorkflowTasksLink() {
return types.length ? (