Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/19443.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: only show hcp link if 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
Expand Up @@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -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