2022-09-18 14:10:01 +08:00
|
|
|
import { PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client';
|
2022-06-29 17:32:10 +08:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import { WorkflowPage } from './WorkflowPage';
|
2022-09-18 14:10:01 +08:00
|
|
|
import { WorkflowPane, WorkflowShortcut } from './WorkflowShortcut';
|
2022-10-30 11:54:14 +08:00
|
|
|
import { ExecutionPage } from './ExecutionPage';
|
2022-06-29 17:32:10 +08:00
|
|
|
|
|
|
|
export const WorkflowProvider = (props) => {
|
|
|
|
const ctx = useContext(PluginManagerContext);
|
|
|
|
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
|
|
|
routes[1].routes.unshift({
|
|
|
|
type: 'route',
|
2022-10-30 11:54:14 +08:00
|
|
|
path: '/admin/settings/workflow/workflows/:id',
|
2022-06-29 17:32:10 +08:00
|
|
|
component: 'WorkflowPage',
|
2022-10-30 11:54:14 +08:00
|
|
|
}, {
|
|
|
|
type: 'route',
|
|
|
|
path: '/admin/settings/workflow/executions/:id',
|
|
|
|
component: 'ExecutionPage',
|
2022-06-29 17:32:10 +08:00
|
|
|
});
|
|
|
|
return (
|
2022-09-18 14:10:01 +08:00
|
|
|
<SettingsCenterProvider
|
|
|
|
settings={{
|
|
|
|
workflow: {
|
|
|
|
icon: 'PartitionOutlined',
|
|
|
|
title: '{{t("Workflow")}}',
|
|
|
|
tabs: {
|
|
|
|
workflows: {
|
|
|
|
title: '{{t("Workflow")}}',
|
|
|
|
component: WorkflowPane,
|
|
|
|
},
|
|
|
|
},
|
2022-06-29 17:32:10 +08:00
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
2022-09-18 14:10:01 +08:00
|
|
|
<PluginManagerContext.Provider
|
|
|
|
value={{
|
|
|
|
components: {
|
|
|
|
...ctx?.components,
|
|
|
|
WorkflowShortcut,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
2022-10-30 11:54:14 +08:00
|
|
|
<RouteSwitchContext.Provider value={{ components: { ...components, WorkflowPage, ExecutionPage }, ...others, routes }}>
|
2022-09-18 14:10:01 +08:00
|
|
|
{props.children}
|
|
|
|
</RouteSwitchContext.Provider>
|
|
|
|
</PluginManagerContext.Provider>
|
|
|
|
</SettingsCenterProvider>
|
2022-06-29 17:32:10 +08:00
|
|
|
);
|
|
|
|
};
|