From 9860f687033a7fafd36ede6062f19a9b0a30bf70 Mon Sep 17 00:00:00 2001 From: Tyler Wendlandt Date: Fri, 3 Nov 2023 15:51:59 -0600 Subject: [PATCH] ui: 1.16.x Back to HCP link conditions (#19443) Only show back to hcp link if CONSUL_HCP_URL is present --- .changelog/19443.txt | 3 ++ .../app/components/consul/hcp/home/index.hbs | 18 ++++++----- .../components/consul/hcp/home/index.test.js | 30 +++++++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 .changelog/19443.txt diff --git a/.changelog/19443.txt b/.changelog/19443.txt new file mode 100644 index 000000000..6541c1693 --- /dev/null +++ b/.changelog/19443.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: only show hcp link if url is present +``` 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 55c6531d2..321f7867c 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,11 +3,13 @@ SPDX-License-Identifier: MPL-2.0 }} -
- - Back to HCP - -
+{{#if (env 'CONSUL_HCP_URL')}} +
+ + Back to HCP + +
+{{/if}} 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 a94b9beeb..93f1e92b1 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 @@ -40,4 +40,34 @@ module('Integration | Component | consul hcp home', function(hooks) { 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(); + }); });