mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-22987] Hide download for corrupt attachments (#16023)
* spelling fix * hide download button for corrupt attachments * add missing translations for desktop
This commit is contained in:
@@ -702,6 +702,12 @@
|
||||
"attachmentSaved": {
|
||||
"message": "Attachment saved"
|
||||
},
|
||||
"addAttachment": {
|
||||
"message": "Add attachment"
|
||||
},
|
||||
"maxFileSizeSansPunctuation": {
|
||||
"message": "Maximum file size is 500 MB"
|
||||
},
|
||||
"file": {
|
||||
"message": "File"
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ export class DeleteAttachmentComponent {
|
||||
/** The attachment that is can be deleted */
|
||||
@Input({ required: true }) attachment!: AttachmentView;
|
||||
|
||||
/** Whether the attachemnt is being accessed from the admin console */
|
||||
/** Whether the attachment is being accessed from the admin console */
|
||||
@Input() admin: boolean = false;
|
||||
|
||||
/** Emits when the attachment is successfully deleted */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<button
|
||||
*ngIf="!isDecryptionFailure"
|
||||
[bitAction]="download"
|
||||
bitIconButton="bwi-download"
|
||||
buttonType="main"
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { DECRYPT_ERROR } from "@bitwarden/common/key-management/crypto/models/enc-string";
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||
@@ -121,6 +122,13 @@ describe("DownloadAttachmentComponent", () => {
|
||||
Request = MockRequest as any;
|
||||
});
|
||||
|
||||
it("hides download button when the attachment has decryption failure", () => {
|
||||
component.attachment.fileName = DECRYPT_ERROR;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.query(By.css("button"))).toBeNull();
|
||||
});
|
||||
|
||||
it("uses the attachment url when available when getAttachmentData returns a 404", async () => {
|
||||
getAttachmentData.mockRejectedValue(new ErrorResponse({}, 404));
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { DECRYPT_ERROR } from "@bitwarden/common/key-management/crypto/models/enc-string";
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -46,6 +47,10 @@ export class DownloadAttachmentComponent {
|
||||
private cipherService: CipherService,
|
||||
) {}
|
||||
|
||||
protected get isDecryptionFailure(): boolean {
|
||||
return this.attachment.fileName === DECRYPT_ERROR;
|
||||
}
|
||||
|
||||
/** Download the attachment */
|
||||
download = async () => {
|
||||
let url: string;
|
||||
|
||||
Reference in New Issue
Block a user