diff --git a/addons/api/addon/models/host-catalog.js b/addons/api/addon/models/host-catalog.js index 894ee9cf1..f9ae96493 100644 --- a/addons/api/addon/models/host-catalog.js +++ b/addons/api/addon/models/host-catalog.js @@ -1,3 +1,10 @@ import GeneratedHostCatalogModel from '../generated/models/host-catalog'; -export default class HostCatalogModel extends GeneratedHostCatalogModel {} +export default class HostCatalogModel extends GeneratedHostCatalogModel { + /** + * @type {boolean} + */ + get isStatic() { + return this.type === 'static'; + } +} diff --git a/addons/api/mirage/factories/host-catalog.js b/addons/api/mirage/factories/host-catalog.js index c08d2786a..75bcc3928 100644 --- a/addons/api/mirage/factories/host-catalog.js +++ b/addons/api/mirage/factories/host-catalog.js @@ -18,9 +18,9 @@ export default factory.extend({ }, withChildren: trait({ afterCreate(hostCatalog, server) { - const { scope } = hostCatalog; - const hosts = server.createList('host', 10, { scope, hostCatalog }); - server.createList('host-set', 3, { scope, hostCatalog, hosts }); + const { scope, type } = hostCatalog; + const hosts = server.createList('host', 10, { scope, hostCatalog, type }); + server.createList('host-set', 3, { scope, hostCatalog, hosts, type }); }, }), }); diff --git a/addons/api/mirage/generated/factories/host-catalog.js b/addons/api/mirage/generated/factories/host-catalog.js index 36d5e64c6..1b2bb8af6 100644 --- a/addons/api/mirage/generated/factories/host-catalog.js +++ b/addons/api/mirage/generated/factories/host-catalog.js @@ -5,7 +5,7 @@ import { random, date, datatype } from 'faker'; * GeneratedHostCatalogModelFactory */ export default Factory.extend({ - type: 'static', + type: () => random.arrayElement(['static', 'plugin']), name: () => random.words(), description: () => random.words(), created_time: () => date.recent(), diff --git a/addons/api/tests/unit/models/host-catalog-test.js b/addons/api/tests/unit/models/host-catalog-test.js index e35a07be7..48b21051d 100644 --- a/addons/api/tests/unit/models/host-catalog-test.js +++ b/addons/api/tests/unit/models/host-catalog-test.js @@ -9,4 +9,14 @@ module('Unit | Model | host catalog', function (hooks) { let model = store.createRecord('host-catalog', {}); assert.ok(model); }); + + test('it has isStatic function and returns the expected values', async function (assert) { + assert.expect(3); + const store = this.owner.lookup('service:store'); + const modelA = store.createRecord('host-catalog', { type: 'static' }); + const modelB = store.createRecord('host-catalog', { type: 'plugin' }); + assert.equal(typeof modelA.isStatic, 'boolean'); + assert.true(modelA.isStatic); + assert.false(modelB.isStatic); + }); }); diff --git a/addons/api/tests/unit/models/host-test.js b/addons/api/tests/unit/models/host-test.js index 871551523..625774e71 100644 --- a/addons/api/tests/unit/models/host-test.js +++ b/addons/api/tests/unit/models/host-test.js @@ -5,12 +5,14 @@ module('Unit | Model | host', function (hooks) { setupTest(hooks); test('it exists', function (assert) { + assert.expect(1); let store = this.owner.lookup('service:store'); let model = store.createRecord('host', {}); assert.ok(model); }); test('it contains attributes', function (assert) { + assert.expect(1); let store = this.owner.lookup('service:store'); let model = store.createRecord('host', { type: 'static', diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs index ccf7e1ec3..afd87cccc 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs @@ -18,6 +18,7 @@ @route='scopes.scope.host-catalogs.host-catalog.hosts.host' @model={{host.id}} > + {{host.displayName}} {{else}} diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs index 94eb61309..b3900063f 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs @@ -41,37 +41,39 @@
{{hostCatalog.description}}
-{{hostCatalog.id}}
- {{hostCatalog.description}}
+ +{{hostCatalog.id}}
+