adminforth 1.3.54-next.0 → 1.3.54-next.2

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/basePlugin.ts CHANGED
@@ -16,7 +16,7 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
16
16
  customFolderPath: string;
17
17
  pluginOptions: any;
18
18
  resourceConfig: AdminForthResource;
19
-
19
+ className: string;
20
20
  activationOrder: number = 0;
21
21
 
22
22
  constructor(pluginOptions: any, metaUrl: string) {
@@ -24,6 +24,8 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
24
24
  this.pluginDir = currentFileDir(metaUrl);
25
25
  this.customFolderPath = path.join(this.pluginDir, this.customFolderName);
26
26
  this.pluginOptions = pluginOptions;
27
+ console.log(`🪲 🪲 🪲 🪲 🪲 🪲 AdminForthPlugin.constructor`, this.constructor.name);
28
+ this.className = this.constructor.name;
27
29
  }
28
30
 
29
31
  setupEndpoints(server: any) {
@@ -11,6 +11,8 @@ export default class AdminForthPlugin {
11
11
  this.pluginDir = currentFileDir(metaUrl);
12
12
  this.customFolderPath = path.join(this.pluginDir, this.customFolderName);
13
13
  this.pluginOptions = pluginOptions;
14
+ console.log(`🪲 🪲 🪲 🪲 🪲 🪲 AdminForthPlugin.constructor`, this.constructor.name);
15
+ this.className = this.constructor.name;
14
16
  }
15
17
  setupEndpoints(server) {
16
18
  }
package/dist/index.js CHANGED
@@ -72,6 +72,21 @@ class AdminForth {
72
72
  this.activatedPlugins.push(pluginInstance);
73
73
  });
74
74
  }
75
+ getPluginsByClassName(className) {
76
+ const plugins = this.activatedPlugins.filter((plugin) => plugin.className === className);
77
+ return plugins;
78
+ }
79
+ getPluginByClassName(className) {
80
+ const plugins = this.getPluginsByClassName(className);
81
+ if (plugins.length > 1) {
82
+ throw new Error(`Multiple plugins with className ${className} found. Use getPluginsByClassName instead`);
83
+ }
84
+ if (plugins.length === 0) {
85
+ const similar = suggestIfTypo(this.activatedPlugins.map((p) => p.className), className);
86
+ throw new Error(`Plugin with className ${className} not found. ${similar ? `Did you mean ${similar}?` : ''}`);
87
+ }
88
+ return plugins[0];
89
+ }
75
90
  discoverDatabases() {
76
91
  return __awaiter(this, void 0, void 0, function* () {
77
92
  this.statuses.dbDiscover = 'running';
package/index.ts CHANGED
@@ -126,6 +126,23 @@ class AdminForth implements IAdminForth {
126
126
  );
127
127
  }
128
128
 
129
+ getPluginsByClassName<T>(className: string): T[] {
130
+ const plugins = this.activatedPlugins.filter((plugin) => plugin.className === className);
131
+ return plugins as T[];
132
+ }
133
+
134
+ getPluginByClassName<T>(className: string): T {
135
+ const plugins = this.getPluginsByClassName(className);
136
+ if (plugins.length > 1) {
137
+ throw new Error(`Multiple plugins with className ${className} found. Use getPluginsByClassName instead`);
138
+ }
139
+ if (plugins.length === 0) {
140
+ const similar = suggestIfTypo(this.activatedPlugins.map((p) => p.className), className);
141
+ throw new Error(`Plugin with className ${className} not found. ${similar ? `Did you mean ${similar}?` : ''}`);
142
+ }
143
+ return plugins[0] as T;
144
+ }
145
+
129
146
  async discoverDatabases() {
130
147
  this.statuses.dbDiscover = 'running';
131
148
  this.connectorClasses = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.3.54-next.0",
3
+ "version": "1.3.54-next.2",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div class="relative">
3
3
  <component
4
+ v-if="!loading"
4
5
  v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.beforeBreadcrumbs || []"
5
6
  :is="getCustomComponent(c)"
6
7
  :meta="c.meta"
@@ -103,6 +104,7 @@
103
104
  </div>
104
105
 
105
106
  <component
107
+ v-if="!loading"
106
108
  v-for="c in coreStore?.resourceOptions?.pageInjections?.show?.bottom || []"
107
109
  :is="getCustomComponent(c)"
108
110
  :meta="c.meta"
@@ -325,6 +325,7 @@ export interface IAdminForthPlugin {
325
325
  customFolderPath: string;
326
326
  pluginOptions: any;
327
327
  resourceConfig: AdminForthResource;
328
+ className: string;
328
329
 
329
330
  /**
330
331
  * Before activating all plugins are sorted by this number and then activated in order.