From a722d0af5ab7251b70591e690cc67a59015a94ed Mon Sep 17 00:00:00 2001 From: Junyi Date: Thu, 2 Nov 2023 22:08:34 +0800 Subject: [PATCH] feat(plugin-workflow): add zoomer for workflow canvas (#2951) * feat(plugin-workflow): add zoomer for workflow canvas * fix(plugin-workflow): fix zoomer position --- .../src/schema-component/antd/input/Input.tsx | 2 + .../src/client/CanvasContent.tsx | 49 +++++++++++++------ .../plugin-workflow/src/client/style.tsx | 31 ++++++++---- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/input/Input.tsx b/packages/core/client/src/schema-component/antd/input/Input.tsx index a17547dd2..cca67cf07 100644 --- a/packages/core/client/src/schema-component/antd/input/Input.tsx +++ b/packages/core/client/src/schema-component/antd/input/Input.tsx @@ -6,6 +6,8 @@ import React from 'react'; import { JSONTextAreaProps, Json } from './Json'; import { ReadPretty } from './ReadPretty'; +export { ReadPretty as InputReadPretty } from './ReadPretty'; + type ComposedInput = React.FC & { ReadPretty: React.FC; TextArea: React.FC; diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx index f02071c59..8a78c6cf5 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/CanvasContent.tsx @@ -1,4 +1,4 @@ -import { Alert } from 'antd'; +import { Alert, Slider } from 'antd'; import React from 'react'; import { cx, css } from '@nocobase/client'; @@ -12,24 +12,41 @@ import { TriggerConfig } from './triggers'; export function CanvasContent({ entry }) { const { styles } = useStyles(); const { workflow } = useFlowContext(); + const [zoom, setZoom] = React.useState(100); return ( -
- {workflow?.executed ? ( - - ) : null} - -
- +
+
+
+
+ {workflow?.executed ? ( + + ) : null} + +
+ +
+
{lang('End')}
+
+
+
+
+
-
{lang('End')}
); } diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx index ad15dfbaa..3f429c4ae 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/style.tsx @@ -35,9 +35,27 @@ const useStyles = createStyles(({ css, token }) => { } } - .workflow-canvas { + .workflow-canvas-wrapper { flex-grow: 1; + overflow: hidden; + position: relative; + } + + .workflow-canvas-zoomer { + display: flex; + align-items: center; + position: absolute; + top: 2em; + right: 2em; + height: 10em; + padding: 1em 0; + border-radius: 0.5em; + background: ${token.colorBgContainer}; + } + + .workflow-canvas { overflow: auto; + height: 100%; width: 100%; display: flex; flex-direction: column; @@ -48,14 +66,6 @@ const useStyles = createStyles(({ css, token }) => { margin-bottom: 2em; font-size: 85%; } - - .end { - cursor: default; - - &:hover { - box-shadow: 0 0.25em 0.5em rgba(0, 0, 0, 0.1); - } - } } `, @@ -110,7 +120,7 @@ const useStyles = createStyles(({ css, token }) => { branchBlockClass: css` display: flex; position: relative; - margin-top: 2em; + margin: 2em auto auto auto; :before { content: ''; @@ -327,6 +337,7 @@ const useStyles = createStyles(({ css, token }) => { display: flex; flex-direction: column-reverse; align-items: center; + margin: auto; `, nodeJobResultClass: css`