Merge pull request #878 from hashicorp/feature-host-catalogs-only-supports-static-type

feat: 🎸 Host catalogs only supports host type static
This commit is contained in:
Randall Morey authored and GitHub committed 2021-12-15 13:26:42 -05:00
commit 30d029a223
8 files changed
+57 -37

No files matched your search

+8 -1
View File
@@ -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';
}
}
+3 -3
View File
@@ -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 });
},
}),
});
@@ -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(),
@@ -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);
});
});
@@ -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',
@@ -18,6 +18,7 @@
@route='scopes.scope.host-catalogs.host-catalog.hosts.host'
@model={{host.id}}
>
{{host.displayName}}
</LinkTo>
{{else}}
@@ -41,37 +41,39 @@
</table.header>
<table.body as |body|>
{{#each @model as |hostCatalog|}}
<body.row as |row|>
<row.headerCell>
{{#if (can 'read model' hostCatalog)}}
<LinkTo
@route='scopes.scope.host-catalogs.host-catalog'
@model={{hostCatalog.id}}
>
{{#if hostCatalog.isStatic}}
<body.row as |row|>
<row.headerCell>
{{#if (can 'read model' hostCatalog)}}
<LinkTo
@route='scopes.scope.host-catalogs.host-catalog'
@model={{hostCatalog.id}}
>
{{hostCatalog.displayName}}
</LinkTo>
{{else}}
{{hostCatalog.displayName}}
</LinkTo>
{{else}}
{{hostCatalog.displayName}}
{{/if}}
<p>{{hostCatalog.description}}</p>
</row.headerCell>
<row.cell>
<Rose::Badge>
{{t
(concat 'resources.host-catalog.types.' hostCatalog.type)
}}
</Rose::Badge>
</row.cell>
<row.cell>
<Copyable
@text={{hostCatalog.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{hostCatalog.id}}</code>
</Copyable>
</row.cell>
</body.row>
{{/if}}
<p>{{hostCatalog.description}}</p>
</row.headerCell>
<row.cell>
<Rose::Badge>
{{t
(concat 'resources.host-catalog.types.' hostCatalog.type)
}}
</Rose::Badge>
</row.cell>
<row.cell>
<Copyable
@text={{hostCatalog.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{hostCatalog.id}}</code>
</Copyable>
</row.cell>
</body.row>
{{/if}}
{{/each}}
</table.body>
</Rose::Table>
@@ -1,7 +1,6 @@
{{page-title (t 'resources.host-set.title_plural')}}
{{#if @model.hosts}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
@@ -40,7 +39,6 @@
{{/each}}
</table.body>
</Rose::Table>
{{else}}
<Rose::Layout::Centered>