Skip to content

Commit

Permalink
backport of commit 2059f85
Browse files Browse the repository at this point in the history
  • Loading branch information
wenincode committed Nov 6, 2023
1 parent f1f383e commit 7641940
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
16 changes: 10 additions & 6 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,10 +3,14 @@
SPDX-License-Identifier: BUSL-1.1
}}

{{#let @list as |SNL|}}
<SNL.BackLink
@text={{t "components.hashicorp-consul.side-nav.hcp"}}
@href={{env "CONSUL_HCP_URL"}}
@isHrefExternal={{true}}
/>
{{#let @list (env "CONSUL_HCP_URL") as |SNL hcpUrl|}}
{{log hcpUrl}}
{{#if (and SNL hcpUrl)}}
<SNL.BackLink
@text={{t "components.hashicorp-consul.side-nav.hcp"}}
@href={{hcpUrl}}
@isHrefExternal={{true}}
data-test-back-to-hcp
/>
{{/if}}
{{/let}}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,40 @@ module('Integration | Component | consul hcp home', function(hooks) {
</Hds::SideNav::List>
`);

assert.dom('[data-test-back-to-hcp]').isVisible();
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`
<Hds::SideNav::List as |SNL|>
<Consul::Hcp::Home @list={{SNL}} />
</Hds::SideNav::List>
`);

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

0 comments on commit 7641940

Please sign in to comment.