1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-09 05:57:40 +02:00
bitwarden-browser/apps/web/src/app/tools/send/send-access-text.component.ts
Daniel James Smith 1c43f77d51
Make linter happy (#7043)
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
2023-11-30 16:20:23 +00:00

63 lines
1.7 KiB
TypeScript

import { Component, Input } from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-access.view";
import { SharedModule } from "../../shared";
@Component({
selector: "app-send-access-text",
templateUrl: "send-access-text.component.html",
imports: [SharedModule],
standalone: true,
})
export class SendAccessTextComponent {
private _send: SendAccessView = null;
protected showText = false;
protected formGroup = this.formBuilder.group({
sendText: [""],
});
constructor(
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private formBuilder: FormBuilder,
) {}
get send(): SendAccessView {
return this._send;
}
@Input() set send(value: SendAccessView) {
this._send = value;
this.showText = this.send.text != null ? !this.send.text.hidden : true;
if (this.send == null || this.send.text == null) {
return;
}
this.formGroup.controls.sendText.patchValue(
this.showText ? this.send.text.text : this.send.text.maskedText,
);
}
protected copyText() {
this.platformUtilsService.copyToClipboard(this.send.text.text);
this.platformUtilsService.showToast(
"success",
null,
this.i18nService.t("valueCopied", this.i18nService.t("sendTypeText")),
);
}
protected toggleText() {
this.showText = !this.showText;
this.formGroup.controls.sendText.patchValue(
this.showText ? this.send.text.text : this.send.text.maskedText,
);
}
}