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
### Integrating AdminForth into your existing application
50
49
51
-
<ahref="https://adminforth.dev/docs/tutorial/Plugins/chat-gpt">Text completion plugin (Copilot-style) using LLMs</a>
52
-
<br/>
50
+
If you want to build an admin panel for an existing project that already has a database with tables, you can provide the connection URL to your existing development database, such as a local or deployed one.
Resource files are needed for AdminForth to “know” about your tables and define how to work with them.
59
+
60
+
Use the command above every time you add new tables or change their schema.
61
+
62
+
### Starting from scratch
63
+
64
+
If you do not have a database yet, start an empty local database, for example PostgreSQL in Docker, and provide its URL to the AdminForth CLI.
65
+
66
+
If the adminforth CLI does not detect any tables, it will suggest adding Prisma as a migration tool. Prisma is not related to AdminForth, but it is one of the most convenient migration tools.
> Follow this section only if you want to make changes to the AdminForth framework or develop a plugin.
62
73
63
-
The most convenient way to add new features or fixes is using `dev-demo`. It imports the source code of the repository and plugins so you can edit them and see changes on the fly.
74
+
The most convenient way to add new features or fixes is to use `dev-demo`. It imports the repository source code and plugins, so you can edit them and see changes on the fly.
export APP_NAMESPACE="myadmin" # <<< SET YOUR APP NAMESPACE HERE
733
+
export IMAGE_FULL_TAG="$${ACCOUNT_ID}.dkr.ecr.$${REGION}.amazonaws.com/myadmink3s:$${TAG}" # Change 'myadmink3s' to your app name in 'helmfile.yaml' & 'Chart.yaml' files as well
734
734
helmfile apply
735
735
cd ..
736
736
737
737
echo "Deployment complete!"
738
738
```
739
+
You need to change the values of `APP_NAMESPACE` and `IMAGE_FULL_TAG` in the `deploy/deploy.sh` script to match your application name and image tag. Note that `IMAGE_FULL_TAG` is constructed dynamically from the Terraform outputs and the tag, so you only need to change `APP_NAMESPACE`.
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md
+126Lines changed: 126 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -304,3 +304,129 @@ menu: [
304
304
305
305
```
306
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