Merge branch 'develop' into ICU-179-tab-component

This commit is contained in:
Randall Morey authored and GitHub committed 2020-06-05 13:28:24 -04:00
commit 420251d696
13 files changed
+131 -12

No files matched your search

+13
View File
@@ -1,6 +1,8 @@
import RESTAdapter from '@ember-data/adapter/rest';
import config from 'ember-get-config';
import { get } from '@ember/object';
import { dasherize } from '@ember/string';
import { pluralize } from 'ember-inflector';
export default class ApplicationAdapter extends RESTAdapter {
// =attributes
@@ -21,6 +23,17 @@ export default class ApplicationAdapter extends RESTAdapter {
// =methods
/**
* Transforms the type to a dasherized string used in our API paths.
*
* @override
* @param {string} type
* @return {string}
*/
pathForType(type) {
return dasherize(pluralize(type));
}
/**
* Overrides default ajax method by rewritting PUT requests as PATCH.
* PATCH is the request method used by our API for updates.
@@ -0,0 +1,6 @@
import ApplicationAdapter from './application';
import ScopeAdapterMixin from '../mixins/scope-adapter';
export default class HostCatalogAdapter extends ApplicationAdapter.extend(
ScopeAdapterMixin
) { }
@@ -0,0 +1,41 @@
import BaseModel from '../../models/base';
import { attr } from '@ember-data/model';
/**
* HostCatalog manages Hosts and HostSets
*/
export default class GeneratedHostCatalogModel extends BaseModel {
// =attributes
@attr('string', {
description: 'The type of the resource, to help differentiate schemas'
}) type;
@attr('string', {
description: 'Optional name for identification purposes'
}) name;
@attr('string', {
description: 'Optional user-set description for identification purposes'
}) description;
@attr('date', {
description: 'The time this resource was created\nOutput only.',
readOnly: true
}) created_time;
@attr('date', {
description: 'The time this resource was last updated\nOutput only.',
readOnly: true
}) updated_time;
@attr('boolean', {
description: 'Whether the catalog is disabled'
}) disabled;
@attr({
description: 'Attributes specific to the catalog type'
}) attributes;
}
+3
View File
@@ -0,0 +1,3 @@
import GeneratedHostCatalogModel from '../generated/models/host-catalog';
export default class HostCatalogModel extends GeneratedHostCatalogModel { }
+1
View File
@@ -0,0 +1 @@
export { default } from 'api/adapters/host-catalog';
+1
View File
@@ -0,0 +1 @@
export { default } from 'api/models/host-catalog';
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Adapter | host catalog', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let adapter = this.owner.lookup('adapter:host-catalog');
assert.ok(adapter);
});
});
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | host catalog', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('host-catalog', {});
assert.ok(model);
});
});
+10 -12
View File
@@ -9,24 +9,22 @@ export default function() {
// delay for each request, automatically set to 0 during testing
this.timing = 350;
/*
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
https://www.ember-cli-mirage.com/docs/route-handlers/shorthands
*/
// Allow any configured API host to passthrough, which is useful in
// development for testing against a locally running backend.
if (config.api.host) this.passthrough(`${config.api.host}/**`);
this.passthrough();
// project
this.get('/orgs/:org_id/projects');
this.post('/orgs/:org_id/projects');
this.get('/orgs/:org_id/projects/:id');
this.patch('/orgs/:org_id/projects/:id');
this.del('/orgs/:org_id/projects/:id');
// host-catalog
this.get('/orgs/:org_id/projects/:project_id/host-catalogs');
this.post('/orgs/:org_id/projects/:project_id/host-catalogs');
this.get('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
this.patch('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
this.del('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
}
+3
View File
@@ -0,0 +1,3 @@
import factory from '../generated/factories/host-catalog';
export default factory.extend();
@@ -0,0 +1,16 @@
import { Factory } from 'ember-cli-mirage';
import { random, date } from 'faker';
/**
* GeneratedHostCatalogModelFactory
*/
export default Factory.extend({
type: 'static',
name: () => random.words(),
description: () => random.words(),
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => random.boolean(),
});
+9
View File
@@ -1,5 +1,14 @@
export default function(server) {
// Scope resources (org and project) have their relationship modelled.
server.createList('project', 3);
// For simplicity, other resources have their relationships modelled _except_
// their relationships to scope. These leads to the situation where the UI
// displays _all subresources_ as if they belong to _every scope_. This is
// a tradeoff due to the complexity of relationship modelling.
server.createList('host-catalog', 3);
}
@@ -0,0 +1,5 @@
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
modelName: 'host-catalog'
});