Skip to content

Commit a44e568

Browse files
committed
docs: update docs for the plugin development guide to explain how to use global scope plugins
1 parent 9e86450 commit a44e568

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

adminforth/basePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
1717
pluginInstanceId: string;
1818
customFolderPath: string;
1919
pluginOptions: any;
20-
resourceConfig: AdminForthResource;
20+
resourceConfig?: AdminForthResource;
2121
className: string;
2222
activationOrder: number = 0;
2323
pluginsScope: 'resource' | 'global' = 'resource';

adminforth/documentation/docs/tutorial/09-Advanced/01-plugin-development.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,38 @@ Default value of activationOrder for most plugins is `0`. Plugins with higher ac
506506
507507
To ensure that plugin activates before some other plugins set `activationOrder` to negative value.
508508
509+
## Making plugin global
510+
511+
If you want to make your plugin to be global and add it to the main `index.ts` in `globalPlugins` section, you need to use `pluginsScope: 'global'` and `modifyGlobalConfig` instead of `modifyResourceConfig`:
512+
513+
514+
```ts title="./your-global-plugin/index.ts"
515+
516+
...
517+
518+
export default class YourPugin extends AdminForthPlugin {
519+
options: PluginOptions;
520+
//diff-add
521+
pluginsScope: 'global'
522+
523+
...
524+
525+
//diff-remove
526+
async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
527+
//diff-remove
528+
super.modifyResourceConfig(adminforth, resourceConfig);
529+
//diff-add
530+
modifyGlobalConfig(adminforth: IAdminForth) {
531+
//diff-add
532+
super.modifyGlobalConfig(adminforth);
533+
534+
}
535+
536+
...
537+
538+
```
539+
540+
509541
## Splitting frontend logic into multiple files
510542
511543
In case your plugin `.vue` files getting too big, you can split them into multiple files (components).

0 commit comments

Comments
 (0)