Workflow Condition
The proxima:workflowCondition
module can create a workflow transition rule.
The workflow transition rule can determine whether a user can execute the transition. If the rule returns false, the user cannot click to transition.
Configure team expressions on workflow transition rules
You can configure team expressions to return the result of the transition rule.
For example, you can configure the following in the plugin's manifest, where expression
is the expression and errorMessage
is the prompt message.
modules:
proxima:workflowCondition:
- key: my-workflow-condition
title: Assignee Required
description: The assignee must not be empty to transition
expression: item.values.assignee?.length > 0
errorMessage: The assignee cannot be empty
The expression can use the following properties:
- item - [Item]
- currentUser - [User]
- workspace - [Workspace]
interface Item {
name: string; // item name
key: string; // item key
objectId: string; // item id
values: Record<string,any>; // item custom field value
itemType: { // item type
objectId: string;
},
status: { // item status
objectId: string
};
}
interface User {
objectId: string;
createdAt: string; // creation time
updatedAt: string; // update time
username: string; // user name
email: string;
enabled: boolean; // Whether to enable
deleted: boolean; // delete or not
nickname: string;
language: string; // language (e.g. 'zh-CN')
}
interface Workspace {
createdAt: string; // creation time
updatedAt: string; // update time
name: string; // workspace name
key: string; // workspace key
}
Configure transition rules through a custom UI
You can configure rules in the transition rule through a custom UI. The following three pages need to be configured:
- create: The page when creating the workflow transition rule
- edit: The page when editing the workflow transition rule
- view: The page when displaying the workflow transition rule
On the create and edit pages, you need to save the configuration information through the handleWorkflowConfigChange
API.
Manifest example
modules:
proxima:workflowCondition:
- key: my-workflow-condition
title: Configure Workflow Transition Rules
description: Custom workflow transition rules
create:
route: /workflow-condition-create
edit:
route: /workflow-condition-edit
view:
route: /workflow-condition-view
resource: main
loadType: Micro
resources:
- key: main
path: /dist
Overriding expression and errorMessage
The handleWorkflowConfigChange
method can override the expression and errorMessage configured in the manifest.
import { Input } from 'antd';
const WorkflowConditionCreatePage = (props) => {
const { context } = props;
const handleWorkflowConfigChange = context?.modal?.handleWorkflowConfigChange;
const onChange = (key, value) => {
handleWorkflowConfigChange({ [key]: value });
};
return (
<div>
<div>Expression:</div>
<Input placeholder="Enter expression" onChange={e => onChange('expression', e.target.value)} />
<div>Error Message:</div>
<Input placeholder="Enter error message" onChange={e => onChange('errorMessage', e.target.value)} />
</div>
);
};
export default WorkflowConditionCreatePage;