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 {
|
||||
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 (
|
||||
<ResourceActionProvider {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function makeNodes(nodes): void {
|
||||
const nodesMap = new Map();
|
||||
nodes.forEach(item => nodesMap.set(item.id, item));
|
||||
@ -168,7 +190,7 @@ export function WorkflowCanvas() {
|
||||
<Dropdown
|
||||
overlay={
|
||||
<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>
|
||||
}
|
||||
|
@ -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 (
|
||||
<Card bordered={false}>
|
||||
<SchemaComponent
|
||||
schema={workflowSchema}
|
||||
components={{
|
||||
WorkflowLink,
|
||||
ExecutionResourceProvider,
|
||||
ExecutionLink,
|
||||
OpenDrawer
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export const WorkflowProvider = (props) => {
|
||||
const ctx = useContext(PluginManagerContext);
|
||||
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
||||
|
@ -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 (
|
||||
<Card bordered={false}>
|
||||
<SchemaComponent
|
||||
schema={workflowSchema}
|
||||
components={{
|
||||
WorkflowLink,
|
||||
ExecutionResourceProvider,
|
||||
ExecutionLink,
|
||||
OpenDrawer
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export const WorkflowShortcut = () => {
|
||||
const history = useHistory();
|
||||
|
@ -66,7 +66,7 @@ export const executionSchema = {
|
||||
action: 'list',
|
||||
params: {
|
||||
appends: ['workflow.id', 'workflow.title'],
|
||||
pageSize: 50,
|
||||
pageSize: 20,
|
||||
sort: ['-createdAt'],
|
||||
filter: {}
|
||||
},
|
||||
|
@ -92,7 +92,7 @@ export const workflowSchema: ISchema = {
|
||||
resource: 'workflows',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 50,
|
||||
pageSize: 20,
|
||||
filter: {
|
||||
current: true
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user