1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

update send list items container

This commit is contained in:
jaasen-livefront
2024-07-18 16:54:22 -07:00
parent b33b82f6be
commit a18d509409
4 changed files with 114 additions and 34 deletions

View File

@@ -51,7 +51,7 @@ export class SendV2Component implements OnInit, OnDestroy {
this.sendService.sendViews$
.pipe(
mergeMap(async (sends) => {
this.sends = sends;
this.sends = sends.sort((a, b) => a.name.localeCompare(b.name));
}),
takeUntil(this.destroy$),
)

View File

@@ -1368,7 +1368,7 @@
},
"exportPasswordDescription": {
"message": "This password will be used to export and import this file"
},
},
"accountRestrictedOptionDescription": {
"message": "Use your account encryption key, derived from your account's username and Master Password, to encrypt the export and restrict import to only the current Bitwarden account."
},
@@ -1937,6 +1937,30 @@
"copyLink": {
"message": "Copy link"
},
"copySendTitle": {
"message": "Copy link - $NAME$",
"placeholders": {
"name": {
"content": "$1"
}
}
},
"deleteSend": {
"message": "Delete - $NAME$",
"placeholders": {
"name": {
"content": "$1"
}
}
},
"editSendTitle": {
"message": "Edit - $NAME$",
"placeholders": {
"name": {
"content": "$1"
}
}
},
"disabled": {
"message": "Disabled"
},

View File

@@ -3,42 +3,50 @@
<h2 class="tw-font-bold" bitTypography="h5">
{{ "allSends" | i18n }}
</h2>
<span bitTypography="body2" slot="end">{{ sends.length }}</span>
<span bitTypography="body1" slot="end">{{ sends.length }}</span>
</bit-section-header>
<bit-item-group>
<bit-item *ngFor="let send of sends">
<a
<button
bit-item-content
[routerLink]="['/view-send']"
[queryParams]="{ sendId: send.id, type: send.type }"
[appA11yTitle]="'viewItemTitle' | i18n: send.name"
[appA11yTitle]="'editSendTitle' | i18n: (send.name | i18n)"
appStopClick
type="button"
class="tw-pb-1"
>
<div class="tw-flex tw-justify-between">
<div class="tw-space-x-2">
<i
*ngIf="send.type === sendType.Text"
class="bwi bwi-file-text"
slot="start"
aria-hidden="true"
></i>
<i
*ngIf="send.type === sendType.File"
class="bwi bwi-file"
slot="start"
aria-hidden="true"
></i>
<span data-testid="item-name">{{ send.name }}</span>
</div>
<div class="tw-space-x-4">
<i
slot="start"
*ngIf="send.type === sendType.Text"
class="bwi bwi-file-text tw-text-2xl text-muted"
></i>
<i
slot="start"
*ngIf="send.type === sendType.File"
class="bwi bwi-file tw-text-2xl text-muted"
></i>
{{ send.name }}
<span slot="secondary">
{{ "deletionDate" | i18n }}:&nbsp;{{ send.deletionDate | date: "mediumDate" }}
</span>
<ng-container slot="end">
<bit-item-action>
<button
type="button"
bitIconButton="bwi-clone"
size="small"
[appA11yTitle]="'copyInfoTitle' | i18n: send.name"
></button>
</div>
</div>
</a>
appA11yTitle="{{ 'copySendTitle' | i18n }}: {{ send.name | i18n }}"
>
<i class="bwi tw-text-lg bwi-clone"></i>
</button>
</bit-item-action>
<bit-item-action>
<button
type="button"
appA11yTitle="{{ 'deleteSendTitle' | i18n }}: {{ send.name | i18n }}"
>
<i class="bwi tw-text-lg bwi-trash"></i>
</button>
</bit-item-action>
</ng-container>
</button>
</bit-item>
</bit-item-group>
</bit-section>

View File

@@ -1,22 +1,28 @@
import { CommonModule } from "@angular/common";
import { Component, Input } from "@angular/core";
import { RouterLink } from "@angular/router";
import { firstValueFrom } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import {
BadgeModule,
ButtonModule,
DialogService,
IconButtonModule,
ItemModule,
SectionComponent,
SectionHeaderComponent,
ToastService,
TypographyModule,
} from "@bitwarden/components";
import { ContainerComponent } from "../../../../../components/src/container/container.component";
@Component({
imports: [
CommonModule,
@@ -29,7 +35,6 @@ import { ContainerComponent } from "../../../../../components/src/container/cont
JslibModule,
SectionHeaderComponent,
RouterLink,
ContainerComponent,
],
selector: "app-send-list-items-container",
templateUrl: "send-list-items-container.component.html",
@@ -42,4 +47,47 @@ export class SendListItemsContainerComponent {
*/
@Input()
sends: SendView[] = [];
constructor(
protected dialogService: DialogService,
protected environmentService: EnvironmentService,
protected i18nService: I18nService,
protected logService: LogService,
protected platformUtilsService: PlatformUtilsService,
protected sendApiService: SendApiService,
protected toastService: ToastService,
) {}
async deleteSend(s: SendView): Promise<boolean> {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "deleteSend" },
content: { key: "deleteSendConfirmation" },
type: "warning",
});
if (!confirmed) {
return false;
}
try {
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("deletedSend"),
});
} catch (e) {
this.logService.error(e);
}
}
async copy(s: SendView) {
const env = await firstValueFrom(this.environmentService.environment$);
const link = env.getSendUrl() + s.accessId + "/" + s.urlB64Key;
this.platformUtilsService.copyToClipboard(link);
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("valueCopied", this.i18nService.t("sendLink")),
});
}
}