refactor: 💡 convert brokered cred IDs array to simple attribute (#1259)

* refactor: 💡 convert brokered cred IDs array to simple attribute

* fix: 🐛 missing test assertion

* fix: 🐛 simplify computed

* refactor: 💡 convert host sources array to simple attribute (#1260)

* refactor: 💡 convert host source IDs array to simple attribute

* fix: 🐛 host source tests

* Refactor role fragment arrays (#1262)

* refactor: 💡 convert grant strings to regular attribute

* refactor: 💡 convert principals array to simple attribute

* Update ui/admin/app/routes/scopes/scope/roles/role.js

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

* fix: 🐛 remove unused import

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
Randall MoreyandZhihe Li authored and GitHub committed 2022-08-31 09:55:59 -07:00
1 parent 83c7b76f48
commit cde6abd445
28 files changed
+147 -182

No files matched your search

@@ -1,16 +0,0 @@
import Fragment from 'ember-data-model-fragments/fragment';
import { attr } from '@ember-data/model';
export default class FragmentHostSourceModel extends Fragment {
// =attributes
@attr('string', {
description: 'ID of the related host source',
})
host_source_id;
@attr('string', {
description: 'ID of the catalog to which the host set belongs',
})
host_catalog_id;
}
@@ -1,21 +0,0 @@
import Fragment from 'ember-data-model-fragments/fragment';
import { attr } from '@ember-data/model';
export default class FragmentPrincipal extends Fragment {
// =attributes
@attr('string', {
description: 'ID of the related scope',
})
scope_id;
@attr('string', {
description: 'ID of the related principal (user or group)',
})
principal_id;
@attr('string', {
description: 'Type of the related principal (user or group)',
})
type;
}
+3 -3
View File
@@ -1,5 +1,5 @@
import GeneratedRoleModel from '../generated/models/role';
import { fragmentArray, array } from 'ember-data-model-fragments/attributes';
import { attr } from '@ember-data/model';
export default class RoleModel extends GeneratedRoleModel {
// =attributes
@@ -11,7 +11,7 @@ export default class RoleModel extends GeneratedRoleModel {
* see obvious. Instead, the application layer is expected to load referenced
* users and groups as needed.
*/
@fragmentArray('fragment-principal', {
@attr('principal-array', {
readOnly: true,
emptyArrayIfMissing: true,
})
@@ -21,7 +21,7 @@ export default class RoleModel extends GeneratedRoleModel {
* Grant strings are read-only. But grants can be persisted via a dedicated
* call to `saveGrantStrings(grants)`.
*/
@array('string', { readOnly: true }) grant_strings;
@attr({ readOnly: true, emptyArrayIfMissing: true }) grant_strings;
/**
* Convenience for looking up the grant scope, if loaded.
+4 -8
View File
@@ -1,21 +1,19 @@
import GeneratedTargetModel from '../generated/models/target';
import { attr } from '@ember-data/model';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
import { computed } from '@ember/object';
export default class TargetModel extends GeneratedTargetModel {
// =attributes
@attr('number', {
isNestedAttribute: true,
description: 'The default port a target should use if present.',
description: 'The default port a target should use if present.',
})
default_port;
/**
* @type {[FragmentHostSourceModel]}
* @type Array
*/
@fragmentArray('fragment-host-source', {
@attr('host-source-id-array', {
readOnly: true,
emptyArrayIfMissing: true,
})
@@ -25,7 +23,7 @@ export default class TargetModel extends GeneratedTargetModel {
* Credential source ids are read only and can be
* persisted via a dedicated call to `addBrokeredCredentialSources()`.
*/
@fragmentArray('fragment-string', {
@attr('string-array', {
readOnly: true,
emptyArrayIfMissing: true,
})
@@ -37,7 +35,6 @@ export default class TargetModel extends GeneratedTargetModel {
* instances). Unresolvable instances are excluded from the array.
* @type {[{model: HostSetModel, hostCatalog: HostCatalogModel}]}
*/
@computed('host_sources.[]', 'store')
get hostSets() {
return this.host_sources
.map(({ host_source_id, host_catalog_id }) => ({
@@ -53,7 +50,6 @@ export default class TargetModel extends GeneratedTargetModel {
* instances). Unresolvable instances are excluded from the array.
* @type {[CredentialLibraryModel, CredentialModel]}
*/
@computed('brokered_credential_source_ids.[]', 'store')
get brokeredCredentialSources() {
return this.brokered_credential_source_ids
.map((source) => {