fix: plugin settings manager Component optional & delete isBookmark (#3027)
This commit is contained in:
parent
83245a406b
commit
34d1406ede
@ -1,5 +1,6 @@
|
||||
import { set } from 'lodash';
|
||||
import { createElement } from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import { Icon } from '../icon';
|
||||
import type { Application } from './Application';
|
||||
@ -11,14 +12,16 @@ export const SNIPPET_PREFIX = 'pm.';
|
||||
|
||||
export interface PluginSettingsManagerSettingOptionsType {
|
||||
title: string;
|
||||
Component: RouteType['Component'];
|
||||
/**
|
||||
* @default Outlet
|
||||
*/
|
||||
Component?: RouteType['Component'];
|
||||
icon?: string;
|
||||
/**
|
||||
* sort, the smaller the number, the higher the priority
|
||||
* @default 0
|
||||
*/
|
||||
sort?: number;
|
||||
isBookmark?: boolean;
|
||||
aclSnippet?: string;
|
||||
[index: string]: any;
|
||||
}
|
||||
@ -32,7 +35,6 @@ export interface PluginSettingsPageType {
|
||||
sort?: number;
|
||||
name?: string;
|
||||
pluginName?: string;
|
||||
isBookmark?: boolean;
|
||||
children?: PluginSettingsPageType[];
|
||||
[index: string]: any;
|
||||
}
|
||||
@ -65,7 +67,7 @@ export class PluginSettingsManager {
|
||||
add(name: string, options: PluginSettingsManagerSettingOptionsType) {
|
||||
const nameArr = name.split('.');
|
||||
const pluginName = nameArr[0];
|
||||
this.settings[name] = { ...options, name, pluginName };
|
||||
this.settings[name] = { Component: Outlet, ...options, name, pluginName };
|
||||
|
||||
// add children
|
||||
if (nameArr.length > 1) {
|
||||
@ -75,7 +77,7 @@ export class PluginSettingsManager {
|
||||
// add route
|
||||
this.app.router.add(this.getRouteName(name), {
|
||||
path: this.getRoutePath(name),
|
||||
Component: options.Component,
|
||||
Component: this.settings[name].Component,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,28 +27,23 @@ export class PMPlugin extends Plugin {
|
||||
icon: 'LockOutlined',
|
||||
Component: ACLPane,
|
||||
aclSnippet: 'pm.acl.roles',
|
||||
isBookmark: true,
|
||||
});
|
||||
this.app.pluginSettingsManager.add('ui-schema-storage', {
|
||||
title: '{{t("Block templates")}}',
|
||||
icon: 'LayoutOutlined',
|
||||
Component: BlockTemplatesPane,
|
||||
isBookmark: true,
|
||||
aclSnippet: 'pm.ui-schema-storage.block-templates',
|
||||
});
|
||||
this.app.pluginSettingsManager.add('system-settings', {
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("System settings")}}',
|
||||
Component: SystemSettingsPane,
|
||||
isBookmark: true,
|
||||
aclSnippet: 'pm.system-settings.system-settings',
|
||||
});
|
||||
|
||||
this.app.pluginSettingsManager.add('collection-manager', {
|
||||
icon: 'DatabaseOutlined',
|
||||
title: '{{t("Collection manager")}}',
|
||||
Component: () => <Outlet />,
|
||||
isBookmark: true,
|
||||
});
|
||||
|
||||
this.app.pluginSettingsManager.add('collection-manager.collections', {
|
||||
|
Loading…
Reference in New Issue
Block a user