Skip to content

Commit

Permalink
ui: 1.15.x back to hcp link conditions (#19444)
Browse files Browse the repository at this point in the history
Only show back to hcp link if CONSUL_HCP_URL is present
  • Loading branch information
Tyler Wendlandt authored Nov 3, 2023
1 parent 64b6897 commit d477441
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/19444.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: only show back-to-hcp link when url is present
```
18 changes: 10 additions & 8 deletions ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div
class="consul-hcp-home"
...attributes
>
<a href={{env 'CONSUL_HCP_URL'}} data-native-href="true">
Back to HCP
</a>
</div>
{{#if (env 'CONSUL_HCP_URL')}}
<div
class="consul-hcp-home"
...attributes
>
<a href={{env 'CONSUL_HCP_URL'}} data-native-href="true">
Back to HCP
</a>
</div>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,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`
<Consul::Hcp::Home />
`);

assert.dom('[data-test-back-to-hcp]').doesNotExist();
assert.dom('a').doesNotExist();
});
});

0 comments on commit d477441

Please sign in to comment.