refactor: 💡 remove grant_scope_id and its uses (#2325)
✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13877
This commit is contained in:
1 parent
c6a917d21b
commit
e60b774d05
8 files changed
-117
No files matched your search
@@ -22,12 +22,6 @@ export default class GeneratedRoleModel extends BaseModel {
|
||||
})
|
||||
description;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
"The scope to which this role applies. Defaults to the role's scope.",
|
||||
})
|
||||
grant_scope_id;
|
||||
|
||||
@attr('array', {
|
||||
description:
|
||||
"The scopes to which this role applies. Defaults to the role's scope.",
|
||||
|
||||
@@ -33,15 +33,6 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
*/
|
||||
@attr({ readOnly: true, emptyArrayIfMissing: true }) grant_strings;
|
||||
|
||||
/**
|
||||
* Convenience for looking up the grant scope, if loaded.
|
||||
*/
|
||||
get grantScope() {
|
||||
return this.grant_scope_id
|
||||
? this.store.peekRecord('scope', this.grant_scope_id)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of IDs for principals of type `user`.
|
||||
* @type {string[]}
|
||||
|
||||
@@ -26,8 +26,6 @@ export default factory.extend({
|
||||
],
|
||||
|
||||
id: () => generateId('r_'),
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
grant_scope_id: 'this',
|
||||
grant_scope_ids: () => ['this'],
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,8 +39,6 @@ export default ApplicationSerializer.extend({
|
||||
if (!json.principals.length) delete json.principals;
|
||||
|
||||
// default grant scopes
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
if (!json.grant_scope_id) json.grant_scope_id = 'this';
|
||||
if (json.grant_scope_ids.length === 0) {
|
||||
json.grant_scope_ids = ['this'];
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ module('Unit | Serializer | role', function (hooks) {
|
||||
name: 'User',
|
||||
description: 'Description',
|
||||
version: 1,
|
||||
grant_scope_id: null,
|
||||
grant_scope_ids: [],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,83 +51,6 @@
|
||||
{{/if}}
|
||||
</Hds::Form::Textarea::Field>
|
||||
|
||||
{{#unless @model.isNew}}
|
||||
<fieldset
|
||||
aria-labelledby='legend-text-grant-scope'
|
||||
aria-describedby='helper-text-grant-scope'
|
||||
>
|
||||
<legend id='legend-text-grant-scope'>
|
||||
{{t 'form.grant_scope.label'}}
|
||||
</legend>
|
||||
<Rose::Form::HelperText
|
||||
@id='helper-text-grant-scope'
|
||||
@error={{@model.errors.grant_scope_id}}
|
||||
>
|
||||
{{t 'form.grant_scope.help'}}
|
||||
</Rose::Form::HelperText>
|
||||
<form.radioGroup
|
||||
@name='grant_scope_id'
|
||||
@selectedValue={{@model.grant_scope_id}}
|
||||
@changed={{this.updateGrantScopeID}}
|
||||
as |radioGroup|
|
||||
>
|
||||
<Rose::Dropdown
|
||||
@text={{@model.grantScope.displayName}}
|
||||
@icon={{if
|
||||
@model.grantScope.isProject
|
||||
'flight-icons/svg/grid-16'
|
||||
(if
|
||||
@model.grantScope.isOrg
|
||||
'flight-icons/svg/org-16'
|
||||
'flight-icons/svg/globe-16'
|
||||
)
|
||||
}}
|
||||
as |dropdown|
|
||||
>
|
||||
<ul>
|
||||
{{#each @grantScopes as |grantScope|}}
|
||||
<li class={{if grantScope.model.isProject 'is-project'}}>
|
||||
<dropdown.item>
|
||||
<radioGroup.radio
|
||||
@label={{grantScope.model.displayName}}
|
||||
@value={{grantScope.model.id}}
|
||||
@icon={{concat 'app-icons/' grantScope.model.type}}
|
||||
/>
|
||||
</dropdown.item>
|
||||
<ul class='indent-label-1'>
|
||||
{{#each grantScope.subScopes as |subScope|}}
|
||||
<li class={{if subScope.model.isProject 'is-project'}}>
|
||||
<dropdown.item>
|
||||
<radioGroup.radio
|
||||
@label={{subScope.model.displayName}}
|
||||
@value={{subScope.model.id}}
|
||||
@icon={{concat 'app-icons/' subScope.model.type}}
|
||||
/>
|
||||
</dropdown.item>
|
||||
<ul class='indent-label-2'>
|
||||
{{#each subScope.subScopes as |subSubScope|}}
|
||||
<li class={{if subSubScope.isProject 'is-project'}}>
|
||||
<dropdown.item>
|
||||
<radioGroup.radio
|
||||
@label={{subSubScope.displayName}}
|
||||
@value={{subSubScope.id}}
|
||||
@icon={{concat 'app-icons/' subSubScope.type}}
|
||||
/>
|
||||
</dropdown.item>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</Rose::Dropdown>
|
||||
</form.radioGroup>
|
||||
</fieldset>
|
||||
<br />
|
||||
{{/unless}}
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class FormRoleGrantsComponent extends Component {
|
||||
// =actions
|
||||
|
||||
@action
|
||||
updateGrantScopeID(id) {
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
this.args.model.grant_scope_id = id;
|
||||
this.args.model.grant_scope_ids = [id];
|
||||
}
|
||||
}
|
||||
@@ -132,8 +132,6 @@ export default class OnboardingRoute extends Route {
|
||||
|
||||
async createGrants(org, project, target, role) {
|
||||
role.scopeID = org.id;
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
role.grant_scope_id = project.id;
|
||||
role.grant_scope_ids = [project.id];
|
||||
try {
|
||||
await role.save();
|
||||
|
||||
Reference in new issue
Block a user