From 68b3513bca5b6cc8e2b651f40e9959df38803126 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:56:18 -0400 Subject: [PATCH] backport of commit 62b1e39acc5c5fdae123455039761e9bdb95fe92 (#22858) Co-authored-by: Jordan Reimer --- .../ldap/addon/components/accounts-checked-out.ts | 6 ++---- .../components/page/library/details/accounts.hbs | 9 +++++++-- ui/lib/ldap/addon/components/page/overview.hbs | 1 + .../components/ldap/accounts-checked-out-test.js | 14 +++++++------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ui/lib/ldap/addon/components/accounts-checked-out.ts b/ui/lib/ldap/addon/components/accounts-checked-out.ts index 0d4d880e4dab..13d83e16110b 100644 --- a/ui/lib/ldap/addon/components/accounts-checked-out.ts +++ b/ui/lib/ldap/addon/components/accounts-checked-out.ts @@ -6,7 +6,6 @@ import { waitFor } from '@ember/test-waiters'; import errorMessage from 'vault/utils/error-message'; import type FlashMessageService from 'vault/services/flash-messages'; -import type RouterService from '@ember/routing/router-service'; import type AuthService from 'vault/services/auth'; import type LdapLibraryModel from 'vault/models/ldap/library'; import type { LdapLibraryAccountStatus } from 'vault/adapters/ldap/library'; @@ -15,11 +14,11 @@ interface Args { libraries: Array; statuses: Array; showLibraryColumn: boolean; + onCheckInSuccess: CallableFunction; } export default class LdapAccountsCheckedOutComponent extends Component { @service declare readonly flashMessages: FlashMessageService; - @service declare readonly router: RouterService; @service declare readonly auth: AuthService; @tracked selectedStatus: LdapLibraryAccountStatus | undefined; @@ -62,8 +61,7 @@ export default class LdapAccountsCheckedOutComponent extends Component { const libraryModel = this.findLibrary(library); yield libraryModel.checkInAccount(account); this.flashMessages.success(`Successfully checked in the account ${account}.`); - // transitioning to the current route to trigger the model hook so we can fetch the updated status - this.router.transitionTo('vault.cluster.secrets.backend.ldap.libraries.library.details.accounts'); + this.args.onCheckInSuccess(); } catch (error) { this.selectedStatus = undefined; this.flashMessages.danger(`Error checking in the account ${account}. \n ${errorMessage(error)}`); diff --git a/ui/lib/ldap/addon/components/page/library/details/accounts.hbs b/ui/lib/ldap/addon/components/page/library/details/accounts.hbs index 150cf3e97edb..15e6c35cdf27 100644 --- a/ui/lib/ldap/addon/components/page/library/details/accounts.hbs +++ b/ui/lib/ldap/addon/components/page/library/details/accounts.hbs @@ -1,5 +1,5 @@
- +

All accounts

{{#if @library.canCheckOut}} @@ -34,7 +34,12 @@
- + diff --git a/ui/tests/integration/components/ldap/accounts-checked-out-test.js b/ui/tests/integration/components/ldap/accounts-checked-out-test.js index 4f8e4512c438..3cee95c68e0f 100644 --- a/ui/tests/integration/components/ldap/accounts-checked-out-test.js +++ b/ui/tests/integration/components/ldap/accounts-checked-out-test.js @@ -40,11 +40,16 @@ module('Integration | Component | ldap | AccountsCheckedOut', function (hooks) { { account: 'bar.baz', available: false, library: 'test-library' }, { account: 'checked.in', available: true, library: 'test-library' }, ]; + this.onCheckInSuccess = () => true; this.renderComponent = () => { return render( hbs` - + `, { owner: this.engine, @@ -122,8 +127,8 @@ module('Integration | Component | ldap | AccountsCheckedOut', function (hooks) { test('it should check in account', async function (assert) { assert.expect(2); - const transitionStub = sinon.stub(this.owner.lookup('service:router'), 'transitionTo'); this.library.disable_check_in_enforcement = 'Disabled'; + this.onCheckInSuccess = () => assert.ok(true, 'Callback is fired on check-in success'); this.server.post('/ldap-test/library/test-library/check-in', (schema, req) => { const json = JSON.parse(req.requestBody); @@ -138,10 +143,5 @@ module('Integration | Component | ldap | AccountsCheckedOut', function (hooks) { await click('[data-test-checked-out-account-action="foo.bar"]'); await click('[data-test-check-in-confirm]'); - - const didTransition = transitionStub.calledWith( - 'vault.cluster.secrets.backend.ldap.libraries.library.details.accounts' - ); - assert.true(didTransition, 'Transitions to accounts route on check-in success'); }); });