fix: change plugin routes

This commit is contained in:
chenos 2022-04-21 12:42:00 +08:00
parent be235786d0
commit 3735d71e70
9 changed files with 41 additions and 42 deletions

View File

@ -101,6 +101,9 @@ const InternalAdminLayout = (props: any) => {
return filterByACL(data, ctx); return filterByACL(data, ctx);
}} }}
onSuccess={(data) => { onSuccess={(data) => {
if (defaultSelectedUid && defaultSelectedUid.includes('/')) {
return;
}
const schema = filterByACL(data?.data, ctx); const schema = filterByACL(data?.data, ctx);
if (defaultSelectedUid) { if (defaultSelectedUid) {
const s = findByUid(schema, defaultSelectedUid); const s = findByUid(schema, defaultSelectedUid);

View File

@ -76,7 +76,7 @@ export const BlockTemplateDetails = () => {
<div> <div>
<AntdPageHeader <AntdPageHeader
onBack={() => { onBack={() => {
history.push('/admin/block-templates'); history.push('/admin/plugins/block-templates');
}} }}
ghost={false} ghost={false}
title={<EditableTitle filterByTk={key} title={data?.data?.name} />} title={<EditableTitle filterByTk={key} title={data?.data?.name} />}

View File

@ -15,12 +15,12 @@ const SchemaTemplateRouteProvider = (props) => {
routes[1].routes.unshift( routes[1].routes.unshift(
{ {
type: 'route', type: 'route',
path: '/admin/block-templates/:key', path: '/admin/plugins/block-templates/:key',
component: 'BlockTemplateDetails', component: 'BlockTemplateDetails',
}, },
{ {
type: 'route', type: 'route',
path: '/admin/block-templates', path: '/admin/plugins/block-templates',
component: 'BlockTemplatePage', component: 'BlockTemplatePage',
}, },
); );

View File

@ -12,7 +12,7 @@ export const SchemaTemplateShortcut = () => {
icon={<LayoutOutlined />} icon={<LayoutOutlined />}
title={t('Block templates')} title={t('Block templates')}
onClick={() => { onClick={() => {
history.push('/admin/block-templates'); history.push('/admin/plugins/block-templates');
}} }}
/> />
); );

View File

@ -75,7 +75,7 @@ export const uiSchemaTemplatesSchema: ISchema = {
'x-action': 'view', 'x-action': 'view',
'x-component': 'RecordLink', 'x-component': 'RecordLink',
'x-component-props': { 'x-component-props': {
to: '/admin/block-templates/${record.key}', to: '/admin/plugins/block-templates/${record.key}',
}, },
}, },
edit: { edit: {

View File

@ -7,6 +7,6 @@ export const WorkflowLink = () => {
const { id } = useRecord(); const { id } = useRecord();
const { setVisible } = useActionContext(); const { setVisible } = useActionContext();
return ( return (
<Link to={`/admin/workflows/${id}`} onClick={() => setVisible(false)}></Link> <Link to={`/admin/plugins/workflows/${id}`} onClick={() => setVisible(false)}></Link>
); );
} }

View File

@ -1,13 +1,11 @@
import { cx } from '@emotion/css';
import { ISchema } from '@formily/react';
import React from 'react'; import React from 'react';
import { useRouteMatch } from 'react-router-dom'; import { useRouteMatch } from 'react-router-dom';
import { ISchema } from '@formily/react';
import { cx } from '@emotion/css';
import { SchemaComponent } from '..'; import { SchemaComponent } from '..';
import { TriggerConfig } from './triggers';
import { WorkflowCanvas } from './WorkflowCanvas'
import { workflowPageClass } from './style'; import { workflowPageClass } from './style';
import { TriggerConfig } from './triggers';
import { WorkflowCanvas } from './WorkflowCanvas';
const workflowCollection = { const workflowCollection = {
name: 'workflow', name: 'workflow',
@ -22,12 +20,12 @@ const workflowCollection = {
'x-component': 'Input', 'x-component': 'Input',
required: true, required: true,
} as ISchema, } as ISchema,
} },
] ],
}; };
export const WorkflowPage = () => { export const WorkflowPage = () => {
const { params } = useRouteMatch(); const { params } = useRouteMatch<any>();
return ( return (
<div className={cx(workflowPageClass)}> <div className={cx(workflowPageClass)}>
@ -36,7 +34,7 @@ export const WorkflowPage = () => {
schema={{ schema={{
type: 'void', type: 'void',
properties: { properties: {
provider: { [`provider_${params.id}`]: {
type: 'void', type: 'void',
'x-decorator': 'ResourceActionProvider', 'x-decorator': 'ResourceActionProvider',
'x-decorator-props': { 'x-decorator-props': {
@ -47,14 +45,14 @@ export const WorkflowPage = () => {
action: 'get', action: 'get',
params: { params: {
filter: params, filter: params,
appends: ['nodes'] appends: ['nodes'],
} },
} },
}, },
properties: { properties: {
trigger: { trigger: {
type: 'void', type: 'void',
'x-component': 'TriggerConfig' 'x-component': 'TriggerConfig',
}, },
nodes: { nodes: {
type: 'void', type: 'void',
@ -70,7 +68,7 @@ export const WorkflowPage = () => {
uiSchema: { uiSchema: {
title: '节点名称', title: '节点名称',
type: 'string', type: 'string',
'x-component': 'Input' 'x-component': 'Input',
}, },
}, },
{ {
@ -82,23 +80,23 @@ export const WorkflowPage = () => {
type: 'string', type: 'string',
'x-component': 'Select', 'x-component': 'Select',
required: true, required: true,
} },
} },
] ],
} },
}, },
'x-component': 'WorkflowCanvas', 'x-component': 'WorkflowCanvas',
'x-component-props': { 'x-component-props': {
// nodes // nodes
} },
} },
} },
}, },
} },
}} }}
components={{ components={{
TriggerConfig, TriggerConfig,
WorkflowCanvas WorkflowCanvas,
}} }}
/> />
</div> </div>

View File

@ -3,12 +3,10 @@ import { RouteSwitchContext } from '../route-switch';
export const WorkflowRouteProvider = (props) => { export const WorkflowRouteProvider = (props) => {
const { routes, ...others } = useContext(RouteSwitchContext); const { routes, ...others } = useContext(RouteSwitchContext);
routes[1].routes.unshift( routes[1].routes.unshift({
{ type: 'route',
type: 'route', path: '/admin/plugins/workflows/:id',
path: '/admin/workflows/:id', component: 'WorkflowPage',
component: 'WorkflowPage', });
},
);
return <RouteSwitchContext.Provider value={{ ...others, routes }}>{props.children}</RouteSwitchContext.Provider>; return <RouteSwitchContext.Provider value={{ ...others, routes }}>{props.children}</RouteSwitchContext.Provider>;
}; };

View File

@ -39,11 +39,11 @@ export class UiRoutesStoragePlugin extends Plugin {
title: 'NocoBase Admin', title: 'NocoBase Admin',
routes: [ routes: [
// test... // test...
{ // {
type: 'route', // type: 'route',
path: '/admin/workflows/:id', // path: '/admin/workflows/:id',
component: 'WorkflowPage', // component: 'WorkflowPage',
}, // },
// { // {
// type: 'route', // type: 'route',
// path: '/admin/block-templates/:key', // path: '/admin/block-templates/:key',