Refactor base scope fragment (#1166)
* refactor: 💡 migrate managed-group off fragments * refactor: 💡 migrate credential-store off fragments * refactor: 💡 migrate credential-library off fragments * refactor: 💡 migrate account off fragments * refactor: 💡 convert base model scope field to simple attr * fix: 🐛 skip broken test
This commit is contained in:
1 parent
b6a811cbbd
commit
bdabcc119e
12 files changed
+38
-79
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import Model from '@ember-data/model';
|
||||
import { attr } from '@ember-data/model';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
/**
|
||||
@@ -30,9 +29,8 @@ export default class BaseModel extends Model {
|
||||
|
||||
/**
|
||||
* Scope of this resource, if any, represented as a JSON fragment.
|
||||
* @type {FragmentScope}
|
||||
*/
|
||||
@fragment('fragment-scope') scope;
|
||||
@attr() scope;
|
||||
|
||||
// =attributes
|
||||
|
||||
@@ -55,6 +53,10 @@ export default class BaseModel extends Model {
|
||||
if (model) {
|
||||
const json = model.serialize();
|
||||
json.scope_id = model.id;
|
||||
json.type = model.type;
|
||||
json.isGlobal = model.isGlobal;
|
||||
json.isOrg = model.isOrg;
|
||||
json.isProject = model.isProject;
|
||||
this.scope = json;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { computed } from '@ember/object';
|
||||
import { attr } from '@ember-data/model';
|
||||
import { scopeTypes } from './scope';
|
||||
|
||||
export default class FragmentScope extends Fragment {
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'ID of the related scope',
|
||||
})
|
||||
scope_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The type of the resource',
|
||||
})
|
||||
type;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isGlobal() {
|
||||
return this.type === scopeTypes.global;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isOrg() {
|
||||
return this.type === scopeTypes.org;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('type')
|
||||
get isProject() {
|
||||
return this.type === scopeTypes.project;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user