feat: 🎸 update the tags badge in workers list view (#1326)

* feat: 🎸 update the tags badge in workers list view

✅ Closes: ICU-6035
This commit is contained in:
Zhihe Li authored and GitHub committed 2022-09-16 14:53:29 -04:00
1 parent 346e0d356a
commit 82bbe798fd
6 files changed
+54 -14

No files matched your search

+2 -1
View File
@@ -48,7 +48,8 @@ export default class GeneratedWorkerModel extends BaseModel {
last_status_time;
@attr('string', {
description: 'The version of the Boundary binary the worker is running.',
description:
'The version of the Boundary binary the worker is running.\nOutput only.',
readOnly: true,
})
release_version;
+15
View File
@@ -21,6 +21,21 @@ export default class WorkerModel extends GeneratedWorkerModel {
return this.type === 'pki';
}
/**
* Returns the number of config tags present on the worker.
* @type {number}
*/
get tagCount() {
if (!this.config_tags) {
return 0;
}
return Object.values(this.config_tags).reduce(
(previousCount, currentTags) => previousCount + currentTags.length,
0
);
}
@attr({
description:
'The deduplicated union of the tags reported by the worker ' +
+26 -6
View File
@@ -15,10 +15,30 @@ export default factory.extend({
'delete',
],
type: (i) => types[i % types.length],
canonical_tags: (i) => ({
type: i % 2 === 0 ? ['dev', faker.random.word(), faker.random.word()] : [],
}),
config_tags: (i) => ({
type: i % 2 === 0 ? ['dev', faker.random.word(), faker.random.word()] : [],
}),
canonical_tags: (i) => {
if (i % 3 === 0) {
return { os: ['ubuntu'] };
}
if (i % 2 === 0) {
return {
type: [faker.random.word(), faker.random.word()],
os: ['ubuntu'],
env: ['dev', 'local'],
};
}
return undefined;
},
config_tags: (i) => {
if (i % 3 === 0) {
return { os: ['ubuntu'] };
}
if (i % 2 === 0) {
return {
type: [faker.random.word(), faker.random.word()],
os: ['ubuntu'],
env: ['dev', 'local'],
};
}
return undefined;
},
});
@@ -16,5 +16,7 @@ export default Factory.extend({
last_status_time: () => faker.date.recent(),
active_connection_count: () => faker.datatype.number({ max: 10 }),
release_version: () =>
`Boundary v${faker.datatype.number({ max: 11 })}.${faker.datatype.number({ max: 50 })}.${faker.datatype.number({ max: 12 })}`,
`Boundary v${faker.datatype.number({ max: 11 })}.${faker.datatype.number({
max: 50,
})}.${faker.datatype.number({ max: 12 })}`,
});
@@ -465,6 +465,7 @@ worker:
session_count: Session Count
ip_address: IP Address
release_version: Release Version
tag_count: '{tagCount, plural, =1 {# tag} other {# tags}}'
form:
cluster_id:
label: Boundary Cluster ID
@@ -109,12 +109,13 @@
{{#if worker.description}}
<p>{{worker.description}}</p>
{{/if}}
{{#if worker.config_tags.type}}
<div>
{{#each worker.config_tags.type as |tag|}}
<Rose::Badge>{{tag}}</Rose::Badge>
{{/each}}
</div>
{{#if worker.tagCount}}
<Rose::Badge @icon='flight-icons/svg/tag-16'>
{{t
'resources.worker.table.tag_count'
tagCount=worker.tagCount
}}
</Rose::Badge>
{{/if}}
</row.headerCell>
<row.cell>