mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-26 09:01:13 +02:00
* re-form yarn.lock, remove resolutions that are out of date. resolves: - mout VAULT-25595 VAULT-25603 - follow-redirects VAULT-25605 - terser VAULT-25594 VAULT-25593 - minimatch VAULT-25591 - loader-utils VAULT-25216 VAULT-25590 VAULT-25589 VAULT-25588 VAULT-25587 - decode-uri-component VAULT-25586 - qs VAULT-25585 - @xmldom/xmldom VAULT-25217 * VAULT-25596 pin async in resolutions due to testem > fireworm * VAULT-25606 pin nth-check due to ember-svg-jar * fix typescript errors after bump * update ember-template-lint to 6.0.0 * Add broken rules to template-eslintrc * pin ansi-html * remove ember-d3 in favor of specific d3 libraries we import * add changelog
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Route from '@ember/routing/route';
|
|
import { service } from '@ember/service';
|
|
import { action } from '@ember/object';
|
|
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 LdapLibraryModel from 'vault/models/ldap/library';
|
|
import type Controller from '@ember/controller';
|
|
import type Transition from '@ember/routing/transition';
|
|
import type { Breadcrumb } from 'vault/vault/app-types';
|
|
import { LdapLibraryCheckOutCredentials } from 'vault/vault/adapters/ldap/library';
|
|
import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports
|
|
|
|
interface LdapLibraryCheckOutController extends Controller {
|
|
breadcrumbs: Array<Breadcrumb>;
|
|
model: LdapLibraryCheckOutCredentials;
|
|
}
|
|
|
|
export default class LdapLibraryCheckOutRoute extends Route {
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
@service declare readonly router: RouterService;
|
|
|
|
accountsRoute = 'vault.cluster.secrets.backend.ldap.libraries.library.details.accounts';
|
|
|
|
beforeModel(transition: Transition) {
|
|
// transition must be from the details.accounts route to ensure it was initiated by the check-out action
|
|
if (transition.from?.name !== this.accountsRoute) {
|
|
this.router.replaceWith(this.accountsRoute);
|
|
}
|
|
}
|
|
model(_params: object, transition: Transition) {
|
|
const ttl = transition.to?.queryParams['ttl'];
|
|
const library = this.modelFor('libraries.library') as LdapLibraryModel;
|
|
return library.checkOutAccount(ttl);
|
|
}
|
|
setupController(
|
|
controller: LdapLibraryCheckOutController,
|
|
resolvedModel: LdapLibraryCheckOutCredentials,
|
|
transition: Transition
|
|
) {
|
|
super.setupController(controller, resolvedModel, transition);
|
|
|
|
const library = this.modelFor('libraries.library') as LdapLibraryModel;
|
|
controller.breadcrumbs = [
|
|
{ label: library.backend, route: 'overview' },
|
|
{ label: 'libraries', route: 'libraries' },
|
|
{ label: library.name, route: 'libraries.library' },
|
|
{ label: 'check-out' },
|
|
];
|
|
}
|
|
|
|
@action
|
|
error(error: AdapterError) {
|
|
// if check-out fails, return to library details route
|
|
const message = errorMessage(error, 'Error checking out account. Please try again or contact support.');
|
|
this.flashMessages.danger(message);
|
|
this.router.replaceWith(this.accountsRoute);
|
|
}
|
|
}
|