-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add banner for when resultant-acl check fails (#23503)
- Loading branch information
Showing
13 changed files
with
187 additions
and
74 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 |
---|---|---|
@@ -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
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'); | ||
}); | ||
}); |