1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-28 07:13:29 +00:00

separate decryption failure state in view

This commit is contained in:
Nick Krantz
2026-01-22 14:32:01 -06:00
parent beca299f5d
commit fe0472da5c
3 changed files with 69 additions and 55 deletions

View File

@@ -275,11 +275,14 @@ export class CipherView implements View, InitializerMetadata {
return undefined;
}
const attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)) ?? [];
const attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a)!) ?? [];
if (obj.attachmentDecryptionFailures?.length) {
obj.attachmentDecryptionFailures.forEach((attachment) => {
attachments.push(AttachmentView.fromSdkAttachmentView(attachment, true)!);
const attachmentView = AttachmentView.fromSdkAttachmentView(attachment, true);
if (attachmentView) {
attachments.push(attachmentView);
}
});
}

View File

@@ -4,53 +4,72 @@
<ul aria-labelledby="attachments" class="tw-list-none tw-pl-0">
@for (attachment of attachments; track attachment.id) {
<li>
<bit-item>
<bit-item-content>
<span data-testid="file-name" [title]="getAttachmentFileName(attachment)">
{{ getAttachmentFileName(attachment) }}
</span>
@if (!attachment.hasDecryptionError) {
@if (!attachment.hasDecryptionError) {
<bit-item>
<bit-item-content>
<span data-testid="file-name" [title]="attachment.fileName">
{{ attachment.fileName }}
</span>
<span slot="secondary" data-testid="file-size">{{ attachment.sizeName }}</span>
}
@if (!attachment.hasDecryptionError && attachment.key == null) {
<i
slot="default-trailing"
class="bwi bwi-exclamation-triangle bwi-sm tw-text-muted"
[appA11yTitle]="'fixEncryptionTooltip' | i18n"
></i>
}
</bit-item-content>
<ng-container slot="end">
<bit-item-action>
@if (attachment.key != null) {
<app-download-attachment
[admin]="admin() && organization()?.canEditAllCiphers"
[cipher]="cipher()"
[attachment]="attachment"
></app-download-attachment>
} @else if (!attachment.hasDecryptionError) {
<button
[bitAction]="fixOldAttachment(attachment)"
bitButton
buttonType="primary"
size="small"
type="button"
>
{{ "fixEncryption" | i18n }}
</button>
@if (attachment.key == null) {
<i
slot="default-trailing"
class="bwi bwi-exclamation-triangle bwi-sm tw-text-muted"
[appA11yTitle]="'fixEncryptionTooltip' | i18n"
></i>
}
</bit-item-action>
<bit-item-action>
<app-delete-attachment
[admin]="admin() && organization()?.canEditAllCiphers"
[cipherId]="cipher().id"
[attachment]="attachment"
(onDeletionSuccess)="removeAttachment(attachment)"
></app-delete-attachment>
</bit-item-action>
</ng-container>
</bit-item>
</bit-item-content>
<ng-container slot="end">
<bit-item-action>
@if (attachment.key != null) {
<app-download-attachment
[admin]="admin() && organization()?.canEditAllCiphers"
[cipher]="cipher()"
[attachment]="attachment"
></app-download-attachment>
} @else {
<button
[bitAction]="fixOldAttachment(attachment)"
bitButton
buttonType="primary"
size="small"
type="button"
>
{{ "fixEncryption" | i18n }}
</button>
}
</bit-item-action>
<bit-item-action>
<app-delete-attachment
[admin]="admin() && organization()?.canEditAllCiphers"
[cipherId]="cipher().id"
[attachment]="attachment"
(onDeletionSuccess)="removeAttachment(attachment)"
></app-delete-attachment>
</bit-item-action>
</ng-container>
</bit-item>
} @else {
<bit-item>
<bit-item-content>
<span data-testid="file-name" [title]="'errorCannotDecrypt' | i18n">
{{ "errorCannotDecrypt" | i18n }}
</span>
</bit-item-content>
<ng-container slot="end">
<bit-item-action>
<app-delete-attachment
[admin]="admin() && organization()?.canEditAllCiphers"
[cipherId]="cipher().id"
[attachment]="attachment"
(onDeletionSuccess)="removeAttachment(attachment)"
></app-delete-attachment>
</bit-item-action>
</ng-container>
</bit-item>
}
</li>
}
</ul>

View File

@@ -190,14 +190,6 @@ export class CipherAttachmentsComponent {
}
}
getAttachmentFileName(attachment: AttachmentView): string {
if (attachment.hasDecryptionError) {
return this.i18nService.t("errorCannotDecrypt");
}
return attachment.fileName ?? "";
}
/** Save the attachments to the cipher */
submit = async () => {
this.onUploadStarted.emit();