mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-24 08:01:07 +02:00
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import errorMessage from 'vault/utils/error-message';
|
|
import { action } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
import { waitFor } from '@ember/test-waiters';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
import PkiTidyModel from 'vault/models/pki/tidy';
|
|
import RouterService from '@ember/routing/router-service';
|
|
|
|
interface Args {
|
|
tidy: PkiTidyModel;
|
|
adapterOptions: object;
|
|
}
|
|
|
|
export default class PkiTidyForm extends Component<Args> {
|
|
@service declare readonly router: RouterService;
|
|
|
|
@tracked errorBanner = '';
|
|
@tracked invalidFormAlert = '';
|
|
|
|
returnToConfiguration() {
|
|
this.router.transitionTo('vault.cluster.secrets.backend.pki.configuration.index');
|
|
}
|
|
|
|
@action
|
|
updateSafetyBuffer({ goSafeTimeString }: { goSafeTimeString: string }) {
|
|
this.args.tidy.safetyBuffer = goSafeTimeString;
|
|
}
|
|
|
|
@task
|
|
@waitFor
|
|
*save(event: Event) {
|
|
event.preventDefault();
|
|
try {
|
|
yield this.args.tidy.save({ adapterOptions: this.args.adapterOptions });
|
|
this.returnToConfiguration();
|
|
} catch (e) {
|
|
this.errorBanner = errorMessage(e);
|
|
this.invalidFormAlert = 'There was an error submitting this form.';
|
|
}
|
|
}
|
|
|
|
@action
|
|
cancel() {
|
|
this.returnToConfiguration();
|
|
}
|
|
}
|