feat: add plugins:getPinned action api
This commit is contained in:
parent
2df0e46318
commit
b5c24aa799
@ -1,8 +1,9 @@
|
||||
import { MoreOutlined, SettingOutlined } from '@ant-design/icons';
|
||||
import { ConfigProvider, Menu, MenuItemProps, Tooltip } from 'antd';
|
||||
import { ConfigProvider, Menu, MenuItemProps, Spin, Tooltip } from 'antd';
|
||||
import cls from 'classnames';
|
||||
import { get } from 'lodash';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useAPIClient, useRequest } from '../api-client';
|
||||
import { PluginManagerContext } from './context';
|
||||
|
||||
export const usePrefixCls = (
|
||||
@ -107,3 +108,15 @@ PluginManager.Toolbar.Item = (props) => {
|
||||
</Menu.Item>
|
||||
);
|
||||
};
|
||||
|
||||
export const RemotePluginManagerToolbar = () => {
|
||||
const api = useAPIClient();
|
||||
const { data, loading } = useRequest({
|
||||
resource: 'plugins',
|
||||
action: 'getPinned',
|
||||
});
|
||||
if (loading) {
|
||||
return <Spin />;
|
||||
}
|
||||
return <PluginManager.Toolbar items={data?.data} />;
|
||||
};
|
||||
|
@ -9,8 +9,8 @@ import {
|
||||
CurrentUserProvider,
|
||||
findByUid,
|
||||
findMenuItem,
|
||||
PluginManager,
|
||||
RemoteCollectionManagerProvider,
|
||||
RemotePluginManagerToolbar,
|
||||
RemoteSchemaTemplateManagerProvider,
|
||||
SchemaComponent,
|
||||
useACLRoleContext,
|
||||
@ -151,17 +151,7 @@ const InternalAdminLayout = (props: any) => {
|
||||
</div>
|
||||
<div style={{ position: 'absolute', top: 0, right: 0 }}>
|
||||
<ACLAllowConfigure>
|
||||
<PluginManager.Toolbar
|
||||
items={[
|
||||
{ component: 'DesignableSwitch', pin: true },
|
||||
{ component: 'CollectionManagerShortcut', pin: true },
|
||||
{ component: 'ACLShortcut', pin: true },
|
||||
{ component: 'WorkflowShortcut', pin: true },
|
||||
{ component: 'SchemaTemplateShortcut', pin: true },
|
||||
{ component: 'SystemSettingsShortcut' },
|
||||
{ component: 'FileStorageShortcut' },
|
||||
]}
|
||||
/>
|
||||
<RemotePluginManagerToolbar />
|
||||
</ACLAllowConfigure>
|
||||
<CurrentUser />
|
||||
</div>
|
||||
|
@ -39,6 +39,24 @@ export class ClientPlugin extends Plugin {
|
||||
},
|
||||
},
|
||||
});
|
||||
this.app.resource({
|
||||
name: 'plugins',
|
||||
actions: {
|
||||
// TODO: 临时
|
||||
async getPinned(ctx, next) {
|
||||
ctx.body = [
|
||||
{ component: 'DesignableSwitch', pin: true },
|
||||
{ component: 'CollectionManagerShortcut', pin: true },
|
||||
{ component: 'ACLShortcut' },
|
||||
{ component: 'WorkflowShortcut' },
|
||||
{ component: 'SchemaTemplateShortcut' },
|
||||
{ component: 'SystemSettingsShortcut' },
|
||||
{ component: 'FileStorageShortcut' },
|
||||
];
|
||||
await next();
|
||||
},
|
||||
},
|
||||
});
|
||||
let root = this.options.dist;
|
||||
if (root && !root.startsWith('/')) {
|
||||
root = resolve(process.cwd(), root);
|
||||
|
Loading…
Reference in New Issue
Block a user