mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
* adds linting for types to scripts and lint staged * fixes issue with AdapterError type * moves lint-staged setup out of package.json and into config file * fixes ember data store service type * fixes route params types * fixes model types * fixes general type errors * fixes ts declaration errors in js files * adds missing copyright headers * fixes issue accessing capabilities model properties * ignores AdapterError import type error * more updates to AdapterError type * adds comment to lint-staged config * moves ember data store type to @ember-data namespace * updates store import * moves AdapterError type to @ember-data namespace * turns ember-data import eslint rule back on
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
import { waitFor } from '@ember/test-waiters';
|
|
import errorMessage from 'vault/utils/error-message';
|
|
|
|
import type FlashMessageService from 'vault/services/flash-messages';
|
|
import type Store from '@ember-data/store';
|
|
import type RouterService from '@ember/routing/router-service';
|
|
|
|
interface Args {
|
|
onClose: () => void;
|
|
onError: (errorMessage: string) => void;
|
|
onConfirm: () => void;
|
|
isHvdManaged: boolean;
|
|
}
|
|
|
|
export default class SyncActivationModal extends Component<Args> {
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
@service declare readonly store: Store;
|
|
@service('app-router') declare readonly router: RouterService;
|
|
|
|
@tracked hasConfirmedDocs = false;
|
|
|
|
@task
|
|
@waitFor
|
|
*onFeatureConfirm() {
|
|
// clear any previous errors in the parent component
|
|
this.args.onConfirm();
|
|
|
|
// must return null instead of root for non managed cluster.
|
|
// child namespaces are not sent.
|
|
const namespace = this.args.isHvdManaged ? 'admin' : null;
|
|
|
|
try {
|
|
yield this.store
|
|
.adapterFor('application')
|
|
.ajax('/v1/sys/activation-flags/secrets-sync/activate', 'POST', { namespace });
|
|
// must refresh and not transition because transition does not refresh the model from within a namespace
|
|
yield this.router.refresh('vault.cluster');
|
|
} catch (error) {
|
|
this.args.onError(errorMessage(error));
|
|
this.flashMessages.danger(`Error enabling feature \n ${errorMessage(error)}`);
|
|
} finally {
|
|
this.args.onClose();
|
|
}
|
|
}
|
|
}
|