-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add banner for when resultant-acl check fails #23503
Merged
hashishaw
merged 12 commits into
main
from
ui/ui/VAULT-18684/banner-when-resultant-acl-fails
Oct 18, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
019a1cc
Add banner for when resultant-acl check fails
hashishaw 6e61364
Update language, add tests for banner
hashishaw 0221da2
Merge branch 'main' into ui/ui/VAULT-18684/banner-when-resultant-acl-…
hashishaw 2b2a9bc
Update test
hashishaw b8dc0df
Add changelog
hashishaw 7dae883
Fix banner logic
hashishaw 161eae2
Update language
hashishaw 265e66e
redirect back to current URL after login
hashishaw c4d10bf
Fix tests
hashishaw d152cd5
Merge branch 'main' into ui/ui/VAULT-18684/banner-when-resultant-acl-…
hashishaw faeeb15
Approved copy
hashishaw f29e508
Merge branch 'main' into ui/ui/VAULT-18684/banner-when-resultant-acl-…
hashishaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: show banner when resultant-acl check fails due to permissions or wrong namespace. | ||
``` |
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,20 @@ | ||
<Hds::Alert @type="inline" @color="critical" data-test-resultant-acl-banner as |A|> | ||
<A.Title>Resultant ACL check failed</A.Title> | ||
<A.Description> | ||
{{if | ||
@isEnterprise | ||
"You do not have access to resources in this namespace." | ||
"Links might be shown that you don't have access to. Contact your administrator to update your policy." | ||
}} | ||
</A.Description> | ||
{{#if @isEnterprise}} | ||
<A.Link::Standalone | ||
@icon="arrow-right" | ||
@iconPosition="trailing" | ||
@text={{concat "Log into " this.ns " namespace"}} | ||
@route="vault.cluster.logout" | ||
@query={{this.queryParams}} | ||
data-test-resultant-acl-reauthenticate | ||
/> | ||
{{/if}} | ||
</Hds::Alert> |
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,16 @@ | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
|
||
export default class ResultantAclBannerComponent extends Component { | ||
@service namespace; | ||
@service router; | ||
|
||
get ns() { | ||
return this.namespace.path || 'root'; | ||
} | ||
|
||
get queryParams() { | ||
// Bring user back to current page after login | ||
return { redirect_to: this.router.currentURL }; | ||
} | ||
} |
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
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,18 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
.cluster-banners-wrapper { | ||
width: 100%; | ||
max-width: 1344px; | ||
margin: 0 auto; | ||
padding: 0 1.5rem; | ||
|
||
> div { | ||
margin-top: $spacing-l; | ||
&:last-of-type { | ||
margin-bottom: $spacing-l; | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,17 @@ | |
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
<Sidebar::Nav::Cluster /> | ||
{{! Only show license banners for Enterprise }} | ||
{{#if this.activeCluster.version.isEnterprise}} | ||
<LicenseBanners | ||
@expiry={{this.activeCluster.licenseExpiry}} | ||
@autoloaded={{eq this.activeCluster.licenseState "autoloaded"}} | ||
/> | ||
{{/if}} | ||
<div class="cluster-banners-wrapper"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class automatically adds margins to the child divs so that spacing is consistent |
||
{{#if this.activeCluster.version.isEnterprise}} | ||
<LicenseBanners | ||
@expiry={{this.activeCluster.licenseExpiry}} | ||
@autoloaded={{eq this.activeCluster.licenseState "autoloaded"}} | ||
/> | ||
{{/if}} | ||
{{#if this.permissionReadFailed}} | ||
<ResultantAclBanner @isEnterprise={{this.activeCluster.version.isEnterprise}} /> | ||
{{/if}} | ||
</div> | ||
<div class="global-flash"> | ||
{{#each this.flashMessages.queue as |flash|}} | ||
<FlashMessage data-test-flash-message={{true}} @flash={{flash}} as |customComponent flash close|> | ||
|
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
42 changes: 42 additions & 0 deletions
42
ui/tests/integration/components/resultant-acl-banner-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,42 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'vault/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | resultant-acl-banner', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders correctly by default', async function (assert) { | ||
await render(hbs`<ResultantAclBanner />`); | ||
|
||
assert.dom('[data-test-resultant-acl-banner] .hds-alert__title').hasText('Resultant ACL check failed'); | ||
assert | ||
.dom('[data-test-resultant-acl-banner] .hds-alert__description') | ||
.hasText( | ||
"Links might be shown that you don't have access to. Contact your administrator to update your policy." | ||
); | ||
assert.dom('[data-test-resultant-acl-reauthenticate]').doesNotExist('Does not show reauth link'); | ||
}); | ||
|
||
test('it renders correctly with set namespace', async function (assert) { | ||
const nsService = this.owner.lookup('service:namespace'); | ||
nsService.setNamespace('my-ns'); | ||
|
||
await render(hbs`<ResultantAclBanner @isEnterprise={{true}} />`); | ||
|
||
assert.dom('[data-test-resultant-acl-banner] .hds-alert__title').hasText('Resultant ACL check failed'); | ||
assert | ||
.dom('[data-test-resultant-acl-banner] .hds-alert__description') | ||
.hasText('You do not have access to resources in this namespace.'); | ||
assert | ||
.dom('[data-test-resultant-acl-reauthenticate]') | ||
.hasText('Log into my-ns namespace', 'Shows reauth link with given namespace'); | ||
}); | ||
|
||
test('it renders correctly with default namespace', async function (assert) { | ||
await render(hbs`<ResultantAclBanner @isEnterprise={{true}} />`); | ||
assert | ||
.dom('[data-test-resultant-acl-reauthenticate]') | ||
.hasText('Log into root namespace', 'Shows reauth link with default namespace'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed wrapping div and moved it to outside all the banners (in cluster.hbs)