From c851e65459137c86b4dacd9b46f384264546c91f Mon Sep 17 00:00:00 2001 From: Junyi Date: Wed, 4 Jan 2023 22:24:41 +0800 Subject: [PATCH] fix(plugin-workflow): fix history drawer in workflow canvas (#1326) --- .../workflow/src/client/WorkflowCanvas.tsx | 28 +++++++++++++++++-- .../workflow/src/client/WorkflowProvider.tsx | 25 +++++++++++++++-- .../workflow/src/client/WorkflowShortcut.tsx | 24 +--------------- .../src/client/schemas/executions.tsx | 2 +- .../workflow/src/client/schemas/workflows.ts | 2 +- 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/packages/plugins/workflow/src/client/WorkflowCanvas.tsx b/packages/plugins/workflow/src/client/WorkflowCanvas.tsx index 7d9b31b6f..f45fb071b 100644 --- a/packages/plugins/workflow/src/client/WorkflowCanvas.tsx +++ b/packages/plugins/workflow/src/client/WorkflowCanvas.tsx @@ -8,23 +8,45 @@ import { useTranslation } from 'react-i18next'; import { ActionContext, + ResourceActionProvider, SchemaComponent, useDocumentTitle, useResourceActionContext, useResourceContext } from '@nocobase/client'; -import { FlowContext } from './FlowContext'; +import { FlowContext, useFlowContext } from './FlowContext'; import { branchBlockClass, nodeCardClass, nodeMetaClass, workflowVersionDropdownClass } from './style'; import { TriggerConfig } from './triggers'; import { Branch } from './Branch'; import { executionSchema } from './schemas/executions'; import { ExecutionLink } from './ExecutionLink'; -import { ExecutionResourceProvider } from './ExecutionResourceProvider'; import { lang } from './locale'; +function ExecutionResourceProvider({ request, filter = {}, ...others }) { + const { workflow } = useFlowContext(); + const props = { + ...others, + request: { + ...request, + params: { + ...request?.params, + filter: { + ...(request?.params?.filter), + key: workflow.key, + } + } + } + }; + + return ( + + ); +} + + function makeNodes(nodes): void { const nodesMap = new Map(); nodes.forEach(item => nodesMap.set(item.id, item)); @@ -168,7 +190,7 @@ export function WorkflowCanvas() { - {lang('Execution history')} + {lang('Execution history')} {lang('Copy to new version')} } diff --git a/packages/plugins/workflow/src/client/WorkflowProvider.tsx b/packages/plugins/workflow/src/client/WorkflowProvider.tsx index 19323b5d9..8e36205fc 100644 --- a/packages/plugins/workflow/src/client/WorkflowProvider.tsx +++ b/packages/plugins/workflow/src/client/WorkflowProvider.tsx @@ -1,11 +1,16 @@ import React, { useContext } from 'react'; -import { PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client'; +import { Card } from 'antd'; +import { PluginManagerContext, RouteSwitchContext, SchemaComponent, SettingsCenterProvider } from '@nocobase/client'; import { WorkflowPage } from './WorkflowPage'; -import { WorkflowPane, WorkflowShortcut } from './WorkflowShortcut'; import { ExecutionPage } from './ExecutionPage'; import { triggers } from './triggers'; import { instructions } from './nodes'; import { lang } from './locale'; +import { workflowSchema } from './schemas/workflows'; +import { WorkflowLink } from './WorkflowLink'; +import { ExecutionResourceProvider } from './ExecutionResourceProvider'; +import { ExecutionLink } from './ExecutionLink'; +import OpenDrawer from './components/OpenDrawer'; export const WorkflowContext = React.createContext({}); @@ -13,6 +18,22 @@ export function useWorkflowContext() { return useContext(WorkflowContext); } +function WorkflowPane() { + return ( + + + + ); +}; + export const WorkflowProvider = (props) => { const ctx = useContext(PluginManagerContext); const { routes, components, ...others } = useContext(RouteSwitchContext); diff --git a/packages/plugins/workflow/src/client/WorkflowShortcut.tsx b/packages/plugins/workflow/src/client/WorkflowShortcut.tsx index 9b4e0346a..9cf1ba5d9 100644 --- a/packages/plugins/workflow/src/client/WorkflowShortcut.tsx +++ b/packages/plugins/workflow/src/client/WorkflowShortcut.tsx @@ -1,34 +1,12 @@ import React from 'react'; -import { Card } from 'antd'; import { PartitionOutlined } from '@ant-design/icons'; -import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; -import { PluginManager, SchemaComponent } from '@nocobase/client'; +import { PluginManager } from '@nocobase/client'; -import { workflowSchema } from './schemas/workflows'; -import { WorkflowLink } from './WorkflowLink'; -import { ExecutionResourceProvider } from './ExecutionResourceProvider'; -import { ExecutionLink } from './ExecutionLink'; import { lang } from './locale'; -import OpenDrawer from './components/OpenDrawer'; -export const WorkflowPane = () => { - return ( - - - - ); -}; export const WorkflowShortcut = () => { const history = useHistory(); diff --git a/packages/plugins/workflow/src/client/schemas/executions.tsx b/packages/plugins/workflow/src/client/schemas/executions.tsx index cd38163ca..0fd19c0e7 100644 --- a/packages/plugins/workflow/src/client/schemas/executions.tsx +++ b/packages/plugins/workflow/src/client/schemas/executions.tsx @@ -66,7 +66,7 @@ export const executionSchema = { action: 'list', params: { appends: ['workflow.id', 'workflow.title'], - pageSize: 50, + pageSize: 20, sort: ['-createdAt'], filter: {} }, diff --git a/packages/plugins/workflow/src/client/schemas/workflows.ts b/packages/plugins/workflow/src/client/schemas/workflows.ts index c4c46e944..8704fe0ca 100644 --- a/packages/plugins/workflow/src/client/schemas/workflows.ts +++ b/packages/plugins/workflow/src/client/schemas/workflows.ts @@ -92,7 +92,7 @@ export const workflowSchema: ISchema = { resource: 'workflows', action: 'list', params: { - pageSize: 50, + pageSize: 20, filter: { current: true },