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:
parent
6eca67fa81
commit
9860f68703
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
ui: only show hcp link if url is present
|
||||
```
|
|
@ -3,11 +3,13 @@
|
|||
SPDX-License-Identifier: MPL-2.0
|
||||
}}
|
||||
|
||||
<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}}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue