@cccsaurora/howler-ui 2.14.0-dev.217 → 2.14.0-dev.220
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/components/hooks/useMyPreferences.js +30 -19
- package/package.json +1 -1
- package/plugins/HowlerPlugin.d.ts +18 -0
- package/plugins/HowlerPlugin.js +30 -0
- package/plugins/store.d.ts +34 -0
- package/plugins/store.js +26 -0
|
@@ -3,6 +3,7 @@ import { Api, Article, Book, Code, Dashboard, Description, Edit, ExitToApp, Form
|
|
|
3
3
|
import { AppBrand } from '@cccsaurora/howler-ui/branding/AppBrand';
|
|
4
4
|
import Classification from '@cccsaurora/howler-ui/components/elements/display/Classification';
|
|
5
5
|
import DocumentationButton from '@cccsaurora/howler-ui/components/elements/display/DocumentationButton';
|
|
6
|
+
import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
|
|
6
7
|
import { useMemo } from 'react';
|
|
7
8
|
// This is your App Name that will be displayed in the left drawer and the top navbar
|
|
8
9
|
const APP_NAME = 'howler';
|
|
@@ -197,26 +198,36 @@ const useMyPreferences = () => {
|
|
|
197
198
|
// prettier-ignore
|
|
198
199
|
[]);
|
|
199
200
|
// This is the basic user menu, it is a menu that shows up in account avatar popover.
|
|
200
|
-
const USER_MENU_ITEMS = useMemo(() =>
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
201
|
+
const USER_MENU_ITEMS = useMemo(() => {
|
|
202
|
+
// Load plugin menu items first as Settings/Logout generally
|
|
203
|
+
// appear at the end of user menus.
|
|
204
|
+
const results = howlerPluginStore.userMenuItems;
|
|
205
|
+
results.push(...[
|
|
206
|
+
{
|
|
207
|
+
i18nKey: 'usermenu.settings',
|
|
208
|
+
route: '/settings',
|
|
209
|
+
icon: _jsx(Settings, {})
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
i18nKey: 'usermenu.logout',
|
|
213
|
+
route: '/logout',
|
|
214
|
+
icon: _jsx(ExitToApp, {})
|
|
215
|
+
}
|
|
216
|
+
]);
|
|
217
|
+
return results;
|
|
218
|
+
}, []);
|
|
212
219
|
// This is the basic administrator menu, it is a menu that shows up under the user menu in the account avatar popover.
|
|
213
|
-
const ADMIN_MENU_ITEMS = useMemo(() =>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
const ADMIN_MENU_ITEMS = useMemo(() => {
|
|
221
|
+
const results = [
|
|
222
|
+
{
|
|
223
|
+
i18nKey: 'adminmenu.users',
|
|
224
|
+
route: '/admin/users',
|
|
225
|
+
icon: _jsx(SupervisorAccount, {})
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
results.push(...howlerPluginStore.adminMenuItems);
|
|
229
|
+
return results;
|
|
230
|
+
}, []);
|
|
220
231
|
// Return memoized config to prevent unnecessary re-renders.
|
|
221
232
|
return useMemo(() => ({
|
|
222
233
|
appName: '',
|
package/package.json
CHANGED
|
@@ -28,6 +28,24 @@ declare abstract class HowlerPlugin implements IPlugin {
|
|
|
28
28
|
addLead(format: string, form: (props: LeadFormProps) => React.ReactNode, renderer: (content: string, metadata: any, hit?: Hit) => React.ReactNode): void;
|
|
29
29
|
addPivot(format: string, form: (props: PivotFormProps) => React.ReactNode, renderer: (props: PivotLinkProps) => React.ReactNode): void;
|
|
30
30
|
addOperation(format: string, form: (props: CustomActionProps) => React.ReactNode, documentation: PluginDocumentation): void;
|
|
31
|
+
/**
|
|
32
|
+
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
33
|
+
* items are added before the 'Settings' and 'Logout' menu items.
|
|
34
|
+
*
|
|
35
|
+
* @param i18nKey Translation Key or Title
|
|
36
|
+
* @param route Route to navigate to, '/settings' for example
|
|
37
|
+
* @param icon JSX Icon element, <Settings/> for example
|
|
38
|
+
*/
|
|
39
|
+
addUserMenuItem(i18nKey: string, route: string, icon: JSX.Element): void;
|
|
40
|
+
/**
|
|
41
|
+
* Adds a single menu item to the Admin Menu group under the Avatar Menu,
|
|
42
|
+
* items are added to the end of the existing Admin menu items.
|
|
43
|
+
*
|
|
44
|
+
* @param i18nKey Translation Key or Title
|
|
45
|
+
* @param route Route to navigate to, '/settings' for example
|
|
46
|
+
* @param icon JSX Icon element, <Settings/> for example
|
|
47
|
+
*/
|
|
48
|
+
addAdminMenuItem(i18nKey: string, route: string, icon: JSX.Element): void;
|
|
31
49
|
on(_event: string, _hit: Hit): any;
|
|
32
50
|
provider(): React.FC<PropsWithChildren<{}>> | null;
|
|
33
51
|
setup(): void;
|
package/plugins/HowlerPlugin.js
CHANGED
|
@@ -72,6 +72,36 @@ class HowlerPlugin {
|
|
|
72
72
|
// eslint-disable-next-line no-console
|
|
73
73
|
console.debug(`Operation ${format} enabled for plugin ${this.getPluginName()}`);
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Adds a single menu item to the User Menu group under the Avatar Menu,
|
|
77
|
+
* items are added before the 'Settings' and 'Logout' menu items.
|
|
78
|
+
*
|
|
79
|
+
* @param i18nKey Translation Key or Title
|
|
80
|
+
* @param route Route to navigate to, '/settings' for example
|
|
81
|
+
* @param icon JSX Icon element, <Settings/> for example
|
|
82
|
+
*/
|
|
83
|
+
addUserMenuItem(i18nKey, route, icon) {
|
|
84
|
+
howlerPluginStore.addUserMenuItem({
|
|
85
|
+
i18nKey: i18nKey,
|
|
86
|
+
route: route,
|
|
87
|
+
icon: icon
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Adds a single menu item to the Admin Menu group under the Avatar Menu,
|
|
92
|
+
* items are added to the end of the existing Admin menu items.
|
|
93
|
+
*
|
|
94
|
+
* @param i18nKey Translation Key or Title
|
|
95
|
+
* @param route Route to navigate to, '/settings' for example
|
|
96
|
+
* @param icon JSX Icon element, <Settings/> for example
|
|
97
|
+
*/
|
|
98
|
+
addAdminMenuItem(i18nKey, route, icon) {
|
|
99
|
+
howlerPluginStore.addAdminMenuItem({
|
|
100
|
+
i18nKey: i18nKey,
|
|
101
|
+
route: route,
|
|
102
|
+
icon: icon
|
|
103
|
+
});
|
|
104
|
+
}
|
|
75
105
|
on(_event, _hit) {
|
|
76
106
|
return null;
|
|
77
107
|
}
|
package/plugins/store.d.ts
CHANGED
|
@@ -11,14 +11,48 @@ declare class HowlerPluginStore {
|
|
|
11
11
|
private _leadFormats;
|
|
12
12
|
private _pivotFormats;
|
|
13
13
|
private _operations;
|
|
14
|
+
private _userMenuItems;
|
|
15
|
+
private _adminMenuItems;
|
|
14
16
|
install(plugin: HowlerPlugin): void;
|
|
15
17
|
addLead(format: string): boolean;
|
|
16
18
|
addPivot(format: string): boolean;
|
|
17
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
|
+
addUserMenuItem(menuItem: {
|
|
27
|
+
i18nKey: string;
|
|
28
|
+
route: string;
|
|
29
|
+
icon: JSX.Element;
|
|
30
|
+
}): 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
|
+
addAdminMenuItem(menuItem: {
|
|
38
|
+
i18nKey: string;
|
|
39
|
+
route: string;
|
|
40
|
+
icon: JSX.Element;
|
|
41
|
+
}): void;
|
|
18
42
|
get leadFormats(): string[];
|
|
19
43
|
get pivotFormats(): string[];
|
|
20
44
|
get operations(): string[];
|
|
21
45
|
get pluginStore(): import("react-pluggable").PluginStore;
|
|
46
|
+
get userMenuItems(): {
|
|
47
|
+
i18nKey: string;
|
|
48
|
+
route: string;
|
|
49
|
+
icon: JSX.Element;
|
|
50
|
+
}[];
|
|
51
|
+
get adminMenuItems(): {
|
|
52
|
+
i18nKey: string;
|
|
53
|
+
route: string;
|
|
54
|
+
icon: JSX.Element;
|
|
55
|
+
}[];
|
|
22
56
|
}
|
|
23
57
|
declare const howlerPluginStore: HowlerPluginStore;
|
|
24
58
|
export default howlerPluginStore;
|
package/plugins/store.js
CHANGED
|
@@ -12,6 +12,8 @@ class HowlerPluginStore {
|
|
|
12
12
|
_leadFormats = [];
|
|
13
13
|
_pivotFormats = [];
|
|
14
14
|
_operations = [];
|
|
15
|
+
_userMenuItems = [];
|
|
16
|
+
_adminMenuItems = [];
|
|
15
17
|
install(plugin) {
|
|
16
18
|
console.log(`Installing plugin ${plugin.getPluginName()} by ${plugin.author}`);
|
|
17
19
|
this.plugins.push(plugin.name);
|
|
@@ -38,6 +40,24 @@ class HowlerPluginStore {
|
|
|
38
40
|
this._operations.push(format);
|
|
39
41
|
return true;
|
|
40
42
|
}
|
|
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
|
+
}
|
|
41
61
|
get leadFormats() {
|
|
42
62
|
return this._leadFormats;
|
|
43
63
|
}
|
|
@@ -50,6 +70,12 @@ class HowlerPluginStore {
|
|
|
50
70
|
get pluginStore() {
|
|
51
71
|
return this._pluginStore;
|
|
52
72
|
}
|
|
73
|
+
get userMenuItems() {
|
|
74
|
+
return this._userMenuItems;
|
|
75
|
+
}
|
|
76
|
+
get adminMenuItems() {
|
|
77
|
+
return this._adminMenuItems;
|
|
78
|
+
}
|
|
53
79
|
}
|
|
54
80
|
const howlerPluginStore = new HowlerPluginStore();
|
|
55
81
|
export default howlerPluginStore;
|