Skip to content

Commit

Permalink
backport of UI: make resultant-acl banner dismissable (#25108)
Browse files Browse the repository at this point in the history
Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
  • Loading branch information
1 parent 4fd9977 commit c395e8c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
3 changes: 3 additions & 0 deletions changelog/25106.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Allows users to dismiss the resultant-acl banner.
```
48 changes: 28 additions & 20 deletions ui/app/components/resultant-acl-banner.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<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>
{{#unless this.hideBanner}}
<Hds::Alert
@type="inline"
@color="critical"
@onDismiss={{fn (mut this.hideBanner) true}}
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>
{{/unless}}
2 changes: 2 additions & 0 deletions ui/app/components/resultant-acl-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class ResultantAclBannerComponent extends Component {
@service namespace;
@service router;
@tracked hideBanner = false;

get ns() {
return this.namespace.path || 'root';
Expand Down
9 changes: 8 additions & 1 deletion ui/tests/integration/components/resultant-acl-banner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | resultant-acl-banner', function (hooks) {
Expand Down Expand Up @@ -44,4 +44,11 @@ module('Integration | Component | resultant-acl-banner', function (hooks) {
.dom('[data-test-resultant-acl-reauthenticate]')
.hasText('Log into root namespace', 'Shows reauth link with default namespace');
});

test('it goes away when dismiss button clicked', async function (assert) {
await render(hbs`<ResultantAclBanner />`);
assert.dom('[data-test-resultant-acl-banner]').exists('Shows banner initially');
await click('.hds-dismiss-button');
assert.dom('[data-test-resultant-acl-banner]').doesNotExist('Hides banner after dismiss');
});
});

0 comments on commit c395e8c

Please sign in to comment.