fix(plugin-workflow): fix todo list form read-pretty for non-assigneed user (#1615)

Fix #1572.
This commit is contained in:
Junyi 2023-03-29 17:16:46 +07:00 committed by GitHub
parent 5752edd5d5
commit c572b696cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -198,7 +198,7 @@ export function WorkflowCanvas() {
<div className={branchBlockClass}>
<Branch entry={entry} />
</div>
<div className={cx(nodeCardClass)}>
<div className={cx('end', nodeCardClass)}>
<div className={cx(nodeMetaClass)}>
<Tag color="#333">{lang('End')}</Tag>
</div>

View File

@ -6,7 +6,7 @@ import parse from 'json-templates';
import { css } from "@emotion/css";
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 { JobStatusOptions, JobStatusOptionsMap, JOB_STATUS } from "../../constants";
@ -386,9 +386,9 @@ function FlowContextProvider(props) {
if (!executionId) {
return;
}
api.resource('executions').get?.({
api.resource('users_jobs').get?.({
filterByTk: executionId,
appends: ['workflow', 'workflow.nodes', 'jobs'],
appends: ['workflow', 'workflow.nodes', 'execution', 'execution.jobs'],
})
.then(({ data }) => {
const {
@ -422,14 +422,21 @@ function FlowContextProvider(props) {
WorkflowTodo.Drawer = function () {
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({
readPretty: Boolean(status),
readPretty: disabled,
disabled,
initialValues: result
}), [result]);
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 actionSchema = status
@ -454,7 +461,7 @@ WorkflowTodo.Drawer = function () {
'x-content': statusOption.label
}
}
: actions;
: availableActions;
return (
<SchemaComponentContext.Provider value={{ ...ctx, designable: false }}>

View File

@ -34,6 +34,14 @@ export const workflowPageClass = css`
flex-direction: column;
align-items: center;
padding: 2em;
.end{
cursor: default;
&:hover{
box-shadow: 0 .25em .5em rgba(0, 0, 0, .1);
}
}
}
`;