ui: 1.16.x Back to HCP link conditions (#19443)

Only show back to hcp link if CONSUL_HCP_URL is present
This commit is contained in:
Tyler Wendlandt 2023-11-03 15:51:59 -06:00 committed by GitHub
parent 6eca67fa81
commit 9860f68703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 8 deletions

3
.changelog/19443.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: only show hcp link if url is present
```

View File

@ -3,11 +3,13 @@
SPDX-License-Identifier: MPL-2.0
}}
<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>
</div>
{{/if}}

View File

@ -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`
<Consul::Hcp::Home />
`);
assert.dom('[data-test-back-to-hcp]').doesNotExist();
assert.dom('a').doesNotExist();
});
});