From 3735d71e705d31d2e57b94bb02aca8438c559d86 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 21 Apr 2022 12:42:00 +0800 Subject: [PATCH] fix: change plugin routes --- .../route-switch/antd/admin-layout/index.tsx | 3 ++ .../schema-templates/BlockTemplateDetails.tsx | 2 +- .../SchemaTemplateManagerProvider.tsx | 4 +- .../SchemaTemplateShortcut.tsx | 2 +- .../schemas/uiSchemaTemplates.ts | 2 +- .../core/client/src/workflow/WorkflowLink.tsx | 2 +- .../core/client/src/workflow/WorkflowPage.tsx | 46 +++++++++---------- .../src/workflow/WorkflowRouteProvider.tsx | 12 ++--- .../plugins/ui-routes-storage/src/index.ts | 10 ++-- 9 files changed, 41 insertions(+), 42 deletions(-) diff --git a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx index 3471e3fee..d1843fbc1 100644 --- a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx +++ b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx @@ -101,6 +101,9 @@ const InternalAdminLayout = (props: any) => { return filterByACL(data, ctx); }} onSuccess={(data) => { + if (defaultSelectedUid && defaultSelectedUid.includes('/')) { + return; + } const schema = filterByACL(data?.data, ctx); if (defaultSelectedUid) { const s = findByUid(schema, defaultSelectedUid); diff --git a/packages/core/client/src/schema-templates/BlockTemplateDetails.tsx b/packages/core/client/src/schema-templates/BlockTemplateDetails.tsx index 30bc7ec34..5929c4837 100644 --- a/packages/core/client/src/schema-templates/BlockTemplateDetails.tsx +++ b/packages/core/client/src/schema-templates/BlockTemplateDetails.tsx @@ -76,7 +76,7 @@ export const BlockTemplateDetails = () => {
{ - history.push('/admin/block-templates'); + history.push('/admin/plugins/block-templates'); }} ghost={false} title={} diff --git a/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx b/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx index 6b4c990af..387300cfa 100644 --- a/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx +++ b/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx @@ -15,12 +15,12 @@ const SchemaTemplateRouteProvider = (props) => { routes[1].routes.unshift( { type: 'route', - path: '/admin/block-templates/:key', + path: '/admin/plugins/block-templates/:key', component: 'BlockTemplateDetails', }, { type: 'route', - path: '/admin/block-templates', + path: '/admin/plugins/block-templates', component: 'BlockTemplatePage', }, ); diff --git a/packages/core/client/src/schema-templates/SchemaTemplateShortcut.tsx b/packages/core/client/src/schema-templates/SchemaTemplateShortcut.tsx index 4bf7816ef..b561d822d 100644 --- a/packages/core/client/src/schema-templates/SchemaTemplateShortcut.tsx +++ b/packages/core/client/src/schema-templates/SchemaTemplateShortcut.tsx @@ -12,7 +12,7 @@ export const SchemaTemplateShortcut = () => { icon={} title={t('Block templates')} onClick={() => { - history.push('/admin/block-templates'); + history.push('/admin/plugins/block-templates'); }} /> ); diff --git a/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts b/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts index a2c83495f..166c6e688 100644 --- a/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts +++ b/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts @@ -75,7 +75,7 @@ export const uiSchemaTemplatesSchema: ISchema = { 'x-action': 'view', 'x-component': 'RecordLink', 'x-component-props': { - to: '/admin/block-templates/${record.key}', + to: '/admin/plugins/block-templates/${record.key}', }, }, edit: { diff --git a/packages/core/client/src/workflow/WorkflowLink.tsx b/packages/core/client/src/workflow/WorkflowLink.tsx index 220594725..f3ac5e16a 100644 --- a/packages/core/client/src/workflow/WorkflowLink.tsx +++ b/packages/core/client/src/workflow/WorkflowLink.tsx @@ -7,6 +7,6 @@ export const WorkflowLink = () => { const { id } = useRecord(); const { setVisible } = useActionContext(); return ( - setVisible(false)}>流程配置 + setVisible(false)}>流程配置 ); } diff --git a/packages/core/client/src/workflow/WorkflowPage.tsx b/packages/core/client/src/workflow/WorkflowPage.tsx index 6c15977ec..473eee015 100644 --- a/packages/core/client/src/workflow/WorkflowPage.tsx +++ b/packages/core/client/src/workflow/WorkflowPage.tsx @@ -1,13 +1,11 @@ +import { cx } from '@emotion/css'; +import { ISchema } from '@formily/react'; import React from 'react'; import { useRouteMatch } from 'react-router-dom'; -import { ISchema } from '@formily/react'; -import { cx } from '@emotion/css'; import { SchemaComponent } from '..'; -import { TriggerConfig } from './triggers'; -import { WorkflowCanvas } from './WorkflowCanvas' import { workflowPageClass } from './style'; - - +import { TriggerConfig } from './triggers'; +import { WorkflowCanvas } from './WorkflowCanvas'; const workflowCollection = { name: 'workflow', @@ -22,12 +20,12 @@ const workflowCollection = { 'x-component': 'Input', required: true, } as ISchema, - } - ] + }, + ], }; export const WorkflowPage = () => { - const { params } = useRouteMatch(); + const { params } = useRouteMatch(); return (
@@ -36,7 +34,7 @@ export const WorkflowPage = () => { schema={{ type: 'void', properties: { - provider: { + [`provider_${params.id}`]: { type: 'void', 'x-decorator': 'ResourceActionProvider', 'x-decorator-props': { @@ -47,14 +45,14 @@ export const WorkflowPage = () => { action: 'get', params: { filter: params, - appends: ['nodes'] - } - } + appends: ['nodes'], + }, + }, }, properties: { trigger: { type: 'void', - 'x-component': 'TriggerConfig' + 'x-component': 'TriggerConfig', }, nodes: { type: 'void', @@ -70,7 +68,7 @@ export const WorkflowPage = () => { uiSchema: { title: '节点名称', type: 'string', - 'x-component': 'Input' + 'x-component': 'Input', }, }, { @@ -82,23 +80,23 @@ export const WorkflowPage = () => { type: 'string', 'x-component': 'Select', required: true, - } - } - ] - } + }, + }, + ], + }, }, 'x-component': 'WorkflowCanvas', 'x-component-props': { // nodes - } - } - } + }, + }, + }, }, - } + }, }} components={{ TriggerConfig, - WorkflowCanvas + WorkflowCanvas, }} />
diff --git a/packages/core/client/src/workflow/WorkflowRouteProvider.tsx b/packages/core/client/src/workflow/WorkflowRouteProvider.tsx index 83a4ecb1f..e82bab153 100644 --- a/packages/core/client/src/workflow/WorkflowRouteProvider.tsx +++ b/packages/core/client/src/workflow/WorkflowRouteProvider.tsx @@ -3,12 +3,10 @@ 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', - }, - ); + routes[1].routes.unshift({ + type: 'route', + path: '/admin/plugins/workflows/:id', + component: 'WorkflowPage', + }); return {props.children}; }; diff --git a/packages/plugins/ui-routes-storage/src/index.ts b/packages/plugins/ui-routes-storage/src/index.ts index fd4bc4e17..096d9263f 100644 --- a/packages/plugins/ui-routes-storage/src/index.ts +++ b/packages/plugins/ui-routes-storage/src/index.ts @@ -39,11 +39,11 @@ export class UiRoutesStoragePlugin extends Plugin { title: 'NocoBase Admin', routes: [ // test... - { - type: 'route', - path: '/admin/workflows/:id', - component: 'WorkflowPage', - }, + // { + // type: 'route', + // path: '/admin/workflows/:id', + // component: 'WorkflowPage', + // }, // { // type: 'route', // path: '/admin/block-templates/:key',