feat: 🎸 Add host catalog type basic support
Add host catalog type basic support. Delete previous conditional rendering to just render static types
This commit is contained in:
1 parent
ff9c659ada
commit
eb36be3688
4 files changed
+89
-40
No files matched your search
@@ -48,4 +48,10 @@ export default class GeneratedHostCatalogModel extends BaseModel {
|
||||
description: 'Current version number of this resource.',
|
||||
})
|
||||
version;
|
||||
|
||||
@attr('string', {
|
||||
description: 'Plugin information for this resource.',
|
||||
readOnly: true,
|
||||
})
|
||||
plugin;
|
||||
}
|
||||
@@ -2,9 +2,26 @@ import GeneratedHostCatalogModel from '../generated/models/host-catalog';
|
||||
|
||||
export default class HostCatalogModel extends GeneratedHostCatalogModel {
|
||||
/**
|
||||
* Returns if the host-catalog is a plugin or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isStatic() {
|
||||
return this.type === 'static';
|
||||
get isPlugin() {
|
||||
return this.type === 'plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if host-catalog plugin is AWS or not
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isAWS() {
|
||||
return this.plugin.name === 'aws';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if host-catalog plugin is Azure or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isAzure() {
|
||||
return this.plugin.name === 'azure';
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,41 @@ module('Unit | Model | host catalog', function (hooks) {
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it has isStatic function and returns the expected values', async function (assert) {
|
||||
test('it has isPlugin 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);
|
||||
const modelPlugin = store.createRecord('host-catalog', { type: 'plugin' });
|
||||
const modelStatic = store.createRecord('host-catalog', { type: 'static' });
|
||||
assert.equal(typeof modelPlugin.isPlugin, 'boolean');
|
||||
assert.true(modelPlugin.isPlugin);
|
||||
assert.false(modelStatic.isPlugin);
|
||||
});
|
||||
|
||||
test('it has isAWS function and returns the expected values', async function (assert) {
|
||||
assert.expect(3);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelAws = store.createRecord('host-catalog', {
|
||||
plugin: { name: 'aws' },
|
||||
});
|
||||
const modelRandom = store.createRecord('host-catalog', {
|
||||
plugin: { name: 'random' },
|
||||
});
|
||||
assert.equal(typeof modelAws.isAWS, 'boolean');
|
||||
assert.true(modelAws.isAWS);
|
||||
assert.false(modelRandom.isAWS);
|
||||
});
|
||||
|
||||
test('it has isAzure function and return the expected values', async function (assert) {
|
||||
assert.expect(3);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelAzure = store.createRecord('host-catalog', {
|
||||
plugin: { name: 'azure' },
|
||||
});
|
||||
const modelRandom = store.createRecord('host-catalog', {
|
||||
plugin: { name: 'random' },
|
||||
});
|
||||
assert.equal(typeof modelAzure.isAzure, 'boolean');
|
||||
assert.true(modelAzure.isAzure);
|
||||
assert.false(modelRandom.isAzure);
|
||||
});
|
||||
});
|
||||
@@ -41,39 +41,37 @@
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
{{#each @model as |hostCatalog|}}
|
||||
{{#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}}
|
||||
{{/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'}}
|
||||
<body.row as |row|>
|
||||
<row.headerCell>
|
||||
{{#if (can 'read model' hostCatalog)}}
|
||||
<LinkTo
|
||||
@route='scopes.scope.host-catalogs.host-catalog'
|
||||
@model={{hostCatalog.id}}
|
||||
>
|
||||
<code>{{hostCatalog.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/if}}
|
||||
{{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>
|
||||
{{/each}}
|
||||
</table.body>
|
||||
</Rose::Table>
|
||||
|
||||
Reference in new issue
Block a user