From 7641940c5952ee9d951ef7da455dcc59b713e13a Mon Sep 17 00:00:00 2001 From: wenincode Date: Tue, 31 Oct 2023 15:33:18 +0000 Subject: [PATCH] backport of commit 2059f85c1713a97b0e17019be3c780598135fe17 --- .../app/components/consul/hcp/home/index.hbs | 16 +++++---- .../components/consul/hcp/home/index.test.js | 33 +++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs b/ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs index 359c7050aa59..5f8dfc5b5510 100644 --- a/ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs +++ b/ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs @@ -3,10 +3,14 @@ SPDX-License-Identifier: BUSL-1.1 }} -{{#let @list as |SNL|}} - +{{#let @list (env "CONSUL_HCP_URL") as |SNL hcpUrl|}} + {{log hcpUrl}} + {{#if (and SNL hcpUrl)}} + + {{/if}} {{/let}} \ No newline at end of file diff --git a/ui/packages/consul-hcp/app/components/consul/hcp/home/index.test.js b/ui/packages/consul-hcp/app/components/consul/hcp/home/index.test.js index 92d0e1e0b0f3..0ffb7c48583f 100644 --- a/ui/packages/consul-hcp/app/components/consul/hcp/home/index.test.js +++ b/ui/packages/consul-hcp/app/components/consul/hcp/home/index.test.js @@ -41,7 +41,40 @@ module('Integration | Component | consul hcp home', function(hooks) { `); + assert.dom('[data-test-back-to-hcp]').isVisible(); assert.dom('a').hasAttribute('href', 'http://hcp'); }); + + test('it does not output the Back to HCP link if CONSUL_HCP_URL is not present', async function(assert) { + // temporary registration until we are running as separate applications + this.owner.register( + 'component:consul/hcp/home', + ConsulHcpHome + ); + // + + const Helper = this.owner.resolveRegistration('helper:env'); + this.owner.register( + 'helper:env', + class extends Helper { + compute([name, def]) { + switch(name) { + case 'CONSUL_HCP_URL': + return undefined; + } + return super.compute(...arguments); + } + } + ); + + await render(hbs` + + + + `); + + assert.dom('[data-test-back-to-hcp]').doesNotExist(); + assert.dom('a').doesNotExist(); + }); });