fix(plugin-workflow): fix todo list form read-pretty for non-assigneed user (#1615)
Fix #1572.
This commit is contained in:
parent
5752edd5d5
commit
c572b696cc
@ -198,7 +198,7 @@ export function WorkflowCanvas() {
|
|||||||
<div className={branchBlockClass}>
|
<div className={branchBlockClass}>
|
||||||
<Branch entry={entry} />
|
<Branch entry={entry} />
|
||||||
</div>
|
</div>
|
||||||
<div className={cx(nodeCardClass)}>
|
<div className={cx('end', nodeCardClass)}>
|
||||||
<div className={cx(nodeMetaClass)}>
|
<div className={cx(nodeMetaClass)}>
|
||||||
<Tag color="#333">{lang('End')}</Tag>
|
<Tag color="#333">{lang('End')}</Tag>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,7 +6,7 @@ import parse from 'json-templates';
|
|||||||
import { css } from "@emotion/css";
|
import { css } from "@emotion/css";
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import { CollectionManagerProvider, CollectionProvider, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, TableBlockProvider, useActionContext, useAPIClient, useCollectionManager, useRecord, useRequest, useTableBlockContext } from "@nocobase/client";
|
import { CollectionManagerProvider, CollectionProvider, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, TableBlockProvider, useActionContext, useAPIClient, useCollectionManager, useCurrentUserContext, useRecord, useRequest, useTableBlockContext } from "@nocobase/client";
|
||||||
import { uid } from "@nocobase/utils/client";
|
import { uid } from "@nocobase/utils/client";
|
||||||
|
|
||||||
import { JobStatusOptions, JobStatusOptionsMap, JOB_STATUS } from "../../constants";
|
import { JobStatusOptions, JobStatusOptionsMap, JOB_STATUS } from "../../constants";
|
||||||
@ -386,9 +386,9 @@ function FlowContextProvider(props) {
|
|||||||
if (!executionId) {
|
if (!executionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
api.resource('executions').get?.({
|
api.resource('users_jobs').get?.({
|
||||||
filterByTk: executionId,
|
filterByTk: executionId,
|
||||||
appends: ['workflow', 'workflow.nodes', 'jobs'],
|
appends: ['workflow', 'workflow.nodes', 'execution', 'execution.jobs'],
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
const {
|
const {
|
||||||
@ -422,14 +422,21 @@ function FlowContextProvider(props) {
|
|||||||
|
|
||||||
WorkflowTodo.Drawer = function () {
|
WorkflowTodo.Drawer = function () {
|
||||||
const ctx = useContext(SchemaComponentContext);
|
const ctx = useContext(SchemaComponentContext);
|
||||||
const { id, node, workflow, status, result, updatedAt } = useRecord();
|
const { id, node, workflow, status, result, updatedAt, userId } = useRecord();
|
||||||
|
const { data: user } = useCurrentUserContext();
|
||||||
|
|
||||||
|
const disabled = Boolean(status) || user?.data?.id !== userId;
|
||||||
const form = useMemo(() => createForm({
|
const form = useMemo(() => createForm({
|
||||||
readPretty: Boolean(status),
|
readPretty: disabled,
|
||||||
|
disabled,
|
||||||
initialValues: result
|
initialValues: result
|
||||||
}), [result]);
|
}), [result]);
|
||||||
|
|
||||||
const { blocks, collection, actions } = node.config.schema ?? {};
|
const { blocks, collection, actions } = node.config.schema ?? {};
|
||||||
|
const availableActions = Object.keys(actions).reduce((buttons, key) => ({ ...buttons, [key]: {
|
||||||
|
...actions[key],
|
||||||
|
'x-disabled': disabled
|
||||||
|
} }), {});
|
||||||
|
|
||||||
const statusOption = JobStatusOptionsMap[status];
|
const statusOption = JobStatusOptionsMap[status];
|
||||||
const actionSchema = status
|
const actionSchema = status
|
||||||
@ -454,7 +461,7 @@ WorkflowTodo.Drawer = function () {
|
|||||||
'x-content': statusOption.label
|
'x-content': statusOption.label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: actions;
|
: availableActions;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaComponentContext.Provider value={{ ...ctx, designable: false }}>
|
<SchemaComponentContext.Provider value={{ ...ctx, designable: false }}>
|
||||||
|
@ -34,6 +34,14 @@ export const workflowPageClass = css`
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
|
|
||||||
|
.end{
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
box-shadow: 0 .25em .5em rgba(0, 0, 0, .1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user