From 81fb4268b9009e9d9a9f463920b9e5abed6b9b3d Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 3 Nov 2020 12:01:46 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20initial=20grant=20scopes?= =?UTF-8?q?=20field=20for=20role=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/app/components/form/role/index.hbs | 38 +++++++++++++++++++ ui/core/app/components/form/role/index.js | 18 +++++++++ .../routes/scopes/scope/roles/role/index.js | 31 ++++++++++++++- ui/core/app/styles/app.scss | 12 ++++++ .../scopes/scope/roles/role/index.hbs | 2 +- ui/core/tests/acceptance/roles-test.js | 8 ++++ ui/core/translations/form/en-us.yaml | 3 ++ 7 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 ui/core/app/components/form/role/index.js diff --git a/ui/core/app/components/form/role/index.hbs b/ui/core/app/components/form/role/index.hbs index 0e024b1fb..2b94423a5 100644 --- a/ui/core/app/components/form/role/index.hbs +++ b/ui/core/app/components/form/role/index.hbs @@ -44,6 +44,44 @@ {{/if}} + + + {{#each @grantScopes as |grantScope|}} + + + + {{#each grantScope.subScopes as |subScope|}} + + + + {{#each subScope.subScopes as |subSubScope|}} + + + + {{/each}} + {{/each}} + {{/each}} + + +        {{t "form.grant_scope.help"}} + + + +
+
+ ({ + model: scope, + subScopes: this.store.query('scope', { scope_id: scope.id }) + })); + const grantScopes = [{ + model: defaultScope, + subScopes + }]; + this.set('grantScopes', grantScopes); + } + + /** + * Adds `grantScopes` to the context. + * @param {Controller} controller + */ + setupController(controller) { + super.setupController(...arguments); + controller.set('grantScopes', this.grantScopes); + } + +} diff --git a/ui/core/app/styles/app.scss b/ui/core/app/styles/app.scss index 609a7aced..5de632e91 100644 --- a/ui/core/app/styles/app.scss +++ b/ui/core/app/styles/app.scss @@ -42,6 +42,18 @@ width: 100%; } } + + .rose-dropdown { + .rose-dropdown-item { + &.indent-1 { + padding-left: sizing.rems(s) * 2; + } + + &.indent-2 { + padding-left: sizing.rems(l) + sizing.rems(m); + } + } + } } .rose-table { diff --git a/ui/core/app/templates/scopes/scope/roles/role/index.hbs b/ui/core/app/templates/scopes/scope/roles/role/index.hbs index e72610ec6..44c14fe3a 100644 --- a/ui/core/app/templates/scopes/scope/roles/role/index.hbs +++ b/ui/core/app/templates/scopes/scope/roles/role/index.hbs @@ -1,6 +1,6 @@ - diff --git a/ui/core/tests/acceptance/roles-test.js b/ui/core/tests/acceptance/roles-test.js index 4060a9cd1..aa2f2fac1 100644 --- a/ui/core/tests/acceptance/roles-test.js +++ b/ui/core/tests/acceptance/roles-test.js @@ -19,6 +19,7 @@ module('Acceptance | roles', function (hooks) { scopes: { global: null, org: null, + project: null, }, role: null, }; @@ -36,6 +37,13 @@ module('Acceptance | roles', function (hooks) { type: 'org', scope: { id: 'global', type: 'global' }, }); + // The project scope is not yet used for role tests (though it will be + // in the future). This is created simply to test the grant scope loading + // mechanism. + instances.scopes.project = this.server.create('scope', { + type: 'project', + scope: { id: instances.scopes.org.id, type: instances.scopes.org.type }, + }); instances.role = this.server.create('role', { scope: instances.scopes.org, }, 'withPrincipals'); diff --git a/ui/core/translations/form/en-us.yaml b/ui/core/translations/form/en-us.yaml index de24444fc..2971b77b6 100644 --- a/ui/core/translations/form/en-us.yaml +++ b/ui/core/translations/form/en-us.yaml @@ -43,3 +43,6 @@ session_connection_limit: help: The maximum number of connections allowed per session. For unlimited, specify "-1". host_set: label: Host Set +grant_scope: + label: Grant Scope + help: Specify the scope to which this role applies.