* refactor: 💡 Refactor default option in scope field and desc Refactor default option for scope field to be 'Choose an option' instead of 'Global', so user can explicitly select their scope. Refactor scope field descriptions to give different context based on if the selection is 'global' or an 'org' scope. ✅ Closes: ICU-9641 * refactor: 💡 refactor translations Added correct translations for default, global, and org. Added small bit of logic to help with switch of text on `onChange` event.
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { inject as service } from '@ember/service';
|
|
import { set } from '@ember/object';
|
|
|
|
export default class FormStorageBucketComponent extends Component {
|
|
// =actions
|
|
@service intl;
|
|
|
|
@tracked scopeFieldDescription = this.intl.t(
|
|
'resources.storage-bucket.form.scope.help'
|
|
);
|
|
|
|
updateScopeFieldDescription() {
|
|
if (this.args.model.scopeModel.isGlobal) {
|
|
this.scopeFieldDescription = this.intl.t(
|
|
'resources.storage-bucket.form.scope.help_global'
|
|
);
|
|
} else {
|
|
this.scopeFieldDescription = this.intl.t(
|
|
'resources.storage-bucket.form.scope.help_org'
|
|
);
|
|
}
|
|
}
|
|
|
|
@action
|
|
updateScope(event) {
|
|
const selectedScopeId = event.target.value;
|
|
const selectedScopeModel = this.args.scopes.find(
|
|
(element) => element.model.id === selectedScopeId
|
|
).model;
|
|
this.args.model.scopeModel = selectedScopeModel;
|
|
this.updateScopeFieldDescription();
|
|
}
|
|
|
|
@action
|
|
rollbackSecretAttrs(currentAttr) {
|
|
const changedAttrs = this.args.model.changedAttributes();
|
|
if (currentAttr in changedAttrs) {
|
|
const [oldVal] = changedAttrs[currentAttr];
|
|
set(this.args.model, currentAttr, oldVal);
|
|
}
|
|
}
|
|
|
|
@action
|
|
toggleDisableCredentialRotation() {
|
|
this.args.model.disable_credential_rotation =
|
|
!this.args.model.disable_credential_rotation;
|
|
}
|
|
}
|