fix(plugin-workflow): fix history drawer in workflow canvas (#1326)
This commit is contained in:
parent
6febdb041a
commit
c851e65459
@ -8,23 +8,45 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ActionContext,
|
ActionContext,
|
||||||
|
ResourceActionProvider,
|
||||||
SchemaComponent,
|
SchemaComponent,
|
||||||
useDocumentTitle,
|
useDocumentTitle,
|
||||||
useResourceActionContext,
|
useResourceActionContext,
|
||||||
useResourceContext
|
useResourceContext
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
|
|
||||||
import { FlowContext } from './FlowContext';
|
import { FlowContext, useFlowContext } from './FlowContext';
|
||||||
import { branchBlockClass, nodeCardClass, nodeMetaClass, workflowVersionDropdownClass } from './style';
|
import { branchBlockClass, nodeCardClass, nodeMetaClass, workflowVersionDropdownClass } from './style';
|
||||||
import { TriggerConfig } from './triggers';
|
import { TriggerConfig } from './triggers';
|
||||||
import { Branch } from './Branch';
|
import { Branch } from './Branch';
|
||||||
import { executionSchema } from './schemas/executions';
|
import { executionSchema } from './schemas/executions';
|
||||||
import { ExecutionLink } from './ExecutionLink';
|
import { ExecutionLink } from './ExecutionLink';
|
||||||
import { ExecutionResourceProvider } from './ExecutionResourceProvider';
|
|
||||||
import { lang } from './locale';
|
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 (
|
||||||
|
<ResourceActionProvider {...props} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function makeNodes(nodes): void {
|
function makeNodes(nodes): void {
|
||||||
const nodesMap = new Map();
|
const nodesMap = new Map();
|
||||||
nodes.forEach(item => nodesMap.set(item.id, item));
|
nodes.forEach(item => nodesMap.set(item.id, item));
|
||||||
@ -168,7 +190,7 @@ export function WorkflowCanvas() {
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
overlay={
|
overlay={
|
||||||
<Menu onClick={onMenuCommand}>
|
<Menu onClick={onMenuCommand}>
|
||||||
<Menu.Item key="history" disabled={!workflow.executed}>{lang('Execution history')}</Menu.Item>
|
<Menu.Item key="history" disabled={!workflow.allExecuted}>{lang('Execution history')}</Menu.Item>
|
||||||
<Menu.Item key="revision" disabled={!revisionable}>{lang('Copy to new version')}</Menu.Item>
|
<Menu.Item key="revision" disabled={!revisionable}>{lang('Copy to new version')}</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
import React, { useContext } from 'react';
|
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 { WorkflowPage } from './WorkflowPage';
|
||||||
import { WorkflowPane, WorkflowShortcut } from './WorkflowShortcut';
|
|
||||||
import { ExecutionPage } from './ExecutionPage';
|
import { ExecutionPage } from './ExecutionPage';
|
||||||
import { triggers } from './triggers';
|
import { triggers } from './triggers';
|
||||||
import { instructions } from './nodes';
|
import { instructions } from './nodes';
|
||||||
import { lang } from './locale';
|
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({});
|
export const WorkflowContext = React.createContext({});
|
||||||
|
|
||||||
@ -13,6 +18,22 @@ export function useWorkflowContext() {
|
|||||||
return useContext(WorkflowContext);
|
return useContext(WorkflowContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WorkflowPane() {
|
||||||
|
return (
|
||||||
|
<Card bordered={false}>
|
||||||
|
<SchemaComponent
|
||||||
|
schema={workflowSchema}
|
||||||
|
components={{
|
||||||
|
WorkflowLink,
|
||||||
|
ExecutionResourceProvider,
|
||||||
|
ExecutionLink,
|
||||||
|
OpenDrawer
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const WorkflowProvider = (props) => {
|
export const WorkflowProvider = (props) => {
|
||||||
const ctx = useContext(PluginManagerContext);
|
const ctx = useContext(PluginManagerContext);
|
||||||
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
||||||
|
@ -1,34 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card } from 'antd';
|
|
||||||
import { PartitionOutlined } from '@ant-design/icons';
|
import { PartitionOutlined } from '@ant-design/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
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 { lang } from './locale';
|
||||||
import OpenDrawer from './components/OpenDrawer';
|
|
||||||
|
|
||||||
|
|
||||||
export const WorkflowPane = () => {
|
|
||||||
return (
|
|
||||||
<Card bordered={false}>
|
|
||||||
<SchemaComponent
|
|
||||||
schema={workflowSchema}
|
|
||||||
components={{
|
|
||||||
WorkflowLink,
|
|
||||||
ExecutionResourceProvider,
|
|
||||||
ExecutionLink,
|
|
||||||
OpenDrawer
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const WorkflowShortcut = () => {
|
export const WorkflowShortcut = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -66,7 +66,7 @@ export const executionSchema = {
|
|||||||
action: 'list',
|
action: 'list',
|
||||||
params: {
|
params: {
|
||||||
appends: ['workflow.id', 'workflow.title'],
|
appends: ['workflow.id', 'workflow.title'],
|
||||||
pageSize: 50,
|
pageSize: 20,
|
||||||
sort: ['-createdAt'],
|
sort: ['-createdAt'],
|
||||||
filter: {}
|
filter: {}
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,7 @@ export const workflowSchema: ISchema = {
|
|||||||
resource: 'workflows',
|
resource: 'workflows',
|
||||||
action: 'list',
|
action: 'list',
|
||||||
params: {
|
params: {
|
||||||
pageSize: 50,
|
pageSize: 20,
|
||||||
filter: {
|
filter: {
|
||||||
current: true
|
current: true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user