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 { 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 cls from 'classnames';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
|
import { useAPIClient, useRequest } from '../api-client';
|
||||||
import { PluginManagerContext } from './context';
|
import { PluginManagerContext } from './context';
|
||||||
|
|
||||||
export const usePrefixCls = (
|
export const usePrefixCls = (
|
||||||
@ -107,3 +108,15 @@ PluginManager.Toolbar.Item = (props) => {
|
|||||||
</Menu.Item>
|
</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,
|
CurrentUserProvider,
|
||||||
findByUid,
|
findByUid,
|
||||||
findMenuItem,
|
findMenuItem,
|
||||||
PluginManager,
|
|
||||||
RemoteCollectionManagerProvider,
|
RemoteCollectionManagerProvider,
|
||||||
|
RemotePluginManagerToolbar,
|
||||||
RemoteSchemaTemplateManagerProvider,
|
RemoteSchemaTemplateManagerProvider,
|
||||||
SchemaComponent,
|
SchemaComponent,
|
||||||
useACLRoleContext,
|
useACLRoleContext,
|
||||||
@ -151,17 +151,7 @@ const InternalAdminLayout = (props: any) => {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ position: 'absolute', top: 0, right: 0 }}>
|
<div style={{ position: 'absolute', top: 0, right: 0 }}>
|
||||||
<ACLAllowConfigure>
|
<ACLAllowConfigure>
|
||||||
<PluginManager.Toolbar
|
<RemotePluginManagerToolbar />
|
||||||
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' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</ACLAllowConfigure>
|
</ACLAllowConfigure>
|
||||||
<CurrentUser />
|
<CurrentUser />
|
||||||
</div>
|
</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;
|
let root = this.options.dist;
|
||||||
if (root && !root.startsWith('/')) {
|
if (root && !root.startsWith('/')) {
|
||||||
root = resolve(process.cwd(), root);
|
root = resolve(process.cwd(), root);
|
||||||
|
Loading…
Reference in New Issue
Block a user