From 246e06eb7a3bb279c74d55b0025afde22e114da5 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 27 Mar 2022 16:15:58 +0800 Subject: [PATCH] feat: workflow route provider --- packages/app/src/pages/index.tsx | 7 ++++--- .../client/src/workflow/WorkflowRouteProvider.tsx | 14 ++++++++++++++ packages/client/src/workflow/index.tsx | 10 ++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 packages/client/src/workflow/WorkflowRouteProvider.tsx diff --git a/packages/app/src/pages/index.tsx b/packages/app/src/pages/index.tsx index 050bd02b0..a72eb11b8 100644 --- a/packages/app/src/pages/index.tsx +++ b/packages/app/src/pages/index.tsx @@ -26,10 +26,10 @@ import { SignupPage, SystemSettingsProvider, SystemSettingsShortcut, - useRequest, + useRoutes, WorkflowPage, - WorkflowShortcut, - useRoutes + WorkflowRouteProvider, + WorkflowShortcut } from '@nocobase/client'; import { notification } from 'antd'; import 'antd/dist/antd.css'; @@ -97,6 +97,7 @@ const providers = [ ], AntdSchemaComponentProvider, ChinaRegionProvider, + WorkflowRouteProvider, [DocumentTitleProvider, { addonAfter: 'NocoBase' }], ]; diff --git a/packages/client/src/workflow/WorkflowRouteProvider.tsx b/packages/client/src/workflow/WorkflowRouteProvider.tsx new file mode 100644 index 000000000..83a4ecb1f --- /dev/null +++ b/packages/client/src/workflow/WorkflowRouteProvider.tsx @@ -0,0 +1,14 @@ +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/workflows/:id', + component: 'WorkflowPage', + }, + ); + return {props.children}; +}; diff --git a/packages/client/src/workflow/index.tsx b/packages/client/src/workflow/index.tsx index b85a387af..079f8b5e8 100644 --- a/packages/client/src/workflow/index.tsx +++ b/packages/client/src/workflow/index.tsx @@ -1,5 +1,7 @@ -export * from './WorkflowPage'; -export * from './WorkflowLink'; -export * from './WorkflowTable'; -export * from './WorkflowShortcut'; export * from './ExecutionResourceProvider'; +export * from './WorkflowLink'; +export * from './WorkflowPage'; +export * from './WorkflowRouteProvider'; +export * from './WorkflowShortcut'; +export * from './WorkflowTable'; +