From e86c5a7636a22513ea9adbe4cd2fb6f9ebc3dd8b Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 27 Oct 2023 11:34:08 +0800 Subject: [PATCH] refactor(plugin-workflow): adjust branch styles (#2922) --- .../plugin-workflow/src/client/Branch.tsx | 6 ++- .../src/client/CanvasContent.tsx | 12 ++++- .../plugin-workflow/src/client/index.tsx | 1 + .../src/client/nodes/condition.tsx | 15 +------ .../plugin-workflow/src/client/nodes/loop.tsx | 6 --- .../src/client/nodes/parallel.tsx | 45 +++++++++---------- .../plugin-workflow/src/client/style.tsx | 2 +- 7 files changed, 39 insertions(+), 48 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/Branch.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/Branch.tsx index 3b73520f4..cafee6cc8 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/Branch.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/Branch.tsx @@ -9,11 +9,13 @@ export function Branch({ entry = null, branchIndex = null, controller = null, + className, }: { from?: any; entry?: any; branchIndex?: number | null; - controller?: any; + controller?: React.ReactNode; + className?: string; }) { const { styles } = useStyles(); @@ -23,7 +25,7 @@ export function Branch({ } return ( -
+
{controller} diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx index 68b9850a6..fe6555f77 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx @@ -1,5 +1,8 @@ import { Alert } from 'antd'; import React from 'react'; + +import { cx, css } from '@nocobase/client'; + import { Branch } from './Branch'; import { lang } from './locale'; import useStyles from './style'; @@ -16,7 +19,14 @@ export function CanvasContent({ entry }) { ) : null} -
+
{lang('End')}
diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx index 5b69499a3..75c857677 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx @@ -4,6 +4,7 @@ export * from './FlowContext'; export * from './nodes'; export { triggers, useTrigger, getTriggersOptions } from './triggers'; export { useWorkflowVariableOptions, getCollectionFieldOptions } from './variable'; +export { default as useStyles } from './style'; import { Plugin } from '@nocobase/client'; import React from 'react'; diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/condition.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/condition.tsx index 58b82ba4a..58b4ba5cf 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/condition.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/condition.tsx @@ -423,19 +423,8 @@ export default { return ( {rejectOnFalse ? null : ( -
-
* > .workflow-branch-lines { - > button { - display: none; - } - } - `, - )} - > +
+
diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/loop.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/loop.tsx index 98043043a..897c60be3 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/loop.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/loop.tsx @@ -91,12 +91,6 @@ export default {
-
); diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/parallel.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/parallel.tsx index 9087dfba1..ab676c44f 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/parallel.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/nodes/parallel.tsx @@ -65,8 +65,8 @@ export default { return ( -
-
+
+
{branches.map((branch) => ( ))} @@ -100,34 +100,29 @@ export default { /> ))}
-
- } className={css` - visibility: ${workflow.executed ? 'hidden' : 'visible'}; - `} - > -
+ .anticon { + transform-origin: center; + transform: rotate(-45deg); + } + `} + onClick={() => setBranchCount(branchCount + 1)} + disabled={workflow.executed} + /> +
); diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx index 3c18eb836..b7afa3f53 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx @@ -110,6 +110,7 @@ const useStyles = createStyles(({ css, token }) => { branchBlockClass: css` display: flex; position: relative; + margin-top: 2em; :before { content: ''; @@ -330,7 +331,6 @@ const useStyles = createStyles(({ css, token }) => { conditionClass: css` position: relative; - height: 2em; overflow: visible; > span {