mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 11:37:04 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Mixin from '@ember/object/mixin';
|
|
import { task } from 'ember-concurrency';
|
|
import { ancestorKeysForKey } from 'core/utils/key-utils';
|
|
|
|
// This mixin is currently used in a controller and a component, but we
|
|
// don't see cancellation of the task as the while loop runs in either
|
|
|
|
// Controller in Ember are singletons so there's no cancellation there
|
|
// during the loop. For components, it might be expected that the task would
|
|
// be cancelled when we transitioned to a new route and a rerender occured, but this is not
|
|
// the case since we are catching the error. Since Ember's route transitions are lazy
|
|
// and we're catching any 404s, the loop continues until the transtion succeeds, or exhausts
|
|
// the ancestors array and transitions to the root
|
|
export default Mixin.create({
|
|
navToNearestAncestor: task(function* (key) {
|
|
const ancestors = ancestorKeysForKey(key);
|
|
let errored = false;
|
|
let nearest = ancestors.pop();
|
|
while (nearest) {
|
|
try {
|
|
const transition = this.transitionToRoute('vault.cluster.secrets.backend.list', nearest);
|
|
transition.data.isDeletion = true;
|
|
yield transition.promise;
|
|
} catch (e) {
|
|
// in the route error event handler, we're only throwing when it's a 404,
|
|
// other errors will be in the route and will not be caught, so the task will complete
|
|
errored = true;
|
|
nearest = ancestors.pop();
|
|
} finally {
|
|
if (!errored) {
|
|
nearest = null;
|
|
// eslint-disable-next-line
|
|
return;
|
|
}
|
|
errored = false;
|
|
}
|
|
}
|
|
yield this.transitionToRoute('vault.cluster.secrets.backend.list-root');
|
|
}),
|
|
});
|