Skip to content

Commit c09003a

Browse files
committed
feat: add shouldHaveSingleInstancePerWholeApp method to AdminForthPlugin interface and implementations
1 parent b3d0593 commit c09003a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

adminforth/basePlugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
3636
return 'non-uniquely-identified';
3737
}
3838

39+
shouldHaveSingleInstancePerWholeApp(): boolean {
40+
return true;
41+
}
42+
3943
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource, allPluginInstances?: {pi: AdminForthPlugin, resource: AdminForthResource}[]) {
4044
this.resourceConfig = resourceConfig;
4145
const uniqueness = this.instanceUniqueRepresentation(this.pluginOptions);

adminforth/commands/createPlugin/templates/index.ts.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export default class {{pluginName}} extends AdminForthPlugin {
2727
return `single`;
2828
}
2929

30+
shouldHaveSingleInstancePerWholeApp(): boolean {
31+
return false;
32+
}
33+
3034
setupEndpoints(server: IHttpServer) {
3135
server.endpoint({
3236
method: 'POST',

adminforth/types/Back.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ export interface IAdminForthPlugin {
468468
instanceUniqueRepresentation(pluginOptions: any) : string;
469469

470470

471+
/**
472+
* If this method returns true, AdminForth will allow only one instance of plugin per whole app
473+
* (only for case when we are creating copy of resource and activating plugins)
474+
* If false, multiple instances of plugin can be installed on different resources.
475+
*/
476+
shouldHaveSingleInstancePerWholeApp(): boolean;
477+
471478
/**
472479
* Optional method which will be called after AdminForth discovers all resources and their columns.
473480
* Can be used to validate types of columns, check if some columns are missing, etc.

0 commit comments

Comments
 (0)