mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-25 00:21:07 +02:00
* Update add-to-array and remove-from-array helpers * remove search-select-has-many, moved logic directly into mfa-login-enforcement-form (see #16470) * Replace add/remove object in MFA files - All MFA tests pass * Replace in PKI components (pki tests all passing) * Replace in core addon where applicable * glimmerize console service -- console tests pass * more replacements * update string-list, add comment to vertical-bar-chart * Refactor CSP Event service - only used one place (auth-form) so simplified that usage - glimmerize and refactor so that the tests work * small updates * more cleanup * Fix tests * Remove objectAt from console-helpers * Address PR comments * move commandIndex clearing back * Remove extra model set
68 lines
1.9 KiB
TypeScript
68 lines
1.9 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 { action } from '@ember/object';
|
|
import { task } from 'ember-concurrency';
|
|
import { waitFor } from '@ember/test-waiters';
|
|
import errorMessage from 'vault/utils/error-message';
|
|
import type RouterService from '@ember/routing/router-service';
|
|
import type FlashMessageService from 'vault/services/flash-messages';
|
|
import type PkiIssuerModel from 'vault/models/pki/issuer';
|
|
import { removeFromArray } from 'vault/helpers/remove-from-array';
|
|
import { addToArray } from 'vault/helpers/add-to-array';
|
|
|
|
interface Args {
|
|
model: PkiIssuerModel;
|
|
}
|
|
|
|
export default class PkiIssuerEditComponent extends Component<Args> {
|
|
@service declare readonly router: RouterService;
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
|
|
@tracked usageValues: Array<string> = [];
|
|
@tracked error = null;
|
|
|
|
constructor(owner: unknown, args: Args) {
|
|
super(owner, args);
|
|
this.usageValues = (this.args.model.usage || '').split(',');
|
|
}
|
|
|
|
toDetails() {
|
|
this.router.transitionTo('vault.cluster.secrets.backend.pki.issuers.issuer.details');
|
|
}
|
|
|
|
@action
|
|
setUsage(value: string) {
|
|
if (this.usageValues.includes(value)) {
|
|
this.usageValues = removeFromArray(this.usageValues, value);
|
|
} else {
|
|
this.usageValues = addToArray(this.usageValues, value);
|
|
}
|
|
this.args.model.usage = this.usageValues.join(',');
|
|
}
|
|
|
|
@task
|
|
@waitFor
|
|
*save(event: Event) {
|
|
event.preventDefault();
|
|
try {
|
|
yield this.args.model.save();
|
|
this.flashMessages.success('Successfully updated issuer');
|
|
this.toDetails();
|
|
} catch (error) {
|
|
this.error = errorMessage(error);
|
|
}
|
|
}
|
|
|
|
@action
|
|
cancel() {
|
|
this.args.model.rollbackAttributes();
|
|
this.toDetails();
|
|
}
|
|
}
|