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:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user