refactor: 💡 implement new pathing for hosts

This commit is contained in:
Randall Morey committed 2020-09-10 17:59:31 -04:00
1 parent 2d29d2216f
commit ebf129d35b
21 files changed
+106 -113

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ export default class HostSetAdapter extends ApplicationAdapter {
// =attributes
/**
* Host catalogs use the new, unprefixed pathing style.
* Host sets use the new, unprefixed pathing style.
* @override
*/
hasScopePrefix = false;
+3 -23
View File
@@ -7,32 +7,12 @@ export default class HostAdapter extends ApplicationAdapter {
@service store;
// =methods
// =attributes
/**
* Append a host catalog URL ahead of the host path if `hostCatalogID` is
* passed via adapter options. Otherwise, generate the prefix as normal.
*
* TODO: generalize the interface to resource-prefixed URLs by accepting
* a modelName and an ID, rather than looking for a known key.
*
* Hosts use the new, unprefixed pathing style.
* @override
* @param {string} path
* @param {string} parentURL
* @param {string} modelName
* @param {string} id
* @param {object} snapshot
* @return {string} urlPrefix
*/
urlPrefix(path, parentURL, modelName, id, snapshot) {
const hostCatalogID = snapshot?.adapterOptions?.hostCatalogID;
if (hostCatalogID) {
const hostCatalogAdapter = this.store.adapterFor('host-catalog');
return hostCatalogAdapter
._buildPrefixedURL('host-catalog', hostCatalogID, snapshot);
} else {
return super.urlPrefix(...arguments);
}
}
hasScopePrefix = false;
}
@@ -15,7 +15,6 @@ export default class GeneratedHostSetModel extends BaseModel {
@attr('string', {
description: 'The owning host catalog ID.',
readOnly: true
}) host_catalog_id;
@attr('string', {
@@ -12,6 +12,10 @@ export default class GeneratedHostModel extends BaseModel {
description: 'The type of the resource, to help differentiate schemas'
}) type;
@attr('string', {
description: 'The owning host catalog ID.',
}) host_catalog_id;
@attr('string', {
description: 'Optional name for identification purposes'
}) name;
-13
View File
@@ -1,6 +1,5 @@
import GeneratedHostSetModel from '../generated/models/host-set';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
//import { computed } from '@ember/object';
export default class HostSetModel extends GeneratedHostSetModel {
@@ -12,18 +11,6 @@ export default class HostSetModel extends GeneratedHostSetModel {
*/
@fragmentArray('fragment-string', {readOnly: true}) host_ids;
// TODO this is here in case we want it in the future,
// especially for the target / add host sets workflow
/**
* Returns the host catalog instance associated with this host set if
* it is already loaded into the store.
* @type {?HostCatalogModel}
*/
// @computed('host_catalog_id')
// get hostCatalog() {
// return this.store.peekRecord('host-catalog', this.host_catalog_id);
// }
// =methods
/**
+13
View File
@@ -0,0 +1,13 @@
import ApplicationSerializer from './application';
export default class HostSerializer extends ApplicationSerializer {
// =attributes
/**
* Serialized the scope ID into the `scope_id` field.
* @type {boolean}
*/
serializeScopeID = true;
}