[PM-11949] Fix generating and copying export password (#10999)

* Use password field value instead of local variable for copy to clipboard

Use appCopyClick directive instead of manually copying and showing success toast

* Add missing "copySuccessful" message key to desktop and web

* Remove whitespace from web en/messages.json

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2024-09-12 20:04:39 +02:00 committed by GitHub
parent 07d2e36496
commit f70b3df2d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 14 deletions

View File

@ -1285,6 +1285,9 @@
}
}
},
"copySuccessful": {
"message": "Copy Successful"
},
"errorRefreshingAccessToken": {
"message": "Access Token Refresh Error"
},

View File

@ -562,6 +562,9 @@
}
}
},
"copySuccessful": {
"message": "Copy Successful"
},
"copyValue": {
"message": "Copy value",
"description": "Copy value to clipboard"

View File

@ -87,7 +87,9 @@
[disabled]="!filePassword"
appStopClick
bitSuffix
(click)="copyPasswordToClipboard()"
[appCopyClick]="filePassword"
[valueLabel]="'password' | i18n"
showToast
></button>
<bit-hint>{{ "exportPasswordDescription" | i18n }}</bit-hint>
</bit-form-field>

View File

@ -121,7 +121,6 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
encryptedExportType = EncryptedExportType;
protected showFilePassword: boolean;
filePasswordValue: string = null;
private _disabledByPolicy = false;
organizations$: Observable<Organization[]>;
@ -278,18 +277,9 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
generatePassword = async () => {
const [options] = await this.passwordGenerationService.getOptions();
this.filePasswordValue = await this.passwordGenerationService.generatePassword(options);
this.exportForm.get("filePassword").setValue(this.filePasswordValue);
this.exportForm.get("confirmFilePassword").setValue(this.filePasswordValue);
};
copyPasswordToClipboard = async () => {
this.platformUtilsService.copyToClipboard(this.filePasswordValue);
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("valueCopied", this.i18nService.t("password")),
});
const generatedPassword = await this.passwordGenerationService.generatePassword(options);
this.exportForm.get("filePassword").setValue(generatedPassword);
this.exportForm.get("confirmFilePassword").setValue(generatedPassword);
};
submit = async () => {