Merge branch 'main' into feat-radio-helper-text

This commit is contained in:
Dharini Jeeva authored and GitHub committed 2022-01-14 13:48:16 -08:00
commit 66ef638086
7 files changed
+144 -4

No files matched your search

@@ -48,4 +48,10 @@ export default class GeneratedHostCatalogModel extends BaseModel {
description: 'Current version number of this resource.',
})
version;
@attr({
description: 'Plugin information for this resource.',
readOnly: true,
})
plugin;
}
+45
View File
@@ -2,9 +2,54 @@ import GeneratedHostCatalogModel from '../generated/models/host-catalog';
export default class HostCatalogModel extends GeneratedHostCatalogModel {
/**
* Returns if the host-catalog is static type or not.
* @type {boolean}
*/
get isStatic() {
return this.type === 'static';
}
/**
* Returns if the host-catalog is a plugin or not.
* @type {boolean}
*/
get isPlugin() {
return this.type === 'plugin';
}
/**
* Returns if host-catalog plugin is AWS or not
* @type {boolean}
*/
get isAWS() {
return this.compositeType === 'aws';
}
/**
* Return if host-catalog plugin is Azure or not.
* @type {boolean}
*/
get isAzure() {
return this.compositeType === 'azure';
}
/** If host-catalog is a plugins returns its name,
* otherwise returns the host-catalog type
* @type {string}
*/
get compositeType() {
return this.isPlugin ? this.plugin.name : this.type;
}
/**
* Sets type, if type is different than static, sets plugin name to type
*/
set compositeType(type) {
if (type === 'static') {
this.type = 'static';
} else {
this.type = 'plugin';
this.plugin = { name: type };
}
}
}
@@ -11,4 +11,13 @@ export default Factory.extend({
created_time: () => date.recent(),
updated_time: () => date.recent(),
disabled: () => datatype.boolean(),
plugin: function (i) {
if (this.type == 'plugin') {
return {
id: `pl_${datatype.hexaDecimal(5)}`,
name: i % 2 ? 'aws' : 'azure',
description: random.words(),
};
}
},
});
@@ -19,4 +19,74 @@ module('Unit | Model | host catalog', function (hooks) {
assert.true(modelA.isStatic);
assert.false(modelB.isStatic);
});
test('it has isPlugin function and returns the expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
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', {
type: 'plugin',
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', {
type: 'plugin',
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);
});
test('get compositeType returns expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
const modelPlugin = store.createRecord('host-catalog', {
type: 'plugin',
plugin: { name: 'Test name' },
});
const modelStatic = store.createRecord('host-catalog', {
type: 'static',
});
assert.equal(typeof modelPlugin.compositeType, 'string');
assert.equal(modelPlugin.compositeType, 'Test name');
assert.equal(modelStatic.compositeType, 'static');
});
test('set compositeType sets expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
const modelPlugin = store.createRecord('host-catalog', {
compositeType: 'aws',
});
const modelStatic = store.createRecord('host-catalog', {
compositeType: 'static',
});
assert.equal(modelPlugin.type, 'plugin');
assert.equal(modelPlugin.plugin.name, 'aws');
assert.equal(modelStatic.type, 'static');
});
});
@@ -1,4 +1,4 @@
<div class="rose-form-radio{{if @error " error"}} {{if @inline "inline"}}">
<div class="{{this.className}} {{if @error " error"}} {{if @inline "inline"}}">
<RadioButton
...attributes
@@ -3,6 +3,6 @@ import { generateComponentID } from '../../../../../utilities/component-auto-id'
export default class RoseFormRadioRadioComponent extends Component {
// =attributes
className = 'rose-form-radio';
id = generateComponentID();
}
@@ -41,7 +41,6 @@
</table.header>
<table.body as |body|>
{{#each @model as |hostCatalog|}}
{{#if hostCatalog.isStatic}}
<body.row as |row|>
<row.headerCell>
{{#if (can 'read model' hostCatalog)}}
@@ -57,11 +56,23 @@
<p>{{hostCatalog.description}}</p>
</row.headerCell>
<row.cell>
{{#if hostCatalog.isStatic}}
<Rose::Badge>
{{t
(concat 'resources.host-catalog.types.' hostCatalog.type)
}}
</Rose::Badge>
{{else}}
<Rose::Badge
@icon={{concat
'flight-icons/svg/'
hostCatalog.compositeType
'-color-16'
}}
>
{{hostCatalog.compositeType}}
</Rose::Badge>
{{/if}}
</row.cell>
<row.cell>
<Copyable
@@ -73,7 +84,6 @@
</Copyable>
</row.cell>
</body.row>
{{/if}}
{{/each}}
</table.body>
</Rose::Table>