From 94530cec9cad9b644db4cf76c19320ddc809e46e Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 18 Jul 2022 16:36:43 -0700 Subject: [PATCH] Feature cross scope group members (#1196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 🤖 add scope column to role principals and group members * chore: 🤖 add recursion and filtering to user and group mocks * feat: 🎸 expose groups and roles on projects * feat: 🎸 enable cross-scope assignment of group members --- addons/api/mirage/scenarios/default.js | 2 +- ui/admin/app/components/form/role/add-principals/index.hbs | 3 --- ui/admin/app/routes/scopes.js | 7 ++++++- .../app/routes/scopes/scope/groups/group/add-members.js | 5 ++--- ui/admin/tests/acceptance/authentication-test.js | 5 ++++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/addons/api/mirage/scenarios/default.js b/addons/api/mirage/scenarios/default.js index f03170eb4..368d1299e 100644 --- a/addons/api/mirage/scenarios/default.js +++ b/addons/api/mirage/scenarios/default.js @@ -17,7 +17,7 @@ export default function (server) { 'withChildren' )[0]; - server.create('user', { id: 'authenticateduser' }); + server.create('user', { id: 'authenticateduser', scope: globalScope }); // Auth const globalAuthMethods = server.createList( diff --git a/ui/admin/app/components/form/role/add-principals/index.hbs b/ui/admin/app/components/form/role/add-principals/index.hbs index 9fa698c63..546ff86d8 100644 --- a/ui/admin/app/components/form/role/add-principals/index.hbs +++ b/ui/admin/app/components/form/role/add-principals/index.hbs @@ -62,9 +62,6 @@ - - - {{principal.description}} {{/each}} diff --git a/ui/admin/app/routes/scopes.js b/ui/admin/app/routes/scopes.js index 4f53d4955..d9ac05ba9 100644 --- a/ui/admin/app/routes/scopes.js +++ b/ui/admin/app/routes/scopes.js @@ -13,7 +13,12 @@ export default class ScopesRoute extends Route { * @param {string} params.scope_id * @return {Promise{[ScopeModel]}} */ - model() { + async model() { + // Always preload the global scope, if possible, since the query below + // only fetches org scopes. + await this.store.findRecord('scope', 'global').catch(() => { + /* no op */ + }); // NOTE: In the absence of a `scope_id` query parameter, this endpoint is // expected to default to the global scope, thus returning org scopes. return this.store.findAll('scope').catch(() => A([])); diff --git a/ui/admin/app/routes/scopes/scope/groups/group/add-members.js b/ui/admin/app/routes/scopes/scope/groups/group/add-members.js index 7629c17d9..4906130cd 100644 --- a/ui/admin/app/routes/scopes/scope/groups/group/add-members.js +++ b/ui/admin/app/routes/scopes/scope/groups/group/add-members.js @@ -26,11 +26,10 @@ export default class ScopesScopeGroupsGroupAddMembersRoute extends Route { * @return {Promise{GroupModel, [UserModel]}} */ model() { - const group = this.modelFor('scopes.scope.groups.group'); - const { scopeID: scope_id } = group; return hash({ group: this.modelFor('scopes.scope.groups.group'), - users: this.store.query('user', { scope_id }), + // load all users from all scopes + users: this.store.query('user', { scope_id: 'global', recursive: true }), }); } diff --git a/ui/admin/tests/acceptance/authentication-test.js b/ui/admin/tests/acceptance/authentication-test.js index df8b7ad9b..130a40d84 100644 --- a/ui/admin/tests/acceptance/authentication-test.js +++ b/ui/admin/tests/acceptance/authentication-test.js @@ -7,7 +7,7 @@ import { find, findAll, getRootElement, - //setupOnerror, + setupOnerror, } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; @@ -115,6 +115,9 @@ module('Acceptance | authentication', function (hooks) { test('visiting auth method when the scope cannot be loaded is still allowed', async function (assert) { assert.expect(1); + setupOnerror(() => { + // do nothing, otherwise an uncaught adapter error will fail the test + }); this.server.get('/scopes', () => { return new Response(404); });