From c8b49beba67ebf1789e9b6bed507bf5cfdb6e6b8 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 7 Dec 2021 16:24:55 -0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Host=20list=20in=20targe?= =?UTF-8?q?ts=20shows=20just=20type=20static?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/host.js | 7 +++ addons/api/tests/unit/models/host-test.js | 12 ++++ .../scope/projects/targets/target/hosts.hbs | 60 ++++++++++--------- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/addons/api/addon/models/host.js b/addons/api/addon/models/host.js index 7748e023b..62274032b 100644 --- a/addons/api/addon/models/host.js +++ b/addons/api/addon/models/host.js @@ -7,4 +7,11 @@ export default class HostModel extends GeneratedHostModel { * @type {FragmentHostAttributesModel} */ @fragment('fragment-host-attributes', { defaultValue: {} }) attributes; + + /** + * @type {boolean} + */ + get isStatic() { + return this.type === 'static'; + } } diff --git a/addons/api/tests/unit/models/host-test.js b/addons/api/tests/unit/models/host-test.js index 871551523..9cd08b5aa 100644 --- a/addons/api/tests/unit/models/host-test.js +++ b/addons/api/tests/unit/models/host-test.js @@ -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', @@ -20,4 +22,14 @@ module('Unit | Model | host', function (hooks) { }); assert.equal(model.attributes.address, '127.0.0.1'); }); + + 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', { type: 'static' }); + const modelB = store.createRecord('host', { type: 'plugin' }); + assert.equal(typeof modelA.isStatic, 'boolean'); + assert.true(modelA.isStatic); + assert.false(modelB.isStatic); + }); }); diff --git a/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs b/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs index 3a4dfbd65..f48b2a895 100644 --- a/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs +++ b/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs @@ -5,35 +5,37 @@ {{#each @model.hosts as |host|}} - - - {{host.displayName}} -

{{host.description}}

-
- - - {{host.id}} - - - {{host.attributes.address}} - - {{t - (concat 'resources.host.types.' host.type) - }} - - - - {{t 'resources.session.actions.connect'}} - - -
+ {{#if host.isStatic}} + + + {{host.displayName}} +

{{host.description}}

+
+ + + {{host.id}} + + + {{host.attributes.address}} + + {{t + (concat 'resources.host.types.' host.type) + }} + + + + {{t 'resources.session.actions.connect'}} + + +
+ {{/if}} {{/each}}