Merge branch 'develop' into add-target-type
This commit is contained in:
62 files changed
+47
-734
No files matched your search
@@ -58,54 +58,8 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
|
||||
*/
|
||||
namespace = get(config, 'api.namespace');
|
||||
|
||||
/**
|
||||
* Whether or not to prefix the URL with the resource scope.
|
||||
* @type {boolean}
|
||||
*/
|
||||
hasScopePrefix = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Prepends a scope to the URL prefix. Precedence is given to the ID passed
|
||||
* via `adapterOptions.scopeID`. If this value isn't found in
|
||||
* `adapterOptions`, we look to the `scope.scope_id` field on the snapshot,
|
||||
* which most resources have.
|
||||
*
|
||||
* Note: scopes themselves never receive a scope URL prefix.
|
||||
*
|
||||
* @override
|
||||
* @param {string} path
|
||||
* @param {string} parentURL
|
||||
* @param {string} modelName
|
||||
* @param {string} id
|
||||
* @param {object} snapshot
|
||||
* @return {string}
|
||||
*/
|
||||
urlPrefix(path, parentURL, modelName, id, snapshot) {
|
||||
const prefix = super.urlPrefix(...arguments);
|
||||
let scopePath = '';
|
||||
let scopeID = '';
|
||||
if (snapshot && this.hasScopePrefix) {
|
||||
// Not all snapshots have `attr` (such as array snapshots),
|
||||
// so we do this sort of ugly check.
|
||||
if (snapshot.attr) {
|
||||
const parentScope = snapshot.attr('scope');
|
||||
if (parentScope) scopeID = parentScope.attr('scope_id');
|
||||
}
|
||||
// Attempt to get scopeID from adapterOptions and fallback on its current
|
||||
// value if it wasn't passed through options.
|
||||
scopeID = getWithDefault(snapshot, 'adapterOptions.scopeID', scopeID);
|
||||
}
|
||||
// Only non-scope resources need a scope path, since scope resources
|
||||
// aren't technically "scoped" the same way.
|
||||
// Ensure a slash is added between prefix + scope path if needed.
|
||||
if (scopeID && prefix.charAt(prefix.length - 1) !== '/') {
|
||||
scopePath = `/scopes/${scopeID}`;
|
||||
}
|
||||
return `${prefix}${scopePath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a custom method after a colon, if a method is passed via the
|
||||
* snapshot's `adapterOptions.method` field.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class AuthMethodAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Auth methods use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class GroupAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Groups use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class HostCatalogAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Host catalogs use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class HostSetAdapter extends ApplicationAdapter {
|
||||
|
||||
// =services
|
||||
|
||||
@service store;
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Host sets use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class HostAdapter extends ApplicationAdapter {
|
||||
|
||||
// =services
|
||||
|
||||
@service store;
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Hosts use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class RoleAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Roles use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class ScopeAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Scopes do not include a scope prefix.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class TargetAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Targets use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class UserAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Users use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -8,18 +8,6 @@ import { copy } from 'ember-copy';
|
||||
*/
|
||||
export default class ApplicationSerializer extends RESTSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
attrs = {
|
||||
scope: { serialize: false }
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether or not to serialize the scope ID into scope_id.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = false;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -81,10 +69,11 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
*/
|
||||
serialize(snapshot) {
|
||||
const serialized = super.serialize(...arguments);
|
||||
if (this.serializeScopeID) {
|
||||
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
|
||||
if (scope_id) serialized.scope_id = scope_id;
|
||||
}
|
||||
// Delete `scope` field
|
||||
delete serialized.scope;
|
||||
// And serialize `scope_id`
|
||||
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
|
||||
if (scope_id) serialized.scope_id = scope_id;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class AuthMethodSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
|
||||
|
||||
export default class GroupSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostCatalogSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostSetSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
@@ -3,14 +3,6 @@ import { get } from '@ember/object';
|
||||
|
||||
export default class RoleSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class ScopeSerializer extends ApplicationSerializer {
|
||||
|
||||
/**
|
||||
* Serialize the scope ID into scope_id.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
@@ -2,14 +2,6 @@ import ApplicationSerializer from './application';
|
||||
|
||||
export default class TargetSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class UserSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user