fix(workflow): merge workflow providers
This commit is contained in:
parent
0348392037
commit
008a7f7f33
@ -47,7 +47,6 @@ export class Application {
|
|||||||
plugins: PluginCallback[] = [];
|
plugins: PluginCallback[] = [];
|
||||||
|
|
||||||
constructor(options: ApplicationOptions) {
|
constructor(options: ApplicationOptions) {
|
||||||
const { WorkflowPage, WorkflowRouteProvider, WorkflowShortcut } = require('../workflow');
|
|
||||||
this.apiClient = new APIClient({
|
this.apiClient = new APIClient({
|
||||||
baseURL: process.env.API_BASE_URL,
|
baseURL: process.env.API_BASE_URL,
|
||||||
headers: {
|
headers: {
|
||||||
@ -66,7 +65,6 @@ export class Application {
|
|||||||
RouteSchemaComponent,
|
RouteSchemaComponent,
|
||||||
SigninPage,
|
SigninPage,
|
||||||
SignupPage,
|
SignupPage,
|
||||||
WorkflowPage,
|
|
||||||
BlockTemplatePage,
|
BlockTemplatePage,
|
||||||
BlockTemplateDetails,
|
BlockTemplateDetails,
|
||||||
},
|
},
|
||||||
@ -77,7 +75,6 @@ export class Application {
|
|||||||
ACLShortcut,
|
ACLShortcut,
|
||||||
DesignableSwitch,
|
DesignableSwitch,
|
||||||
CollectionManagerShortcut,
|
CollectionManagerShortcut,
|
||||||
WorkflowShortcut,
|
|
||||||
SystemSettingsShortcut,
|
SystemSettingsShortcut,
|
||||||
SchemaTemplateShortcut,
|
SchemaTemplateShortcut,
|
||||||
FileStorageShortcut,
|
FileStorageShortcut,
|
||||||
@ -93,7 +90,7 @@ export class Application {
|
|||||||
this.use(AntdSchemaComponentProvider);
|
this.use(AntdSchemaComponentProvider);
|
||||||
this.use(ACLProvider);
|
this.use(ACLProvider);
|
||||||
this.use(RemoteDocumentTitleProvider);
|
this.use(RemoteDocumentTitleProvider);
|
||||||
this.use(WorkflowRouteProvider);
|
this.use(require('../workflow').WorkflowProvider);
|
||||||
for (const plugin of options.plugins) {
|
for (const plugin of options.plugins) {
|
||||||
const [component, props] = Array.isArray(plugin) ? plugin : [plugin];
|
const [component, props] = Array.isArray(plugin) ? plugin : [plugin];
|
||||||
this.use(component, props);
|
this.use(component, props);
|
||||||
|
29
packages/core/client/src/workflow/WorkflowProvider.tsx
Normal file
29
packages/core/client/src/workflow/WorkflowProvider.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import React, { useContext } from 'react';
|
||||||
|
import { PluginManagerContext } from '../plugin-manager';
|
||||||
|
import { RouteSwitchContext } from '../route-switch';
|
||||||
|
import { WorkflowPage } from './WorkflowPage';
|
||||||
|
import { WorkflowShortcut } from './WorkflowShortcut';
|
||||||
|
|
||||||
|
export const WorkflowProvider = (props) => {
|
||||||
|
const ctx = useContext(PluginManagerContext);
|
||||||
|
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
||||||
|
routes[1].routes.unshift({
|
||||||
|
type: 'route',
|
||||||
|
path: '/admin/plugins/workflows/:id',
|
||||||
|
component: 'WorkflowPage',
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<PluginManagerContext.Provider
|
||||||
|
value={{
|
||||||
|
components: {
|
||||||
|
...ctx?.components,
|
||||||
|
WorkflowShortcut,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RouteSwitchContext.Provider value={{ components: { ...components, WorkflowPage }, ...others, routes }}>
|
||||||
|
{props.children}
|
||||||
|
</RouteSwitchContext.Provider>
|
||||||
|
</PluginManagerContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
@ -1,12 +0,0 @@
|
|||||||
import React, { useContext } from 'react';
|
|
||||||
import { RouteSwitchContext } from '../route-switch';
|
|
||||||
|
|
||||||
export const WorkflowRouteProvider = (props) => {
|
|
||||||
const { routes, ...others } = useContext(RouteSwitchContext);
|
|
||||||
routes[1].routes.unshift({
|
|
||||||
type: 'route',
|
|
||||||
path: '/admin/plugins/workflows/:id',
|
|
||||||
component: 'WorkflowPage',
|
|
||||||
});
|
|
||||||
return <RouteSwitchContext.Provider value={{ ...others, routes }}>{props.children}</RouteSwitchContext.Provider>;
|
|
||||||
};
|
|
@ -1,5 +1,6 @@
|
|||||||
export * from './ExecutionResourceProvider';
|
export * from './ExecutionResourceProvider';
|
||||||
export * from './WorkflowLink';
|
export * from './WorkflowLink';
|
||||||
export * from './WorkflowPage';
|
export * from './WorkflowPage';
|
||||||
export * from './WorkflowRouteProvider';
|
export * from './WorkflowProvider';
|
||||||
export * from './WorkflowShortcut';
|
export * from './WorkflowShortcut';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user