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);
}}
onSuccess={(data) => {
if (defaultSelectedUid && defaultSelectedUid.includes('/')) {
return;
}
const schema = filterByACL(data?.data, ctx);
if (defaultSelectedUid) {
const s = findByUid(schema, defaultSelectedUid);

View File

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

View File

@ -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',
},
);

View File

@ -12,7 +12,7 @@ export const SchemaTemplateShortcut = () => {
icon={<LayoutOutlined />}
title={t('Block templates')}
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-component': 'RecordLink',
'x-component-props': {
to: '/admin/block-templates/${record.key}',
to: '/admin/plugins/block-templates/${record.key}',
},
},
edit: {

View File

@ -7,6 +7,6 @@ export const WorkflowLink = () => {
const { id } = useRecord();
const { setVisible } = useActionContext();
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 { 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<any>();
return (
<div className={cx(workflowPageClass)}>
@ -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,
}}
/>
</div>

View File

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

View File

@ -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',