Merge branch 'feat-create-radio-card-component' of github.com:hashicorp/boundary-ui into feat-create-radio-card-component
This commit is contained in:
commit
299c1cdd06
7 files changed
+171
-31
No files matched your search
@@ -48,4 +48,10 @@ export default class GeneratedHostCatalogModel extends BaseModel {
|
|||||||
description: 'Current version number of this resource.',
|
description: 'Current version number of this resource.',
|
||||||
})
|
})
|
||||||
version;
|
version;
|
||||||
|
|
||||||
|
@attr({
|
||||||
|
description: 'Plugin information for this resource.',
|
||||||
|
readOnly: true,
|
||||||
|
})
|
||||||
|
plugin;
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,54 @@ import GeneratedHostCatalogModel from '../generated/models/host-catalog';
|
|||||||
|
|
||||||
export default class HostCatalogModel extends GeneratedHostCatalogModel {
|
export default class HostCatalogModel extends GeneratedHostCatalogModel {
|
||||||
/**
|
/**
|
||||||
|
* Returns if the host-catalog is static type or not.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
get isStatic() {
|
get isStatic() {
|
||||||
return this.type === 'static';
|
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(),
|
created_time: () => date.recent(),
|
||||||
updated_time: () => date.recent(),
|
updated_time: () => date.recent(),
|
||||||
disabled: () => datatype.boolean(),
|
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.true(modelA.isStatic);
|
||||||
assert.false(modelB.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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"@ember/test-helpers": "^2.4.2",
|
"@ember/test-helpers": "^2.4.2",
|
||||||
"@glimmer/component": "^1.0.4",
|
"@glimmer/component": "^1.0.4",
|
||||||
"@glimmer/tracking": "^1.0.4",
|
"@glimmer/tracking": "^1.0.4",
|
||||||
"@hashicorp/flight-icons": "^1.0.0",
|
"@hashicorp/flight-icons": "^2.0.1",
|
||||||
"@storybook/addon-a11y": "^6.3.12",
|
"@storybook/addon-a11y": "^6.3.12",
|
||||||
"@storybook/addon-actions": "^6.3.10",
|
"@storybook/addon-actions": "^6.3.10",
|
||||||
"@storybook/addon-docs": "^6.3.8",
|
"@storybook/addon-docs": "^6.3.8",
|
||||||
|
|||||||
@@ -41,39 +41,49 @@
|
|||||||
</table.header>
|
</table.header>
|
||||||
<table.body as |body|>
|
<table.body as |body|>
|
||||||
{{#each @model as |hostCatalog|}}
|
{{#each @model as |hostCatalog|}}
|
||||||
{{#if hostCatalog.isStatic}}
|
<body.row as |row|>
|
||||||
<body.row as |row|>
|
<row.headerCell>
|
||||||
<row.headerCell>
|
{{#if (can 'read model' hostCatalog)}}
|
||||||
{{#if (can 'read model' hostCatalog)}}
|
<LinkTo
|
||||||
<LinkTo
|
@route='scopes.scope.host-catalogs.host-catalog'
|
||||||
@route='scopes.scope.host-catalogs.host-catalog'
|
@model={{hostCatalog.id}}
|
||||||
@model={{hostCatalog.id}}
|
>
|
||||||
>
|
|
||||||
{{hostCatalog.displayName}}
|
|
||||||
</LinkTo>
|
|
||||||
{{else}}
|
|
||||||
{{hostCatalog.displayName}}
|
{{hostCatalog.displayName}}
|
||||||
{{/if}}
|
</LinkTo>
|
||||||
<p>{{hostCatalog.description}}</p>
|
{{else}}
|
||||||
</row.headerCell>
|
{{hostCatalog.displayName}}
|
||||||
<row.cell>
|
{{/if}}
|
||||||
|
<p>{{hostCatalog.description}}</p>
|
||||||
|
</row.headerCell>
|
||||||
|
<row.cell>
|
||||||
|
{{#if hostCatalog.isStatic}}
|
||||||
<Rose::Badge>
|
<Rose::Badge>
|
||||||
{{t
|
{{t
|
||||||
(concat 'resources.host-catalog.types.' hostCatalog.type)
|
(concat 'resources.host-catalog.types.' hostCatalog.type)
|
||||||
}}
|
}}
|
||||||
</Rose::Badge>
|
</Rose::Badge>
|
||||||
</row.cell>
|
{{else}}
|
||||||
<row.cell>
|
<Rose::Badge
|
||||||
<Copyable
|
@icon={{concat
|
||||||
@text={{hostCatalog.id}}
|
'flight-icons/svg/'
|
||||||
@buttonText={{t 'actions.copy-to-clipboard'}}
|
hostCatalog.compositeType
|
||||||
@acknowledgeText={{t 'states.copied'}}
|
'-color-16'
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<code>{{hostCatalog.id}}</code>
|
{{hostCatalog.compositeType}}
|
||||||
</Copyable>
|
</Rose::Badge>
|
||||||
</row.cell>
|
{{/if}}
|
||||||
</body.row>
|
</row.cell>
|
||||||
{{/if}}
|
<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}}
|
{{/each}}
|
||||||
</table.body>
|
</table.body>
|
||||||
</Rose::Table>
|
</Rose::Table>
|
||||||
|
|||||||
@@ -3449,10 +3449,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@handlebars/parser/-/parser-1.1.0.tgz#d6dbc7574774b238114582410e8fee0dc3532bdf"
|
resolved "https://registry.yarnpkg.com/@handlebars/parser/-/parser-1.1.0.tgz#d6dbc7574774b238114582410e8fee0dc3532bdf"
|
||||||
integrity sha512-rR7tJoSwJ2eooOpYGxGGW95sLq6GXUaS1UtWvN7pei6n2/okYvCGld9vsUTvkl2migxbkszsycwtMf/GEc1k1A==
|
integrity sha512-rR7tJoSwJ2eooOpYGxGGW95sLq6GXUaS1UtWvN7pei6n2/okYvCGld9vsUTvkl2migxbkszsycwtMf/GEc1k1A==
|
||||||
|
|
||||||
"@hashicorp/flight-icons@^1.0.0":
|
"@hashicorp/flight-icons@^2.0.1":
|
||||||
version "1.0.0"
|
version "2.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@hashicorp/flight-icons/-/flight-icons-1.0.0.tgz#488ec6c3aaa8702d7878274abb8a5352eae1f6a2"
|
resolved "https://registry.yarnpkg.com/@hashicorp/flight-icons/-/flight-icons-2.0.1.tgz#7e7370f1d45207409dd20ebdce7285370e7d9532"
|
||||||
integrity sha512-LehZZOxbHZmVLzF6fy2w1LqJ5jQv+QXCfGlb7oToBc3u6YPxlIb3S1+bKQJIXzn7TELFRjRndnCtuYYXFO90Ng==
|
integrity sha512-445WEmL0ysOeVQDe2khCqGbmNm+/Rv5B35Q8FXvc+RuE+r9mNWL0ufe2cVa8Sqqt/VRg0lyTEhArNX9gYCX1Yg==
|
||||||
|
|
||||||
"@humanwhocodes/config-array@^0.5.0":
|
"@humanwhocodes/config-array@^0.5.0":
|
||||||
version "0.5.0"
|
version "0.5.0"
|
||||||
|
|||||||
Reference in new issue
Block a user