From dc9d1e275d37bb53f4de74529c7830a2ded64e5f Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:17:35 -0600 Subject: [PATCH] UI: Make resultant-acl banner dismissable (#25106) --- changelog/25106.txt | 3 ++ ui/app/components/resultant-acl-banner.hbs | 48 +++++++++++-------- ui/app/components/resultant-acl-banner.js | 2 + .../components/resultant-acl-banner-test.js | 9 +++- 4 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 changelog/25106.txt diff --git a/changelog/25106.txt b/changelog/25106.txt new file mode 100644 index 000000000000..d861b1a98109 --- /dev/null +++ b/changelog/25106.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Allows users to dismiss the resultant-acl banner. +``` \ No newline at end of file diff --git a/ui/app/components/resultant-acl-banner.hbs b/ui/app/components/resultant-acl-banner.hbs index 81a6833e4aa8..5c5b52b63e36 100644 --- a/ui/app/components/resultant-acl-banner.hbs +++ b/ui/app/components/resultant-acl-banner.hbs @@ -3,23 +3,31 @@ SPDX-License-Identifier: BUSL-1.1 ~}} - - Resultant ACL check failed - - {{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." - }} - - {{#if @isEnterprise}} - - {{/if}} - \ No newline at end of file +{{#unless this.hideBanner}} + + Resultant ACL check failed + + {{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." + }} + + {{#if @isEnterprise}} + + {{/if}} + +{{/unless}} \ No newline at end of file diff --git a/ui/app/components/resultant-acl-banner.js b/ui/app/components/resultant-acl-banner.js index c2a4213d70c4..793b0f973a46 100644 --- a/ui/app/components/resultant-acl-banner.js +++ b/ui/app/components/resultant-acl-banner.js @@ -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'; diff --git a/ui/tests/integration/components/resultant-acl-banner-test.js b/ui/tests/integration/components/resultant-acl-banner-test.js index 63905aa269f9..97de2c59bd37 100644 --- a/ui/tests/integration/components/resultant-acl-banner-test.js +++ b/ui/tests/integration/components/resultant-acl-banner-test.js @@ -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) { @@ -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``); + 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'); + }); });