From df2137da79a11d7c7ee74850491c70dfd90fcd65 Mon Sep 17 00:00:00 2001 From: Junyi Date: Thu, 18 Feb 2021 08:55:46 +0800 Subject: [PATCH] Feature: filter for linkTo field (#64) * feat: add scope select for relation field * fix: add associatedKey support for drawerSelect component * refactor: use 'component.x-component-props.filter' as filter type * fix: remove user group field Co-authored-by: chenos --- .../migrations/add-lock-to-actions-scopes.ts | 4 +-- .../app/src/api/migrations/add-permissions.ts | 2 +- .../migrations/create-action-logs-table.ts | 4 +-- .../form.fields/permissions/index.tsx | 4 +-- .../src/collections/collections.ts | 26 ++++++++++++++++++ .../src/collections/fields.ts | 27 +++++++++++++++++++ .../src/collections/scopes.ts} | 2 +- .../src/AccessController.ts | 2 +- .../plugin-permissions/src/__tests__/seed.ts | 12 ++++++--- .../src/collections/actions_permissions.ts | 2 +- .../src/collections/collections.ts | 26 ------------------ 11 files changed, 71 insertions(+), 40 deletions(-) rename packages/{plugin-permissions/src/collections/actions_scopes.ts => plugin-collections/src/collections/scopes.ts} (97%) diff --git a/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts b/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts index 0e8ffc48e..3fe150944 100644 --- a/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts +++ b/packages/app/src/api/migrations/add-lock-to-actions-scopes.ts @@ -5,12 +5,12 @@ import Database from '@nocobase/database'; await api.loadPlugins(); const database: Database = api.database; await api.database.sync({ - tables: ['actions_scopes'], + tables: ['scopes'], }); const [Collection, User, Role] = database.getModels(['collections', 'users', 'roles']); - const tables = database.getTables(['actions_scopes']); + const tables = database.getTables(['scopes']); for (let table of tables) { console.log(table.getName()); diff --git a/packages/app/src/api/migrations/add-permissions.ts b/packages/app/src/api/migrations/add-permissions.ts index 5e5ab5c87..ccb0a42b6 100644 --- a/packages/app/src/api/migrations/add-permissions.ts +++ b/packages/app/src/api/migrations/add-permissions.ts @@ -38,7 +38,7 @@ import Database from '@nocobase/database'; parent_id: parent.id, }); - const Scope = database.getModel('actions_scopes'); + const Scope = database.getModel('scopes'); const collections = await Collection.findAll(); diff --git a/packages/app/src/api/migrations/create-action-logs-table.ts b/packages/app/src/api/migrations/create-action-logs-table.ts index bf10af056..9db4eb413 100644 --- a/packages/app/src/api/migrations/create-action-logs-table.ts +++ b/packages/app/src/api/migrations/create-action-logs-table.ts @@ -5,12 +5,12 @@ import Database from '@nocobase/database'; await api.loadPlugins(); const database: Database = api.database; await api.database.sync({ - tables: ['actions_scopes', 'action_logs', 'action_changes'], + tables: ['scopes', 'action_logs', 'action_changes'], }); const [Collection, Page] = database.getModels(['collections', 'pages']); - const tables = database.getTables(['actions_scopes', 'action_logs', 'action_changes']); + const tables = database.getTables(['scopes', 'action_logs', 'action_changes']); for (let table of tables) { console.log(table.getName()); diff --git a/packages/app/src/components/form.fields/permissions/index.tsx b/packages/app/src/components/form.fields/permissions/index.tsx index 889191849..77d1bbda4 100644 --- a/packages/app/src/components/form.fields/permissions/index.tsx +++ b/packages/app/src/components/form.fields/permissions/index.tsx @@ -72,10 +72,10 @@ Permissions.Actions = connect({ const index = findIndex(values, (item: any) => item && item.name === `${resourceKey}:${record.name}`); return (