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
{{ message }}
Repository navigation
Commit 19b701e
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/10-Advanced/01-plugin-development.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -512,7 +512,11 @@ To ensure that plugin activates before some other plugins set `activationOrder`
512
512
513
513
## Making plugin global
514
514
515
-
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`:
515
+
Each plugin should define a scope: resource-level or global level.
516
+
* Resource-level plugins should be used when plugin instance works only with one resource config or it's fields. Instances of resource-scope plugins should be installed into "plugins' field of resource config.
517
+
* All other plugins should be global-scoped. Such plugins are installed to `globalPlugins` of root adminforth config. They might modify configs of many resources like default AuditLog plugin or use several database resources to store data like default Agent plugin.
518
+
519
+
To make your plugin global, you need to use `pluginsScope:'global'` and `modifyGlobalConfig` instead of `modifyResourceConfig`
Copy file name to clipboardExpand all lines: adminforth/index.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,10 @@ class AdminForth implements IAdminForth {
296
296
for(letpluginInstanceofresource.plugins||[]){
297
297
afLogger.trace(`🔌 Found plugin: ${pluginInstance.constructor.name} for resource ${resource.resourceId}`);
298
298
if(pluginInstance.pluginsScope==='global'){
299
-
thrownewError(formatHugePluginError(`Move plugin ${pluginInstance.constructor.name} to index.ts config.globalPlugins array`));
299
+
thrownewError(formatHugePluginError(`Please move plugin ${pluginInstance.constructor.name} instance to index.ts config.globalPlugins array.
300
+
Details: Previously adminforth had only resource-level plugins. To keep project structure clean, in recent version of adminforth we introduced globalPlugins.
301
+
Global plugins are installed on whole application and not only one resource (like agent, audit logs etc)
0 commit comments