open-nomad/ui/app/components/secure-variable-form.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1 KiB
JavaScript
Raw Normal View History

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
export default class SecureVariableFormComponent extends Component {
@service router;
@tracked
shouldHideValues = true;
get valueFieldType() {
return this.shouldHideValues ? 'password' : 'text';
}
get shouldDisableSave() {
return !this.args.model?.path;
}
@action
toggleShowHide() {
this.shouldHideValues = !this.shouldHideValues;
}
@action appendRow() {
this.args.model.keyValues.pushObject({
key: '',
value: '',
});
}
@action deleteRow(row) {
this.args.model.keyValues.removeObject(row);
}
@action
async save(e) {
e.preventDefault();
this.args.model.setAndTrimPath();
const transitionTarget = this.args.model.isNew
? 'variables'
: 'variables.variable';
await this.args.model.save();
this.router.transitionTo(transitionTarget);
}
}