You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -57,131 +57,6 @@ E.g. create group "Blog" with Items who link to resource "posts" and "categories
57
57
58
58
If it is rare Group you can make it `open: false` so it would not take extra space in menu, but admin users will be able to open it by clicking on the group name.
59
59
60
-
## Adding menu items from plugins
61
-
62
-
Plugins can add top-level menu items without mutating the user-defined `config.menu`. This keeps the application menu owned by the app configuration, while plugins can contribute their own entries.
63
-
64
-
Use `registerMenuContribution` from a plugin's `modifyResourceConfig`:
If placement is omitted, or if the target item is not found, AdminForth appends the contributed item to the end of the top-level menu.
121
-
122
-
Plugin menu contributions are additive only:
123
-
124
-
- user-defined `config.menu` is not changed
125
-
- plugins cannot remove or edit existing menu items through this API
126
-
- contributed `itemId` must not duplicate an existing top-level menu item
127
-
- this first version inserts only top-level menu items
128
-
129
-
### Dynamic menu items from plugin state
130
-
131
-
If a plugin needs to add menu items at runtime, for example after a user clicks a button and creates a new dashboard, register a menu contribution provider. AdminForth calls providers every time it fetches the menu.
After the plugin changes the state used by the provider, call `refreshMenu` on the backend:
162
-
163
-
```ts
164
-
awaitadminforth.resource('dashboards').create({
165
-
name: 'Sales',
166
-
});
167
-
168
-
awaitadminforth.refreshMenu(adminUser);
169
-
```
170
-
171
-
AdminForth sends a websocket event to the current user, and the frontend refetches the menu without a page reload.
172
-
173
-
Frontend components can also refresh the menu directly:
174
-
175
-
```ts
176
-
import { useAdminforth } from'@/adminforth';
177
-
178
-
const { menu } =useAdminforth();
179
-
180
-
awaitmenu.refresh();
181
-
```
182
-
183
-
Dynamic menu items should point to routes that are already available in the SPA. If a provider returns a brand-new custom `component` path that was not known during AdminForth build, the menu item can appear, but the route will not be registered until the app is rebuilt.
184
-
185
60
## Visibility of menu items
186
61
187
62
You might want to hide some menu items from the menu for some users.
@@ -429,3 +304,129 @@ menu: [
429
304
430
305
```
431
306
> 👆 Please note start internal URLs with a leading / to ensure correct routing.
307
+
308
+
309
+
## Adding menu items from plugins
310
+
311
+
Plugins can add top-level menu items without mutating the user-defined `config.menu`. This keeps the application menu owned by the app configuration, while plugins can contribute their own entries.
312
+
313
+
Use `registerMenuContribution` from a plugin's `modifyResourceConfig`:
If placement is omitted, or if the target item is not found, AdminForth appends the contributed item to the end of the top-level menu.
370
+
371
+
Plugin menu contributions are additive only:
372
+
373
+
- user-defined `config.menu` is not changed
374
+
- plugins cannot remove or edit existing menu items through this API
375
+
- contributed `itemId` must not duplicate an existing top-level menu item
376
+
- this first version inserts only top-level menu items
377
+
378
+
### Dynamic menu items from plugin state
379
+
380
+
If a plugin needs to add menu items at runtime, for example after a user clicks a button and creates a new dashboard, register a menu contribution provider. AdminForth calls providers every time it fetches the menu.
After the plugin changes the state used by the provider, call `refreshMenu` on the backend:
411
+
412
+
```ts
413
+
awaitadminforth.resource('dashboards').create({
414
+
name: 'Sales',
415
+
});
416
+
417
+
awaitadminforth.refreshMenu(adminUser);
418
+
```
419
+
420
+
AdminForth sends a websocket event to the current user, and the frontend refetches the menu without a page reload.
421
+
422
+
Frontend components can also refresh the menu directly:
423
+
424
+
```ts
425
+
import { useAdminforth } from'@/adminforth';
426
+
427
+
const { menu } =useAdminforth();
428
+
429
+
awaitmenu.refresh();
430
+
```
431
+
432
+
Dynamic menu items should point to routes that are already available in the SPA. If a provider returns a brand-new custom `component` path that was not known during AdminForth build, the menu item can appear, but the route will not be registered until the app is rebuilt.
0 commit comments