Files
threshold-ui/ui/desktop/app/components/hidden-secret/index.js
T

27 lines
664 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';
2021-07-07 12:39:44 -07:00
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class HiddenSecretComponent extends Component {
textMask = '■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■';
2021-07-07 12:39:44 -07:00
@tracked isHidden = false;
2021-07-07 12:39:44 -07:00
get displaySecretValue() {
if (typeof this.args.secret === 'object' && this.args.secret !== null) {
return JSON.stringify(this.args.secret, null, 2);
} else {
return this.args.secret;
}
}
2021-07-07 12:39:44 -07:00
@action
toggleSecretVisibility() {
this.isHidden = !this.isHidden;
2021-07-07 12:39:44 -07:00
}
}