refactor: 💡 upgrade addons/api to Ember 3.24

This commit is contained in:
Randall Morey committed 2021-03-04 15:47:38 -05:00
1 parent 050c2577d0
commit fbf39b3bba
92 files changed
+1348 -621

No files matched your search

+2 -1
View File
@@ -18,7 +18,8 @@ export default class GeneratedRoleModel extends BaseModel {
description;
@attr('string', {
description: 'The scope to which this role applies. Defaults to the role\'s scope.',
description:
"The scope to which this role applies. Defaults to the role's scope.",
})
grant_scope_id;
@@ -2,7 +2,6 @@ import BaseModel from '../../models/base';
import { attr } from '@ember-data/model';
export default class GeneratedSessionModel extends BaseModel {
// =attributes
@attr('string') user_id;
@@ -32,5 +31,4 @@ export default class GeneratedSessionModel extends BaseModel {
description: 'Current version number of this resource.',
})
version;
}
+2 -2
View File
@@ -24,13 +24,13 @@ export default class GeneratedTargetModel extends BaseModel {
@attr('number', {
description: '',
defaultValue: 28800
defaultValue: 28800,
})
session_max_seconds;
@attr('number', {
description: '',
defaultValue: 1
defaultValue: 1,
})
session_connection_limit;
-1
View File
@@ -4,7 +4,6 @@ import { computed } from '@ember/object';
import { equal } from '@ember/object/computed';
export default class AccountModel extends GeneratedAccountModel {
// =attributes
/**
-1
View File
@@ -25,7 +25,6 @@ import { computed } from '@ember/object';
* 2) Or as an ID: `record.scopeID`.
*/
export default class BaseModel extends Model {
// =relationships
/**
-1
View File
@@ -2,7 +2,6 @@ import GeneratedHostSetModel from '../generated/models/host-set';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
export default class HostSetModel extends GeneratedHostSetModel {
// =attributes
/**
-2
View File
@@ -2,11 +2,9 @@ import GeneratedHostModel from '../generated/models/host';
import { fragment } from 'ember-data-model-fragments/attributes';
export default class HostModel extends GeneratedHostModel {
/**
* Attributes of this resource, if any, represented as a JSON fragment.
* @type {FragmentHostAttributesModel}
*/
@fragment('fragment-host-attributes', { defaultValue: {} }) attributes;
}
+1 -1
View File
@@ -35,7 +35,7 @@ export default class RoleModel extends GeneratedRoleModel {
return this.save({
adapterOptions: {
method: 'set-grants',
grantStrings
grantStrings,
},
});
}
-2
View File
@@ -4,7 +4,6 @@ import { equal } from '@ember/object/computed';
import { attr } from '@ember-data/model';
export default class SessionModel extends GeneratedSessionModel {
// =attributes
@attr('string', { readOnly: true }) proxy_address;
@@ -61,5 +60,4 @@ export default class SessionModel extends GeneratedSessionModel {
},
});
}
}
+6 -4
View File
@@ -41,8 +41,9 @@ export default class TargetModel extends GeneratedTargetModel {
* @type {SessionModel[]}
*/
get sessions() {
return this.store.peekAll('session')
.filter(s => s && (s.target_id === this.id));
return this.store
.peekAll('session')
.filter((s) => s && s.target_id === this.id);
}
/**
@@ -58,8 +59,9 @@ export default class TargetModel extends GeneratedTargetModel {
* @type {boolean}
*/
get isActive() {
const pendingOrActiveSessions =
this.sessions.filter(s => s.isActive || s.isPending);
const pendingOrActiveSessions = this.sessions.filter(
(s) => s.isActive || s.isPending
);
return Boolean(pendingOrActiveSessions.length);
}
-2
View File
@@ -3,7 +3,6 @@ import { attr } from '@ember-data/model';
import { A } from '@ember/array';
export default class UserModel extends GeneratedUserModel {
// =attributes
/**
@@ -74,5 +73,4 @@ export default class UserModel extends GeneratedUserModel {
removeAccount(accountID, options) {
return this.removeAccounts([accountID], options);
}
}
-1
View File
@@ -1,7 +1,6 @@
import ApplicationSerializer from './application';
export default class AccountSerializer extends ApplicationSerializer {
// =properties
/**
+1 -2
View File
@@ -7,7 +7,6 @@ import { copy } from 'ember-copy';
* Manages serialization/normalization of data to/from the API.
*/
export default class ApplicationSerializer extends RESTSerializer {
// =properties
/**
@@ -82,7 +81,7 @@ export default class ApplicationSerializer extends RESTSerializer {
// Delete `scope` field
delete serialized.scope;
// And serialize `scope_id`
if(this.serializeScopeID) {
if (this.serializeScopeID) {
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
if (scope_id) serialized.scope_id = scope_id;
}
-1
View File
@@ -1,7 +1,6 @@
import ApplicationSerializer from './application';
export default class HostSetSerializer extends ApplicationSerializer {
// =properties
/**
-2
View File
@@ -1,12 +1,10 @@
import ApplicationSerializer from './application';
export default class HostSerializer extends ApplicationSerializer {
// =properties
/**
* @type {boolean}
*/
serializeScopeID = false;
}
+3 -3
View File
@@ -17,8 +17,8 @@ export default class RoleSerializer extends ApplicationSerializer {
serialize(snapshot) {
const grantStrings = get(snapshot, 'adapterOptions.grantStrings');
let serialized = super.serialize(...arguments);
if (grantStrings) serialized =
this.serializeWithGrantStrings(snapshot, grantStrings);
if (grantStrings)
serialized = this.serializeWithGrantStrings(snapshot, grantStrings);
const principalIDs = snapshot?.adapterOptions?.principalIDs;
if (principalIDs)
serialized = this.serializewithPrincipals(snapshot, principalIDs);
@@ -34,7 +34,7 @@ export default class RoleSerializer extends ApplicationSerializer {
serializeWithGrantStrings(snapshot, grantStrings) {
return {
version: snapshot.attr('version'),
grant_strings: grantStrings
grant_strings: grantStrings,
};
}
+2 -2
View File
@@ -13,8 +13,8 @@ export default class UserSerializer extends ApplicationSerializer {
serialize(snapshot) {
let serialized = super.serialize(...arguments);
const accountIDs = snapshot?.adapterOptions?.accountIDs;
if (accountIDs) serialized =
this.serializewithAccounts(snapshot, accountIDs);
if (accountIDs)
serialized = this.serializewithAccounts(snapshot, accountIDs);
return serialized;
}