From a477facdbfcbd818893746fdfe856e975b812907 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Sun, 10 Mar 2024 09:57:14 +0800 Subject: [PATCH] chore: move collection manager snippets into data source (#3666) --- packages/core/acl/src/snippet-manager.ts | 2 +- .../plugin-collection-manager/src/server/server.ts | 5 ----- .../plugin-data-source-manager/src/server/plugin.ts | 10 +++++++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/core/acl/src/snippet-manager.ts b/packages/core/acl/src/snippet-manager.ts index 2a66915fa..e7826fa91 100644 --- a/packages/core/acl/src/snippet-manager.ts +++ b/packages/core/acl/src/snippet-manager.ts @@ -31,7 +31,7 @@ class SnippetManager { const snippet = this.snippets.get(snippetName); if (!snippet) { - throw new Error(`Snippet ${snippetName} not found`); + return null; } const matched = snippet.actions.some((action) => minimatch(actionPath, action)); diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/server/server.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/server/server.ts index f6823a8bb..2fea0b6ad 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/server/server.ts @@ -51,11 +51,6 @@ export class CollectionManagerPlugin extends Plugin { }, }); - this.app.acl.registerSnippet({ - name: `pm.${this.name}.collections`, - actions: ['collections:*', 'collections.fields:*', 'dbViews:*', 'collectionCategories:*', 'sqlCollection:*'], - }); - this.app.db.on('collections.beforeCreate', async (model) => { if (this.app.db.inDialect('postgres') && this.schema && model.get('from') != 'db2cm' && !model.get('schema')) { model.set('schema', this.schema); diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts index 154712d4d..ea4933139 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/plugin.ts @@ -472,7 +472,15 @@ export class PluginDataSourceManagerServer extends Plugin { this.app.acl.registerSnippet({ name: `pm.${this.name}`, - actions: ['dataSources:*', 'roles.dataSourceResources'], + actions: [ + 'dataSources:*', + 'roles.dataSourceResources', + 'collections:*', + 'collections.fields:*', + 'dbViews:*', + 'collectionCategories:*', + 'sqlCollection:*', + ], }); this.app.acl.allow('dataSources', 'listEnabled', 'loggedIn');