1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-23 03:22:50 +02:00

[PM-254] Set PDF Attachments in Web to download, add success toast (#10757)

* add success toast to pdf attachment download in web

* update desktop attachments for toastService

* removed trailing comma

---------

Co-authored-by: gbubemismith <gsmithwalter@gmail.com>
Co-authored-by: SmithThe4th <gsmith@bitwarden.com>
This commit is contained in:
Jason Ng 2024-09-11 15:27:53 -04:00 committed by GitHub
parent 2cfbfcbdfe
commit 89751f46d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 33 additions and 10 deletions

View File

@ -4308,6 +4308,9 @@
},
"enterprisePolicyRequirementsApplied": {
"message": "Enterprise policy requirements have been applied to this setting"
},
"fileSavedToDevice": {
"message": "File saved to device. Manage from your device downloads."
},
"showCharacterCount": {
"message": "Show character count"

View File

@ -14,7 +14,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
@Component({
selector: "app-vault-attachments",
@ -38,6 +38,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
dialogService: DialogService,
billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService,
toastService: ToastService,
) {
super(
cipherService,
@ -52,6 +53,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
dialogService,
billingAccountProfileStateService,
accountService,
toastService,
);
}

View File

@ -3061,5 +3061,8 @@
},
"ssoError": {
"message": "No free ports could be found for the sso login."
},
"fileSavedToDevice": {
"message": "File saved to device. Manage from your device downloads."
}
}

View File

@ -11,7 +11,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
@Component({
selector: "app-vault-attachments",
@ -30,6 +30,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
dialogService: DialogService,
billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService,
toastService: ToastService,
) {
super(
cipherService,
@ -44,6 +45,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
dialogService,
billingAccountProfileStateService,
accountService,
toastService,
);
}
}

View File

@ -12,7 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
@Component({
selector: "emergency-access-attachments",
@ -34,6 +34,7 @@ export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponen
dialogService: DialogService,
billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService,
toastService: ToastService,
) {
super(
cipherService,
@ -48,6 +49,7 @@ export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponen
dialogService,
billingAccountProfileStateService,
accountService,
toastService,
);
}

View File

@ -12,14 +12,12 @@ export class WebFileDownloadService implements FileDownloadService {
download(request: FileDownloadRequest): void {
const builder = new FileDownloadBuilder(request);
const a = window.document.createElement("a");
if (builder.downloadMethod === "save") {
a.download = request.fileName;
} else if (!this.platformUtilsService.isSafari()) {
if (!this.platformUtilsService.isSafari()) {
a.rel = "noreferrer";
a.target = "_blank";
}
a.href = URL.createObjectURL(builder.blob);
a.style.position = "fixed";
a.download = request.fileName;
window.document.body.appendChild(a);
a.click();
window.document.body.removeChild(a);

View File

@ -12,7 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
@Component({
selector: "app-vault-attachments",
@ -33,6 +33,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
dialogService: DialogService,
billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService,
toastService: ToastService,
) {
super(
cipherService,
@ -47,6 +48,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
dialogService,
billingAccountProfileStateService,
accountService,
toastService,
);
}

View File

@ -15,7 +15,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
import { AttachmentsComponent as BaseAttachmentsComponent } from "../individual-vault/attachments.component";
@ -39,6 +39,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
dialogService: DialogService,
billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService,
toastService: ToastService,
) {
super(
cipherService,
@ -52,6 +53,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
dialogService,
billingAccountProfileStateService,
accountService,
toastService,
);
}

View File

@ -9070,6 +9070,9 @@
"secretsManagerWithFreePasswordManagerInfo": {
"message": "Your complementary one year Password Manager subscription will upgrade to the selected plan. You will not be charged until the complimentary period is over."
},
"fileSavedToDevice": {
"message": "File saved to device. Manage from your device downloads."
},
"publicApi": {
"message": "Public API",
"description": "The text, 'API', is an acronymn and should not be translated."

View File

@ -17,7 +17,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
@Directive()
export class AttachmentsComponent implements OnInit {
@ -49,6 +49,7 @@ export class AttachmentsComponent implements OnInit {
protected dialogService: DialogService,
protected billingAccountProfileStateService: BillingAccountProfileStateService,
protected accountService: AccountService,
protected toastService: ToastService,
) {}
async ngOnInit() {
@ -182,6 +183,11 @@ export class AttachmentsComponent implements OnInit {
fileName: attachment.fileName,
blobData: decBuf,
});
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("fileSavedToDevice"),
});
} catch (e) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred"));
}