refactor(PluginManager): remove useless code (#2022)

* refactor(PluginManager): remove useless code

* chore: fix build error
This commit is contained in:
被雨水过滤的空气-Rairn 2023-06-14 09:35:09 +08:00 committed by GitHub
parent 4ac01b28db
commit 58840e5fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 44 additions and 802 deletions

View File

@ -1,31 +1,10 @@
import { LockOutlined } from '@ant-design/icons';
import { ISchema } from '@formily/react';
import { uid } from '@formily/shared';
import { Card } from 'antd';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { PluginManager } from '../plugin-manager';
import { ActionContextProvider, SchemaComponent } from '../schema-component';
import React from 'react';
import { SchemaComponent } from '../schema-component';
import * as components from './Configuration';
const schema: ISchema = {
type: 'object',
properties: {
[uid()]: {
'x-component': 'Action.Drawer',
type: 'void',
title: '{{t("Roles & Permissions")}}',
properties: {
hello1: {
type: 'void',
'x-component': 'RoleTable',
},
},
},
},
};
const schema2: ISchema = {
type: 'object',
properties: {
@ -42,34 +21,3 @@ export const ACLPane = () => {
</Card>
);
};
export const ACLShortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<LockOutlined />}
title={t('Roles & Permissions')}
onClick={() => {
history.push('/admin/settings/acl/roles');
}}
/>
);
};
export const ACLShortcut2 = () => {
const [visible, setVisible] = useState(false);
const { t } = useTranslation();
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<LockOutlined />}
title={t('Roles & Permissions')}
onClick={() => {
setVisible(true);
}}
/>
<SchemaComponent components={components} schema={schema} />
</ActionContextProvider>
);
};

View File

@ -1,17 +1,14 @@
import {
ACLShortcut,
AdminLayout,
AntdConfigProvider,
AntdSchemaComponentProvider,
APIClientProvider,
AuthLayout,
CollectionManagerProvider,
CollectionManagerShortcut,
compose,
DesignableSwitch,
DocumentTitleProvider,
i18n,
PluginManagerProvider,
RouteSchemaComponent,
RouteSwitch,
RouteSwitchProvider,
@ -20,7 +17,6 @@ import {
SigninPage,
SignupPage,
SystemSettingsProvider,
SystemSettingsShortcut,
useRequest,
} from '@nocobase/client';
import { Spin } from 'antd';
@ -36,10 +32,7 @@ const providers = [
[I18nextProvider, { i18n }],
[AntdConfigProvider, { remoteLocale: true }],
SystemSettingsProvider,
[
PluginManagerProvider,
{ components: { ACLShortcut, DesignableSwitch, CollectionManagerShortcut, SystemSettingsShortcut } },
],
[{ components: { DesignableSwitch } }],
[SchemaComponentProvider, { components: { Link, NavLink } }],
CollectionManagerProvider,
AntdSchemaComponentProvider,

View File

@ -1,33 +1,28 @@
import { DatabaseOutlined } from '@ant-design/icons';
import { ISchema } from '@formily/react';
import { uid } from '@formily/shared';
import { Card } from 'antd';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { PluginManager } from '../plugin-manager';
import { ActionContextProvider, SchemaComponent } from '../schema-component';
import React from 'react';
import { SchemaComponent } from '../schema-component';
import {
AddCategory,
AddCategoryAction,
AddCollection,
AddCollectionAction,
AddCollectionField,
AddFieldAction,
ConfigurationTable,
EditFieldAction,
EditCollectionField,
OverridingFieldAction,
OverridingCollectionField,
ViewCollectionField,
ViewFieldAction,
AddCollection,
AddCollectionAction,
AddCategoryAction,
AddCategory,
EditCollection,
EditCollectionAction,
ConfigurationTabs,
EditCategory,
EditCategoryAction,
EditCollection,
EditCollectionAction,
EditCollectionField,
EditFieldAction,
OverridingCollectionField,
OverridingFieldAction,
SyncFieldsAction,
SyncFieldsActionCom,
ViewCollectionField,
ViewFieldAction,
} from './Configuration';
import { CollectionCategroriesProvider } from './CollectionManagerProvider';
@ -90,48 +85,3 @@ export const CollectionManagerPane = () => {
// </Card>
);
};
export const CollectionManagerShortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={t('Collections & Fields')}
onClick={() => {
history.push('/admin/settings/collection-manager/collections');
}}
/>
);
};
export const CollectionManagerShortcut2 = () => {
const [visible, setVisible] = useState(false);
const { t } = useTranslation();
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={t('Collections & Fields')}
onClick={() => {
setVisible(true);
}}
/>
<SchemaComponent
schema={schema}
components={{
ConfigurationTable,
ConfigurationTabs,
AddFieldAction,
EditFieldAction,
OverridingFieldAction,
ViewFieldAction,
AddCollectionAction,
EditCollectionAction,
AddCategoryAction,
EditCategoryAction,
}}
/>
</ActionContextProvider>
);
};

View File

@ -1,157 +0,0 @@
import { SettingOutlined } from '@ant-design/icons';
import { css } from '@emotion/css';
import { ConfigProvider, Menu, MenuItemProps, Tooltip } from 'antd';
import cls from 'classnames';
import { get } from 'lodash';
import React, { createContext, useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { useACLRoleContext } from '../acl/ACLProvider';
import { PluginManagerContext } from './context';
export const usePrefixCls = (
tag?: string,
props?: {
prefixCls?: string;
},
) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
return getPrefixCls(tag, props?.prefixCls);
};
type PluginManagerType = {
Toolbar?: React.FC<ToolbarProps> & {
Item?: React.FC<MenuItemProps & { selected?: boolean; subtitle?: string }>;
};
};
export const PluginManager: PluginManagerType = () => null;
const ToolbarItemContext = createContext<ToolbarItemProps>(null);
interface ToolbarProps {
items?: ToolbarItemProps[];
}
interface ToolbarItemProps {
component: string;
pin?: boolean;
}
const splitItems = (items: ToolbarItemProps[]) => {
const pinned = [];
const unpinned = [];
for (const item of items) {
if (item.pin) {
pinned.push(item);
} else {
unpinned.push(item);
}
}
return [pinned, unpinned];
};
PluginManager.Toolbar = (props: ToolbarProps) => {
const { components } = useContext(PluginManagerContext);
const { items = [] } = props;
const [pinned, unpinned] = splitItems(items);
const { t } = useTranslation();
const history = useHistory();
return (
<div style={{ display: 'inline-block' }}>
<Menu style={{ width: '100%' }} selectable={false} mode={'horizontal'} theme={'dark'}>
{pinned.map((item, index) => {
const Action = get(components, item.component);
return (
Action && (
<ToolbarItemContext.Provider key={index} value={item}>
<Action />
</ToolbarItemContext.Provider>
)
);
})}
{unpinned.length > 0 && (
<Menu.SubMenu popupClassName={'pm-sub-menu'} key={'more'} title={<SettingOutlined />}>
{unpinned.map((item, index) => {
const Action = get(components, item.component);
return (
Action && (
<ToolbarItemContext.Provider key={index} value={item}>
<Action />
</ToolbarItemContext.Provider>
)
);
})}
{unpinned.length > 0 && <Menu.Divider key={'divider'}></Menu.Divider>}
<Menu.Item
key={'plugins'}
onClick={() => {
history.push('/admin/settings');
}}
icon={<SettingOutlined />}
>
{t('All plugin settings')}
</Menu.Item>
</Menu.SubMenu>
)}
</Menu>
</div>
);
};
PluginManager.Toolbar.Item = (props) => {
const item = useContext(ToolbarItemContext);
const { selected, icon, title, subtitle, ...others } = props;
const prefix = usePrefixCls();
const className = cls({ [`${prefix}-menu-item-selected`]: selected });
if (item.pin) {
const subtitleComponent = subtitle && (
<div
className={css`
font-size: 12px;
color: #999;
`}
>
{subtitle}
</div>
);
const titleComponent = (
<div>
<div>{title}</div>
{subtitleComponent}
</div>
);
return title ? (
<Tooltip title={titleComponent}>
<Menu.Item {...others} className={className} eventKey={item.component}>
{icon}
</Menu.Item>
</Tooltip>
) : (
<Menu.Item {...others} className={className} eventKey={item.component}>
{icon}
</Menu.Item>
);
}
return (
<Menu.Item {...others} className={className} eventKey={item.component} icon={icon}>
{title}
</Menu.Item>
);
};
export const RemotePluginManagerToolbar = () => {
const { allowAll, snippets } = useACLRoleContext();
const getSnippetsAllow = (aclKey) => {
return allowAll || snippets?.includes(aclKey);
};
const items = [
{ component: 'DesignableSwitch', pin: true, isAllow: getSnippetsAllow('ui.*') },
{ component: 'PluginManagerLink', pin: true, isAllow: getSnippetsAllow('pm') },
{ component: 'SettingsCenterDropdown', pin: true, isAllow: getSnippetsAllow('pm.*') },
// ...data?.data,
];
return <PluginManager.Toolbar items={items.filter((v) => v.isAllow)} />;
};

View File

@ -1,7 +0,0 @@
import React from 'react';
import { PluginManagerContext } from './context';
export const PluginManagerProvider: React.FC<any> = (props) => {
const { components, children } = props;
return <PluginManagerContext.Provider value={{ components }}>{children}</PluginManagerContext.Provider>;
};

View File

@ -1,34 +0,0 @@
import React from 'react';
import { Action, PluginManager, PluginManagerProvider, SchemaComponentProvider } from '@nocobase/client';
import * as plugins from './plugins';
export default () => {
return (
<SchemaComponentProvider components={{ Action }}>
<PluginManagerProvider components={plugins}>
<PluginManager.Toolbar
items={[
{
component: 'Plugin1.ToolbarItem',
pin: true,
},
{
component: 'Plugin2.ToolbarItem',
pin: true,
},
{
component: 'Plugin3.ToolbarItem',
pin: true,
},
{
component: 'Plugin4.ToolbarItem',
},
{
component: 'Plugin5.ToolbarItem',
},
]}
/>
</PluginManagerProvider>
</SchemaComponentProvider>
);
};

View File

@ -1,5 +0,0 @@
export * from './plugin1';
export * from './plugin2';
export * from './plugin3';
export * from './plugin4';
export * from './plugin5';

View File

@ -1,16 +0,0 @@
import React from 'react';
import { DatabaseOutlined } from '@ant-design/icons';
import { PluginManager } from '@nocobase/client';
export const Plugin1 = () => null;
Plugin1.ToolbarItem = () => {
return (
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={'Plugin1'}
onClick={() => {
alert('Plugin1');
}}
/>
);
};

View File

@ -1,65 +0,0 @@
import { VerifiedOutlined } from '@ant-design/icons';
import { ISchema, useForm } from '@formily/react';
import { ActionContextProvider, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client';
import React, { useState } from 'react';
const useCloseAction = () => {
const { setVisible } = useActionContext();
const form = useForm();
return {
async run() {
setVisible(false);
form.submit((values) => {
console.log(values);
});
},
};
};
const schema: ISchema = {
type: 'object',
properties: {
drawer1: {
'x-component': 'Action.Drawer',
type: 'void',
title: 'Drawer Title',
properties: {
hello1: {
'x-content': 'Hello',
title: 'T1',
},
footer1: {
'x-component': 'Action.Drawer.Footer',
type: 'void',
properties: {
close1: {
title: 'Close',
'x-component': 'Action',
'x-component-props': {
useAction: '{{ useCloseAction }}',
},
},
},
},
},
},
},
};
export const Plugin2 = () => null;
Plugin2.ToolbarItem = () => {
const [visible, setVisible] = useState(false);
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<VerifiedOutlined />}
title={'Plugin2'}
onClick={() => {
setVisible(true);
}}
/>
<SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContextProvider>
);
};

View File

@ -1,17 +0,0 @@
import { Menu } from 'antd';
import React from 'react';
import { SaveOutlined, KeyOutlined, DatabaseOutlined, VerifiedOutlined, NotificationOutlined } from '@ant-design/icons';
import { PluginManager } from '@nocobase/client';
export const Plugin3 = () => null;
Plugin3.ToolbarItem = () => {
return (
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={'Plugin3'}
onClick={() => {
alert('Plugin3');
}}
/>
);
};

View File

@ -1,65 +0,0 @@
import { VerifiedOutlined } from '@ant-design/icons';
import { ISchema, useForm } from '@formily/react';
import { ActionContextProvider, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client';
import React, { useState } from 'react';
const useCloseAction = () => {
const { setVisible } = useActionContext();
const form = useForm();
return {
async run() {
setVisible(false);
form.submit((values) => {
console.log(values);
});
},
};
};
const schema: ISchema = {
type: 'object',
properties: {
drawer1: {
'x-component': 'Action.Drawer',
type: 'void',
title: 'Drawer Title',
properties: {
hello1: {
'x-content': 'Hello',
title: 'T1',
},
footer1: {
'x-component': 'Action.Drawer.Footer',
type: 'void',
properties: {
close1: {
title: 'Close',
'x-component': 'Action',
'x-component-props': {
useAction: '{{ useCloseAction }}',
},
},
},
},
},
},
},
};
export const Plugin4 = () => null;
Plugin4.ToolbarItem = () => {
const [visible, setVisible] = useState(false);
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<VerifiedOutlined />}
title={'Plugin4'}
onClick={() => {
setVisible(true);
}}
/>
<SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContextProvider>
);
};

View File

@ -1,17 +0,0 @@
import { Menu } from 'antd';
import React from 'react';
import { SaveOutlined, KeyOutlined, DatabaseOutlined, VerifiedOutlined, NotificationOutlined } from '@ant-design/icons';
import { PluginManager } from '@nocobase/client';
export const Plugin5 = () => null;
Plugin5.ToolbarItem = () => {
return (
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={'Plugin5'}
onClick={() => {
alert('Plugin5');
}}
/>
);
};

View File

@ -1,59 +0,0 @@
---
nav:
path: /client
group:
path: /client
---
# PluginManager
## PluginManagerProvider
## PluginManager.Toolbar
插件管理器的工具栏,用于便捷的展示所有插件,不常用的可折叠显示。
<code src="./demos/demo1.tsx"/>
## PluginManager.Toolbar.Item
工具栏项,各个插件都可以配置自己的 `PluginManager.Toolbar.Item`
- `icon` pin 时,只显示 icon
- `title` pin 时title 以 tooltip 的方式显示
最简单的示例
```tsx | pure
Plugin1.ToolbarItem = () => {
return (
<PluginManager.Toolbar.Item
icon={<DatabaseOutlined />}
title={'Plugin1'}
onClick={() => {
alert('Plugin1');
}}
/>
);
};
```
弹出抽屉
```tsx | pure
Plugin2.ToolbarItem = () => {
const [visible, setVisible] = useState(false);
return (
<ActionContext.Provider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<VerifiedOutlined />}
title={'Plugin2'}
onClick={() => {
setVisible(true);
}}
/>
<SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContext.Provider>
);
};
```

View File

@ -1,4 +1,3 @@
export * from './context';
export * from './PinnedPluginListProvider';
export * from './PluginManager';
export * from './PluginManagerProvider';
export * from './context';

View File

@ -1,19 +0,0 @@
import { LayoutOutlined } from '@ant-design/icons';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { PluginManager } from '../plugin-manager';
export const SchemaTemplateShortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<LayoutOutlined />}
title={t('Block templates')}
onClick={() => {
history.push('/admin/settings/block-templates/list');
}}
/>
);
};

View File

@ -1,4 +1,4 @@
export * from './BlockTemplateDetails';
export * from './BlockTemplatePage';
export * from './SchemaTemplateManagerProvider';
export * from './SchemaTemplateShortcut';

View File

@ -1,15 +1,13 @@
import { SettingOutlined } from '@ant-design/icons';
import { ISchema, useForm } from '@formily/react';
import { uid } from '@formily/shared';
import { Card, message } from 'antd';
import cloneDeep from 'lodash/cloneDeep';
import React, { useState } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { useSystemSettings } from '.';
import { i18n, PluginManager, useAPIClient, useRequest } from '..';
import { i18n, useAPIClient, useRequest } from '..';
import locale from '../locale';
import { ActionContextProvider, SchemaComponent, useActionContext } from '../schema-component';
import { SchemaComponent, useActionContext } from '../schema-component';
const langs = Object.keys(locale).map((lang) => {
return {
@ -281,38 +279,3 @@ export const SystemSettingsPane = () => {
</Card>
);
};
export const SystemSettingsShortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<SettingOutlined />}
title={t('System settings')}
onClick={() => {
history.push('/admin/settings/system-settings/system-settings');
}}
/>
);
};
export const SystemSettingsShortcut2 = () => {
const [visible, setVisible] = useState(false);
const { t } = useTranslation();
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
eventKey={'ACLAction'}
onClick={() => {
setVisible(true);
}}
icon={<SettingOutlined />}
title={t('System settings')}
/>
<SchemaComponent
scope={{ useSaveSystemSettingsValues, useSystemSettingsValues, useCloseAction }}
schema={schema}
/>
</ActionContextProvider>
);
};

View File

@ -2,11 +2,8 @@ import {
AntdSchemaComponentProvider,
APIClient,
APIClientProvider,
PluginManager,
PluginManagerProvider,
SchemaComponentProvider,
SystemSettingsProvider,
SystemSettingsShortcut,
useSystemSettings,
} from '@nocobase/client';
import MockAdapter from 'axios-mock-adapter';
@ -38,17 +35,7 @@ export default () => {
<SystemSettingsProvider>
<SchemaComponentProvider>
<AntdSchemaComponentProvider>
<PluginManagerProvider components={{ SystemSettingsShortcut }}>
<PluginManager.Toolbar
items={[
{
component: 'SystemSettingsShortcut',
pin: true,
},
]}
/>
<Demo />
</PluginManagerProvider>
<Demo />
</AntdSchemaComponentProvider>
</SchemaComponentProvider>
</SystemSettingsProvider>

View File

@ -194,18 +194,6 @@ export class ClientPlugin extends Plugin {
this.app.resource({
name: 'plugins',
actions: {
// TODO: 临时
async getPinned(ctx, next) {
ctx.body = [
{ component: 'CollectionManagerShortcut' },
{ component: 'ACLShortcut' },
{ component: 'WorkflowShortcut' },
{ component: 'SchemaTemplateShortcut' },
{ component: 'SystemSettingsShortcut' },
{ component: 'FileStorageShortcut' },
];
await next();
},
async getInfo(ctx, next) {
const lang = await getLang(ctx);
const { filterByTk } = ctx.action.params;

View File

@ -1,39 +0,0 @@
import { FileOutlined } from '@ant-design/icons';
import { uid } from '@formily/shared';
import { ActionContextProvider, PluginManager, SchemaComponent } from '@nocobase/client';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { storageSchema } from './schemas/storage';
import { StorageOptions } from './StorageOptions';
const schema = {
type: 'object',
properties: {
[uid()]: {
'x-component': 'Action.Drawer',
type: 'void',
title: '{{t("File manager")}}',
properties: {
storageSchema,
},
},
},
};
export const FileStorageShortcut = () => {
const [visible, setVisible] = useState(false);
const { t } = useTranslation();
return (
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
eventKey={'FileStorage'}
onClick={() => {
setVisible(true);
}}
icon={<FileOutlined />}
title={t('File manager')}
/>
<SchemaComponent components={{ StorageOptions }} schema={schema} />
</ActionContextProvider>
);
};

View File

@ -12,12 +12,11 @@ import {
import { forEach } from '@nocobase/utils/client';
import React, { useContext } from 'react';
import { FileStoragePane } from './FileStorage';
import { FileStorageShortcut } from './FileStorageShortcut';
import * as hooks from './hooks';
import * as initializers from './initializers';
import * as templates from './templates';
import { NAMESPACE } from './locale';
import { attachment } from './interfaces/attachment';
import { NAMESPACE } from './locale';
import * as templates from './templates';
// 注册之后就可以在 Crete collection 按钮中选择创建了
forEach(templates, (template, key: string) => {
@ -71,7 +70,6 @@ export default function (props) {
value={{
components: {
...ctx?.components,
FileStorageShortcut,
},
}}
>

View File

@ -5,7 +5,7 @@ import {
SettingsCenterProvider,
} from '@nocobase/client';
import React, { useContext } from 'react';
import { GraphCollectionPane, GraphCollectionShortcut } from './GraphCollectionShortcut';
import { GraphCollectionPane } from './GraphCollectionShortcut';
import { useGCMTranslation } from './utils';
export const GraphCollectionProvider = React.memo((props) => {
@ -28,7 +28,6 @@ export const GraphCollectionProvider = React.memo((props) => {
value={{
components: {
...ctx?.components,
GraphCollectionShortcut,
},
}}
>

View File

@ -1,12 +1,10 @@
import { DeleteOutlined, PartitionOutlined } from '@ant-design/icons';
import { DeleteOutlined } from '@ant-design/icons';
import { css } from '@emotion/css';
import { uid } from '@formily/shared';
import { PluginManager, SchemaComponent, useActionContext, useRequest } from '@nocobase/client';
import { SchemaComponent, useActionContext, useRequest } from '@nocobase/client';
import React, { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { useCreateActionAndRefreshCM } from './action-hooks';
import { GraphDrawPage } from './GraphDrawPage';
import { useGCMTranslation } from './utils';
import { useCreateActionAndRefreshCM } from './action-hooks';
const useCollectionValues = (options) => {
const { visible } = useActionContext();
@ -142,17 +140,3 @@ export const GraphCollectionPane = () => {
</div>
);
};
export const GraphCollectionShortcut = () => {
const { t } = useGCMTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<PartitionOutlined />}
title={t('Graph Collection')}
onClick={() => {
history.push('/admin/settings/graph/collections');
}}
/>
);
};

View File

@ -1,20 +0,0 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { CheckCircleOutlined } from '@ant-design/icons';
import { PluginManager } from '@nocobase/client';
import { NAMESPACE } from './locale';
export const Shortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
icon={<CheckCircleOutlined />}
title={t('Verification', { ns: NAMESPACE })}
onClick={() => {
history.push('/admin/settings/verification/providers');
}}
/>
);
};

View File

@ -1,5 +1,3 @@
import React, { useContext } from 'react';
import { Card } from 'antd';
import {
CollectionManagerContext,
PluginManagerContext,
@ -7,24 +5,25 @@ import {
SchemaComponent,
SchemaComponentOptions,
SettingsCenterProvider,
registerField,
useCollectionDataSource,
useCollectionDataSource
} from '@nocobase/client';
import { Card } from 'antd';
import React, { useContext } from 'react';
import { WorkflowPage } from './WorkflowPage';
import { ExecutionPage } from './ExecutionPage';
import { triggers } from './triggers';
import { instructions } from './nodes';
import { lang } from './locale';
import { workflowSchema } from './schemas/workflows';
import { WorkflowLink } from './WorkflowLink';
import { ExecutionResourceProvider } from './ExecutionResourceProvider';
import { ExecutionLink } from './ExecutionLink';
import { ExecutionPage } from './ExecutionPage';
import { ExecutionResourceProvider } from './ExecutionResourceProvider';
import { WorkflowLink } from './WorkflowLink';
import { WorkflowPage } from './WorkflowPage';
import { DynamicExpression } from './components/DynamicExpression';
import OpenDrawer from './components/OpenDrawer';
import expressionField from './interfaces/expression';
import { lang } from './locale';
import { instructions } from './nodes';
import { WorkflowTodo } from './nodes/manual/WorkflowTodo';
import { WorkflowTodoBlockInitializer } from './nodes/manual/WorkflowTodoBlockInitializer';
import { DynamicExpression } from './components/DynamicExpression';
import expressionField from './interfaces/expression';
import { workflowSchema } from './schemas/workflows';
import { triggers } from './triggers';
// registerField(expressionField.group, 'expression', expressionField);
@ -87,7 +86,6 @@ export const WorkflowProvider = (props) => {
value={{
components: {
...pmCtx?.components,
// WorkflowShortcut,
},
}}
>

View File

@ -1,21 +0,0 @@
import React from 'react';
import { PartitionOutlined } from '@ant-design/icons';
import { useHistory } from 'react-router-dom';
import { PluginManager } from '@nocobase/client';
import { lang } from './locale';
export const WorkflowShortcut = () => {
const history = useHistory();
return (
<PluginManager.Toolbar.Item
key="workflow"
icon={<PartitionOutlined />}
title={lang('Workflow')}
onClick={() => {
history.push('/admin/settings/workflow/workflows');
}}
/>
);
};

View File

@ -1,15 +1,7 @@
import { ShopOutlined } from '@ant-design/icons';
import {
i18n,
PluginManager,
PluginManagerContext,
RouteSwitchContext,
SettingsCenterProvider,
} from '@nocobase/client';
import { i18n, PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client';
import { Select } from 'antd';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
const ns = '@nocobase/plugin-sample-shop-i18n';
@ -44,21 +36,6 @@ function OrderStatusSelect() {
);
}
export const ShopShortcut = () => {
const { t } = useTranslation();
const history = useHistory();
return (
<PluginManager.Toolbar.Item
key="workflow"
icon={<ShopOutlined />}
title={t('Workflow')}
onClick={() => {
history.push('/admin/settings/workflow/workflows');
}}
/>
);
};
const ShopI18n = React.memo((props) => {
const ctx = useContext(PluginManagerContext);
const { routes, components, ...others } = useContext(RouteSwitchContext);
@ -82,7 +59,6 @@ const ShopI18n = React.memo((props) => {
value={{
components: {
...ctx?.components,
ShopShortcut,
},
}}
>