@cccsaurora/howler-ui 2.14.0-dev.232 → 2.14.0-dev.247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commons/components/app/AppConfigs.d.ts +9 -3
- package/components/app/App.js +1 -0
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/hooks/useMyPreferences.js +208 -193
- package/components/hooks/useMySitemap.js +3 -1
- package/components/routes/hits/search/InformationPane.js +6 -3
- package/components/routes/hits/view/HitViewer.js +2 -2
- package/package.json +1 -1
- package/plugins/HowlerPlugin.d.ts +53 -1
- package/plugins/HowlerPlugin.js +146 -14
- package/plugins/store.d.ts +51 -14
- package/plugins/store.js +36 -21
- package/utils/menuUtils.d.ts +89 -0
- package/utils/menuUtils.js +243 -0
|
@@ -13,6 +13,7 @@ import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
|
13
13
|
import type React from 'react';
|
|
14
14
|
import type { PropsWithChildren } from 'react';
|
|
15
15
|
import type { IPlugin, PluginStore } from 'react-pluggable';
|
|
16
|
+
import type { MainMenuInsertOperation } from './store';
|
|
16
17
|
declare abstract class HowlerPlugin implements IPlugin {
|
|
17
18
|
abstract name: string;
|
|
18
19
|
abstract version: string;
|
|
@@ -27,7 +28,6 @@ declare abstract class HowlerPlugin implements IPlugin {
|
|
|
27
28
|
deactivate(): void;
|
|
28
29
|
addLead(format: string, form: (props: LeadFormProps) => React.ReactNode, renderer: (content: string, metadata: any, hit?: Hit) => React.ReactNode): void;
|
|
29
30
|
addPivot(format: string, form: (props: PivotFormProps) => React.ReactNode, renderer: (props: PivotLinkProps) => React.ReactNode): void;
|
|
30
|
-
addOperation(format: string, form: (props: CustomActionProps) => React.ReactNode, documentation: PluginDocumentation): void;
|
|
31
31
|
/**
|
|
32
32
|
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
33
33
|
* items are added before the 'Settings' and 'Logout' menu items.
|
|
@@ -46,6 +46,58 @@ declare abstract class HowlerPlugin implements IPlugin {
|
|
|
46
46
|
* @param icon JSX Icon element, <Settings/> for example
|
|
47
47
|
*/
|
|
48
48
|
addAdminMenuItem(i18nKey: string, route: string, icon: JSX.Element): void;
|
|
49
|
+
/**
|
|
50
|
+
* Adds a single route to the system to load, items are added to the end of
|
|
51
|
+
* base routes defined.
|
|
52
|
+
*
|
|
53
|
+
* @param path Route path, should not start with /
|
|
54
|
+
* @param element Element the route directs to
|
|
55
|
+
* @param children Child routes if required
|
|
56
|
+
*/
|
|
57
|
+
addRoute(path: string, element: JSX.Element, children?: []): void;
|
|
58
|
+
/**
|
|
59
|
+
* Adds a sitemap entry to the sitemap table, this is used to populate
|
|
60
|
+
* information on the Breadcrumb component
|
|
61
|
+
*
|
|
62
|
+
* @param path The react router path to this route
|
|
63
|
+
* @param title The title/label to display in breadcrumbs for this route
|
|
64
|
+
* @param icon The icon component to show beside the title/label
|
|
65
|
+
* @param isRoot When true, indicates that the breadcrumbs will reset to this one path each time it is encountered
|
|
66
|
+
* @param isLeaf When true, indicates that this path does not aggregate in breadcrumbs, i.e. will be replaced by next path
|
|
67
|
+
* @param excluded When true, indicates to breadcrumbs component to not render this route
|
|
68
|
+
* @param breadcrumbs Static list of breadcrumb paths to be rendered for the given route
|
|
69
|
+
* @param textWidth The max width of the text when rendering the breadcrumb
|
|
70
|
+
*/
|
|
71
|
+
addSitemap(path: string, title: string, icon?: JSX.Element, isRoot?: boolean, isLeaf?: boolean, excluded?: boolean, breadcrumbs?: string[], textWidth?: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Adds a route as well as a simple sitemap entry with values derived from the path
|
|
74
|
+
*
|
|
75
|
+
* @param path Route path, should not start with /
|
|
76
|
+
* @param element Element the route directs to
|
|
77
|
+
* @param children Child routes if required
|
|
78
|
+
* @param title The title/label to display in breadcrumbs for this route
|
|
79
|
+
* @param icon The icon component to show beside the title/label
|
|
80
|
+
*/
|
|
81
|
+
addRouteAndSitemap(path: string, element: JSX.Element, title: string, icon?: JSX.Element, children?: []): void;
|
|
82
|
+
/**
|
|
83
|
+
* Adds a new menu item to the Main Menu
|
|
84
|
+
*
|
|
85
|
+
* @param operation Insert operation to perform
|
|
86
|
+
* @param targetId Reference Menu Id
|
|
87
|
+
* @param id Identifier for new menu entry
|
|
88
|
+
* @param i18nKey Translation key for new menu entry
|
|
89
|
+
* @param route Route for new menu entry
|
|
90
|
+
* @param icon Icon for new menu entry
|
|
91
|
+
*/
|
|
92
|
+
addMainMenuItem(operation: MainMenuInsertOperation, targetId: string, id: string, i18nKey: string, route: string, icon: JSX.Element): void;
|
|
93
|
+
/**
|
|
94
|
+
* Adds a divider to the main menu
|
|
95
|
+
*
|
|
96
|
+
* @param operation Insert operation to perform
|
|
97
|
+
* @param targetId Reference menu id
|
|
98
|
+
*/
|
|
99
|
+
addMainMenuDivider(operation: MainMenuInsertOperation, targetId: string): void;
|
|
100
|
+
addOperation(format: string, form: (props: CustomActionProps) => React.ReactNode, documentation: PluginDocumentation): void;
|
|
49
101
|
on(_event: string, _hit: Hit): any;
|
|
50
102
|
provider(): React.FC<PropsWithChildren<{}>> | null;
|
|
51
103
|
setup(): void;
|
package/plugins/HowlerPlugin.js
CHANGED
|
@@ -8,7 +8,16 @@ const INTERNAL_FUNCTIONS = [
|
|
|
8
8
|
'init',
|
|
9
9
|
'activate',
|
|
10
10
|
'deactivate',
|
|
11
|
-
'addLead'
|
|
11
|
+
'addLead',
|
|
12
|
+
'addPivot',
|
|
13
|
+
'addUserMenuItem',
|
|
14
|
+
'addAdminMenuItem',
|
|
15
|
+
'addRoute',
|
|
16
|
+
'addSitemap',
|
|
17
|
+
'addRouteAndSitemap',
|
|
18
|
+
'addMainMenuItem',
|
|
19
|
+
'addMainMenuDivider',
|
|
20
|
+
'addOperation'
|
|
12
21
|
];
|
|
13
22
|
class HowlerPlugin {
|
|
14
23
|
pluginStore;
|
|
@@ -59,19 +68,6 @@ class HowlerPlugin {
|
|
|
59
68
|
// eslint-disable-next-line no-console
|
|
60
69
|
console.debug(`Pivot format ${format} enabled for plugin ${this.getPluginName()}`);
|
|
61
70
|
}
|
|
62
|
-
addOperation(format, form, documentation) {
|
|
63
|
-
if (!howlerPluginStore.addOperation(format)) {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.error(`Operation ${format} already configured, not enabling for plugin ${this.getPluginName()}`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.pluginStore.addFunction(`operation.${format}`, form);
|
|
69
|
-
this.functionsToRemove.push(`operation.${format}`);
|
|
70
|
-
this.pluginStore.addFunction(`operation.${format}.documentation`, () => documentation);
|
|
71
|
-
this.functionsToRemove.push(`operation.${format}.documentation`);
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
console.debug(`Operation ${format} enabled for plugin ${this.getPluginName()}`);
|
|
74
|
-
}
|
|
75
71
|
/**
|
|
76
72
|
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
77
73
|
* items are added before the 'Settings' and 'Logout' menu items.
|
|
@@ -102,6 +98,142 @@ class HowlerPlugin {
|
|
|
102
98
|
icon: icon
|
|
103
99
|
});
|
|
104
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Adds a single route to the system to load, items are added to the end of
|
|
103
|
+
* base routes defined.
|
|
104
|
+
*
|
|
105
|
+
* @param path Route path, should not start with /
|
|
106
|
+
* @param element Element the route directs to
|
|
107
|
+
* @param children Child routes if required
|
|
108
|
+
*/
|
|
109
|
+
addRoute(path, element, children) {
|
|
110
|
+
howlerPluginStore.addRoute({
|
|
111
|
+
path: path,
|
|
112
|
+
element: element,
|
|
113
|
+
children: children
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Adds a sitemap entry to the sitemap table, this is used to populate
|
|
118
|
+
* information on the Breadcrumb component
|
|
119
|
+
*
|
|
120
|
+
* @param path The react router path to this route
|
|
121
|
+
* @param title The title/label to display in breadcrumbs for this route
|
|
122
|
+
* @param icon The icon component to show beside the title/label
|
|
123
|
+
* @param isRoot When true, indicates that the breadcrumbs will reset to this one path each time it is encountered
|
|
124
|
+
* @param isLeaf When true, indicates that this path does not aggregate in breadcrumbs, i.e. will be replaced by next path
|
|
125
|
+
* @param excluded When true, indicates to breadcrumbs component to not render this route
|
|
126
|
+
* @param breadcrumbs Static list of breadcrumb paths to be rendered for the given route
|
|
127
|
+
* @param textWidth The max width of the text when rendering the breadcrumb
|
|
128
|
+
*/
|
|
129
|
+
addSitemap(path, title, icon, isRoot, isLeaf, excluded, breadcrumbs, textWidth) {
|
|
130
|
+
if (isRoot === isLeaf) {
|
|
131
|
+
throw new Error(`Sitemap '${path}' must define either isRoot or isLeaf as true`);
|
|
132
|
+
}
|
|
133
|
+
if (isRoot) {
|
|
134
|
+
if (breadcrumbs != null) {
|
|
135
|
+
breadcrumbs = null;
|
|
136
|
+
console.warn(`Sitemap '${path}' with isRoot should not contain breadcrumbs and have been removed`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
howlerPluginStore.addSitemap({
|
|
140
|
+
path: path,
|
|
141
|
+
title: title,
|
|
142
|
+
icon: icon,
|
|
143
|
+
isRoot: isRoot,
|
|
144
|
+
isLeaf: isLeaf,
|
|
145
|
+
excluded: excluded,
|
|
146
|
+
breadcrumbs: breadcrumbs,
|
|
147
|
+
textWidth: textWidth
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Adds a route as well as a simple sitemap entry with values derived from the path
|
|
152
|
+
*
|
|
153
|
+
* @param path Route path, should not start with /
|
|
154
|
+
* @param element Element the route directs to
|
|
155
|
+
* @param children Child routes if required
|
|
156
|
+
* @param title The title/label to display in breadcrumbs for this route
|
|
157
|
+
* @param icon The icon component to show beside the title/label
|
|
158
|
+
*/
|
|
159
|
+
addRouteAndSitemap(path, element, title, icon, children) {
|
|
160
|
+
this.addRoute(path, element, children);
|
|
161
|
+
const routeParts = path.split('/');
|
|
162
|
+
let isRoot = true;
|
|
163
|
+
let isLeaf = false;
|
|
164
|
+
let breadcrumbs = null;
|
|
165
|
+
if (routeParts.length > 1) {
|
|
166
|
+
// Set as leaf and not root
|
|
167
|
+
isRoot = false;
|
|
168
|
+
isLeaf = true;
|
|
169
|
+
// Attempt to auto build breadcrumbs
|
|
170
|
+
breadcrumbs = [];
|
|
171
|
+
for (let index = 0; index < routeParts.length - 1; index++) {
|
|
172
|
+
breadcrumbs.push(`/${routeParts[index]}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
this.addSitemap(`/${path}`, title, icon, isRoot, isLeaf, false, breadcrumbs);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Adds a new menu item to the Main Menu
|
|
179
|
+
*
|
|
180
|
+
* @param operation Insert operation to perform
|
|
181
|
+
* @param targetId Reference Menu Id
|
|
182
|
+
* @param id Identifier for new menu entry
|
|
183
|
+
* @param i18nKey Translation key for new menu entry
|
|
184
|
+
* @param route Route for new menu entry
|
|
185
|
+
* @param icon Icon for new menu entry
|
|
186
|
+
*/
|
|
187
|
+
addMainMenuItem(operation, targetId, id, i18nKey, route, icon) {
|
|
188
|
+
if (targetId === '') {
|
|
189
|
+
targetId = 'root';
|
|
190
|
+
}
|
|
191
|
+
howlerPluginStore.addMainMenuItem({
|
|
192
|
+
operation: operation,
|
|
193
|
+
targetId: targetId,
|
|
194
|
+
item: {
|
|
195
|
+
type: 'item',
|
|
196
|
+
element: {
|
|
197
|
+
id: id,
|
|
198
|
+
i18nKey: i18nKey,
|
|
199
|
+
route: route,
|
|
200
|
+
icon: icon
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Adds a divider to the main menu
|
|
207
|
+
*
|
|
208
|
+
* @param operation Insert operation to perform
|
|
209
|
+
* @param targetId Reference menu id
|
|
210
|
+
*/
|
|
211
|
+
addMainMenuDivider(operation, targetId) {
|
|
212
|
+
if (targetId === '') {
|
|
213
|
+
targetId = 'root';
|
|
214
|
+
}
|
|
215
|
+
howlerPluginStore.addMainMenuItem({
|
|
216
|
+
operation: operation,
|
|
217
|
+
targetId: targetId,
|
|
218
|
+
item: {
|
|
219
|
+
type: 'divider',
|
|
220
|
+
element: null
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
addOperation(format, form, documentation) {
|
|
225
|
+
if (!howlerPluginStore.addOperation(format)) {
|
|
226
|
+
// eslint-disable-next-line no-console
|
|
227
|
+
console.error(`Operation ${format} already configured, not enabling for plugin ${this.getPluginName()}`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.pluginStore.addFunction(`operation.${format}`, form);
|
|
231
|
+
this.functionsToRemove.push(`operation.${format}`);
|
|
232
|
+
this.pluginStore.addFunction(`operation.${format}.documentation`, () => documentation);
|
|
233
|
+
this.functionsToRemove.push(`operation.${format}.documentation`);
|
|
234
|
+
// eslint-disable-next-line no-console
|
|
235
|
+
console.debug(`Operation ${format} enabled for plugin ${this.getPluginName()}`);
|
|
236
|
+
}
|
|
105
237
|
on(_event, _hit) {
|
|
106
238
|
return null;
|
|
107
239
|
}
|
package/plugins/store.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
2
2
|
import { Event } from 'react-pluggable';
|
|
3
3
|
import type HowlerPlugin from './HowlerPlugin';
|
|
4
|
+
import type { AppLeftNavElement } from '../commons/components/app/AppConfigs';
|
|
4
5
|
export declare class HitEvent extends Event {
|
|
5
6
|
hit: Hit;
|
|
6
7
|
constructor(type: string, hit: Hit);
|
|
7
8
|
}
|
|
9
|
+
export declare enum MainMenuInsertOperation {
|
|
10
|
+
Insert = "INSERT",
|
|
11
|
+
InsertAfter = "AFTER",
|
|
12
|
+
InsertBefore = "BEFORE"
|
|
13
|
+
}
|
|
8
14
|
declare class HowlerPluginStore {
|
|
9
15
|
private _pluginStore;
|
|
10
16
|
plugins: string[];
|
|
@@ -13,36 +19,46 @@ declare class HowlerPluginStore {
|
|
|
13
19
|
private _operations;
|
|
14
20
|
private _userMenuItems;
|
|
15
21
|
private _adminMenuItems;
|
|
22
|
+
private _mainMenuOperations;
|
|
23
|
+
private _routes;
|
|
24
|
+
private _sitemaps;
|
|
16
25
|
install(plugin: HowlerPlugin): void;
|
|
17
26
|
addLead(format: string): boolean;
|
|
18
27
|
addPivot(format: string): boolean;
|
|
19
|
-
addOperation(format: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
22
|
-
* items are added before the 'Settings' and 'Logout' menu items.
|
|
23
|
-
*
|
|
24
|
-
* @param menuItem Menu Item {i18nKey, route, icon}
|
|
25
|
-
*/
|
|
26
28
|
addUserMenuItem(menuItem: {
|
|
27
29
|
i18nKey: string;
|
|
28
30
|
route: string;
|
|
29
31
|
icon: JSX.Element;
|
|
30
32
|
}): void;
|
|
31
|
-
/**
|
|
32
|
-
* Adds a single menu item to the Admin Menu group under the Avatar Menu,
|
|
33
|
-
* items are added to the end of the existing Admin menu items.
|
|
34
|
-
*
|
|
35
|
-
* @param menuItem Menu Item {i18nKey, route, icon}
|
|
36
|
-
*/
|
|
37
33
|
addAdminMenuItem(menuItem: {
|
|
38
34
|
i18nKey: string;
|
|
39
35
|
route: string;
|
|
40
36
|
icon: JSX.Element;
|
|
41
37
|
}): void;
|
|
38
|
+
addMainMenuItem(menuOperation: {
|
|
39
|
+
operation: string;
|
|
40
|
+
targetId: string;
|
|
41
|
+
item: AppLeftNavElement;
|
|
42
|
+
}): void;
|
|
43
|
+
addRoute(route: {
|
|
44
|
+
path: string;
|
|
45
|
+
element: JSX.Element;
|
|
46
|
+
children?: [];
|
|
47
|
+
}): void;
|
|
48
|
+
addSitemap(sitemap: {
|
|
49
|
+
path: string;
|
|
50
|
+
title: string;
|
|
51
|
+
icon?: JSX.Element;
|
|
52
|
+
isRoot?: boolean;
|
|
53
|
+
isLeaf?: boolean;
|
|
54
|
+
excluded?: boolean;
|
|
55
|
+
breadcrumbs?: string[];
|
|
56
|
+
textWidth?: number;
|
|
57
|
+
}): void;
|
|
58
|
+
addOperation(format: string): boolean;
|
|
42
59
|
get leadFormats(): string[];
|
|
43
60
|
get pivotFormats(): string[];
|
|
44
61
|
get operations(): string[];
|
|
45
|
-
get pluginStore(): import("react-pluggable").PluginStore;
|
|
46
62
|
get userMenuItems(): {
|
|
47
63
|
i18nKey: string;
|
|
48
64
|
route: string;
|
|
@@ -53,6 +69,27 @@ declare class HowlerPluginStore {
|
|
|
53
69
|
route: string;
|
|
54
70
|
icon: JSX.Element;
|
|
55
71
|
}[];
|
|
72
|
+
get mainMenuOperations(): {
|
|
73
|
+
operation: string;
|
|
74
|
+
targetId: string;
|
|
75
|
+
item: AppLeftNavElement;
|
|
76
|
+
}[];
|
|
77
|
+
get routes(): {
|
|
78
|
+
path: string;
|
|
79
|
+
element: JSX.Element;
|
|
80
|
+
children?: [];
|
|
81
|
+
}[];
|
|
82
|
+
get sitemaps(): {
|
|
83
|
+
path: string;
|
|
84
|
+
title: string;
|
|
85
|
+
icon?: JSX.Element;
|
|
86
|
+
isRoot?: boolean;
|
|
87
|
+
isLeaf?: boolean;
|
|
88
|
+
excluded?: boolean;
|
|
89
|
+
breadcrumbs?: string[];
|
|
90
|
+
textWidth?: number;
|
|
91
|
+
}[];
|
|
92
|
+
get pluginStore(): import("react-pluggable").PluginStore;
|
|
56
93
|
}
|
|
57
94
|
declare const howlerPluginStore: HowlerPluginStore;
|
|
58
95
|
export default howlerPluginStore;
|
package/plugins/store.js
CHANGED
|
@@ -6,6 +6,12 @@ export class HitEvent extends Event {
|
|
|
6
6
|
this.hit = hit;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
export var MainMenuInsertOperation;
|
|
10
|
+
(function (MainMenuInsertOperation) {
|
|
11
|
+
MainMenuInsertOperation["Insert"] = "INSERT";
|
|
12
|
+
MainMenuInsertOperation["InsertAfter"] = "AFTER";
|
|
13
|
+
MainMenuInsertOperation["InsertBefore"] = "BEFORE";
|
|
14
|
+
})(MainMenuInsertOperation || (MainMenuInsertOperation = {}));
|
|
9
15
|
class HowlerPluginStore {
|
|
10
16
|
_pluginStore = createPluginStore();
|
|
11
17
|
plugins = [];
|
|
@@ -14,6 +20,9 @@ class HowlerPluginStore {
|
|
|
14
20
|
_operations = [];
|
|
15
21
|
_userMenuItems = [];
|
|
16
22
|
_adminMenuItems = [];
|
|
23
|
+
_mainMenuOperations = [];
|
|
24
|
+
_routes = [];
|
|
25
|
+
_sitemaps = [];
|
|
17
26
|
install(plugin) {
|
|
18
27
|
console.log(`Installing plugin ${plugin.getPluginName()} by ${plugin.author}`);
|
|
19
28
|
this.plugins.push(plugin.name);
|
|
@@ -33,6 +42,21 @@ class HowlerPluginStore {
|
|
|
33
42
|
this._pivotFormats.push(format);
|
|
34
43
|
return true;
|
|
35
44
|
}
|
|
45
|
+
addUserMenuItem(menuItem) {
|
|
46
|
+
this._userMenuItems.push(menuItem);
|
|
47
|
+
}
|
|
48
|
+
addAdminMenuItem(menuItem) {
|
|
49
|
+
this._adminMenuItems.push(menuItem);
|
|
50
|
+
}
|
|
51
|
+
addMainMenuItem(menuOperation) {
|
|
52
|
+
this._mainMenuOperations.push(menuOperation);
|
|
53
|
+
}
|
|
54
|
+
addRoute(route) {
|
|
55
|
+
this._routes.push(route);
|
|
56
|
+
}
|
|
57
|
+
addSitemap(sitemap) {
|
|
58
|
+
this._sitemaps.push(sitemap);
|
|
59
|
+
}
|
|
36
60
|
addOperation(format) {
|
|
37
61
|
if (this._operations.includes(format)) {
|
|
38
62
|
return false;
|
|
@@ -40,24 +64,6 @@ class HowlerPluginStore {
|
|
|
40
64
|
this._operations.push(format);
|
|
41
65
|
return true;
|
|
42
66
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
45
|
-
* items are added before the 'Settings' and 'Logout' menu items.
|
|
46
|
-
*
|
|
47
|
-
* @param menuItem Menu Item {i18nKey, route, icon}
|
|
48
|
-
*/
|
|
49
|
-
addUserMenuItem(menuItem) {
|
|
50
|
-
this._userMenuItems.push(menuItem);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Adds a single menu item to the Admin Menu group under the Avatar Menu,
|
|
54
|
-
* items are added to the end of the existing Admin menu items.
|
|
55
|
-
*
|
|
56
|
-
* @param menuItem Menu Item {i18nKey, route, icon}
|
|
57
|
-
*/
|
|
58
|
-
addAdminMenuItem(menuItem) {
|
|
59
|
-
this._adminMenuItems.push(menuItem);
|
|
60
|
-
}
|
|
61
67
|
get leadFormats() {
|
|
62
68
|
return this._leadFormats;
|
|
63
69
|
}
|
|
@@ -67,15 +73,24 @@ class HowlerPluginStore {
|
|
|
67
73
|
get operations() {
|
|
68
74
|
return this._operations;
|
|
69
75
|
}
|
|
70
|
-
get pluginStore() {
|
|
71
|
-
return this._pluginStore;
|
|
72
|
-
}
|
|
73
76
|
get userMenuItems() {
|
|
74
77
|
return this._userMenuItems;
|
|
75
78
|
}
|
|
76
79
|
get adminMenuItems() {
|
|
77
80
|
return this._adminMenuItems;
|
|
78
81
|
}
|
|
82
|
+
get mainMenuOperations() {
|
|
83
|
+
return this._mainMenuOperations;
|
|
84
|
+
}
|
|
85
|
+
get routes() {
|
|
86
|
+
return this._routes;
|
|
87
|
+
}
|
|
88
|
+
get sitemaps() {
|
|
89
|
+
return this._sitemaps;
|
|
90
|
+
}
|
|
91
|
+
get pluginStore() {
|
|
92
|
+
return this._pluginStore;
|
|
93
|
+
}
|
|
79
94
|
}
|
|
80
95
|
const howlerPluginStore = new HowlerPluginStore();
|
|
81
96
|
export default howlerPluginStore;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AppLeftNavElement, AppLeftNavItem } from '../commons/components/app/AppConfigs';
|
|
2
|
+
declare class AppMenuBuilder {
|
|
3
|
+
private items;
|
|
4
|
+
private indexMap;
|
|
5
|
+
constructor(defaultMenu: AppLeftNavElement[]);
|
|
6
|
+
/**
|
|
7
|
+
* Applies a collection of Menu Operation objects created by the plugin system
|
|
8
|
+
*
|
|
9
|
+
* @param operations Operations created by the plugin system
|
|
10
|
+
*/
|
|
11
|
+
applyOperations(operations: {
|
|
12
|
+
operation: string;
|
|
13
|
+
targetId: string;
|
|
14
|
+
item: AppLeftNavElement;
|
|
15
|
+
}[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get the completed menu structure
|
|
18
|
+
*/
|
|
19
|
+
get menu(): AppLeftNavElement[];
|
|
20
|
+
/**
|
|
21
|
+
* Insert provided menu item at the menu object identified by targetId.
|
|
22
|
+
*
|
|
23
|
+
* If the target menu is a group then item will be placed at end of sub items
|
|
24
|
+
*
|
|
25
|
+
* If the target menu is a standard item then group will be created and new item added, warning this removes
|
|
26
|
+
* the route from the new group parent item, be sure to add it back.
|
|
27
|
+
*
|
|
28
|
+
* If the target is 'root' then item will be added to end of root menu
|
|
29
|
+
*
|
|
30
|
+
* @param targetId Identifier of menu to insert to
|
|
31
|
+
* @param item Menu Item to insert
|
|
32
|
+
*/
|
|
33
|
+
insert(targetId: string, item: AppLeftNavElement): void;
|
|
34
|
+
/**
|
|
35
|
+
* Insert provided menu item before the menu object identified by targetId.
|
|
36
|
+
*
|
|
37
|
+
* @param targetId Identifier of menu to insert to
|
|
38
|
+
* @param item Menu Item to insert
|
|
39
|
+
*/
|
|
40
|
+
insertBefore(targetId: string, item: AppLeftNavElement): void;
|
|
41
|
+
/**
|
|
42
|
+
* Insert provided menu item after the menu object identified by targetId.
|
|
43
|
+
*
|
|
44
|
+
* @param targetId Identifier of menu to insert to
|
|
45
|
+
* @param item Menu Item to insert
|
|
46
|
+
*/
|
|
47
|
+
insertAfter(targetId: string, item: AppLeftNavElement): void;
|
|
48
|
+
/**
|
|
49
|
+
* Locates menu location in menu structure by menu id.
|
|
50
|
+
*
|
|
51
|
+
* @param id Menu Id to search for
|
|
52
|
+
* @return {index: number, subIndex: number} A dictionary containing indexes needed to access Menu Item
|
|
53
|
+
*/
|
|
54
|
+
indexOfMenuId(id: string): {
|
|
55
|
+
index: number;
|
|
56
|
+
subIndex?: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Grabs a menu by indexes, helper function to account for an index of -1
|
|
60
|
+
* to represent the root menu
|
|
61
|
+
*
|
|
62
|
+
* @param index First level index
|
|
63
|
+
* @param subIndex Second level index
|
|
64
|
+
* @return {} Menu item
|
|
65
|
+
*/
|
|
66
|
+
menuFromIndex(index: number, subIndex?: number): AppLeftNavElement[] | AppLeftNavElement | AppLeftNavItem;
|
|
67
|
+
/**
|
|
68
|
+
* Determine if provided element is a group element
|
|
69
|
+
*
|
|
70
|
+
* @param elem Element to check
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
private isGroupElement;
|
|
74
|
+
/**
|
|
75
|
+
* Determine if provided element is an item element
|
|
76
|
+
*
|
|
77
|
+
* @param elem Element to check
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private isItemElement;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a flat list of menu items and subitems by menu id
|
|
83
|
+
* for quick lookup.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private updateMenuMap;
|
|
88
|
+
}
|
|
89
|
+
export default AppMenuBuilder;
|