-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cc 7146/convert consul hcp to a simpler component for some upcoming c…
…hanges (#20344) * Convert consul-hcp to a simpler component * update existing test to use envStub helper * Add missing copyright - weird no one yelled about this * remove consul-hcp from load * remove this test that doesn't run anymore
- Loading branch information
Showing
15 changed files
with
131 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"scripts": { | ||
"doc:toc": "doctoc README.md", | ||
"compliance": "npm-run-all compliance:*", | ||
"compliance:licenses": "license-checker --summary --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages '[email protected];[email protected];[email protected];[email protected];[email protected];consul-[email protected];consul-[email protected]'" | ||
"compliance:licenses": "license-checker --summary --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages '[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]'" | ||
|
||
}, | ||
"devDependencies": { | ||
|
15 changes: 0 additions & 15 deletions
15
ui/packages/consul-hcp/app/components/consul/hcp/home/index.hbs
This file was deleted.
Oops, something went wrong.
80 changes: 0 additions & 80 deletions
80
ui/packages/consul-hcp/app/components/consul/hcp/home/index.test.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ui/packages/consul-ui/app/components/hcp-nav-item/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
}} | ||
|
||
{{#let @list (env "CONSUL_HCP_URL") as |SNL hcpUrl|}} | ||
{{#if this.shouldShowBackToHcpItem}} | ||
<SNL.BackLink | ||
@text={{t "components.hashicorp-consul.side-nav.hcp"}} | ||
@href={{hcpUrl}} | ||
@isHrefExternal={{true}} | ||
data-test-back-to-hcp | ||
/> | ||
{{/if}} | ||
{{/let}} |
21 changes: 21 additions & 0 deletions
21
ui/packages/consul-ui/app/components/hcp-nav-item/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
/** | ||
* If the user has accessed consul from HCP managed consul, we do NOT want to display the | ||
* "HCP Consul Central↗️" link in the nav bar. As we're already displaying a BackLink to HCP. | ||
*/ | ||
export default class HcpLinkItemComponent extends Component { | ||
@service env; | ||
|
||
get shouldShowBackToHcpItem() { | ||
const isConsulHcpUrlDefined = !!this.env.var('CONSUL_HCP_URL'); | ||
const isConsulHcpEnabled = !!this.env.var('CONSUL_HCP_ENABLED'); | ||
return isConsulHcpEnabled && isConsulHcpUrlDefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
ui/packages/consul-ui/tests/integration/components/consul/hcp/home-test.js
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
ui/packages/consul-ui/tests/integration/components/hcp-nav-item-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { EnvStub } from 'consul-ui/services/env'; | ||
|
||
module('Integration | Component | hcp nav item', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it prints the value of CONSUL_HCP_URL', async function (assert) { | ||
this.owner.register( | ||
'service:env', | ||
class Stub extends EnvStub { | ||
stubEnv = { | ||
CONSUL_HCP_URL: 'http://hcp.com', | ||
CONSUL_HCP_ENABLED: true, | ||
}; | ||
} | ||
); | ||
|
||
await render(hbs` | ||
<Hds::SideNav::List as |SNL|> | ||
<HcpNavItem @list={{SNL}} /> | ||
</Hds::SideNav::List> | ||
`); | ||
|
||
assert.dom('[data-test-back-to-hcp]').isVisible(); | ||
assert.dom('a').hasAttribute('href', 'http://hcp.com'); | ||
}); | ||
|
||
test('it does not output the Back to HCP link if CONSUL_HCP_URL is not present', async function (assert) { | ||
this.owner.register( | ||
'service:env', | ||
class Stub extends EnvStub { | ||
stubEnv = { | ||
CONSUL_HCP_ENABLED: true, | ||
CONSUL_HCP_URL: undefined, | ||
}; | ||
} | ||
); | ||
|
||
await render(hbs` | ||
<Hds::SideNav::List as |SNL|> | ||
<HcpNavItem @list={{SNL}} /> | ||
</Hds::SideNav::List> | ||
`); | ||
|
||
assert.dom('[data-test-back-to-hcp]').doesNotExist(); | ||
assert.dom('a').doesNotExist(); | ||
}); | ||
test('it does not output the Back to HCP link if CONSUL_HCP_ENABLED is not present', async function (assert) { | ||
this.owner.register( | ||
'service:env', | ||
class Stub extends EnvStub { | ||
stubEnv = { | ||
CONSUL_HCP_URL: 'http://hcp.com', | ||
CONSUL_HCP_ENABLED: undefined, | ||
}; | ||
} | ||
); | ||
|
||
await render(hbs` | ||
<Hds::SideNav::List as |SNL|> | ||
<HcpNavItem @list={{SNL}} /> | ||
</Hds::SideNav::List> | ||
`); | ||
|
||
assert.dom('[data-test-back-to-hcp]').doesNotExist(); | ||
assert.dom('a').doesNotExist(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters