Merge branch 'PM-9853' into PM-9852

This commit is contained in:
jaasen-livefront 2024-07-19 10:24:44 -07:00
commit 9f65ded13f
No known key found for this signature in database
10 changed files with 182 additions and 17 deletions

View File

@ -1996,6 +1996,9 @@
"passwordProtected": {
"message": "Password protected"
},
"copyLink": {
"message": "Copy link"
},
"copySendLink": {
"message": "Copy Send link",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."

View File

@ -8,14 +8,12 @@
</ng-container>
</popup-header>
<div
*ngIf="sendsListState === SendsListStateEnum.Empty"
class="tw-flex tw-flex-col tw-h-full tw-justify-center"
>
<div *ngIf="sends.length === 0" class="tw-flex tw-flex-col tw-h-full tw-justify-center">
<bit-no-items [icon]="noItemIcon" class="tw-text-main">
<ng-container slot="title">{{ "sendsNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "sendsNoItemsMessage" | i18n }}</ng-container>
<tools-new-send-dropdown slot="button"></tools-new-send-dropdown>
</bit-no-items>
</div>
<app-send-list-items-container [sends]="sends" />
</popup-page>

View File

@ -1,21 +1,24 @@
import { CommonModule } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { RouterLink } from "@angular/router";
import { mergeMap, Subject, takeUntil } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { ButtonModule, NoItemsModule } from "@bitwarden/components";
import { NoSendsIcon, NewSendDropdownComponent } from "@bitwarden/send-ui";
import {
NoSendsIcon,
NewSendDropdownComponent,
SendListItemsContainerComponent,
} from "@bitwarden/send-ui";
import { CurrentAccountComponent } from "../../../auth/popup/account-switching/current-account.component";
import { PopOutComponent } from "../../../platform/popup/components/pop-out.component";
import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-header.component";
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
enum SendsListState {
Empty,
}
@Component({
templateUrl: "send-v2.component.html",
standalone: true,
@ -30,23 +33,30 @@ enum SendsListState {
ButtonModule,
RouterLink,
NewSendDropdownComponent,
SendListItemsContainerComponent,
],
})
export class SendV2Component implements OnInit, OnDestroy {
sendType = SendType;
/** Visual state of the Sends list */
protected sendsListState: SendsListState | null = null;
protected sends: SendView[] = [];
private destroy$ = new Subject<void>();
protected noItemIcon = NoSendsIcon;
protected SendsListStateEnum = SendsListState;
constructor(protected sendService: SendService) {}
constructor() {
this.sendsListState = SendsListState.Empty;
async ngOnInit() {
this.sendService.sendViews$
.pipe(
mergeMap(async (sends) => {
this.sends = sends.sort((a, b) => a.name.localeCompare(b.name));
}),
takeUntil(this.destroy$),
)
.subscribe();
}
ngOnInit(): void {}
ngOnDestroy(): void {}
}

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."
},

View File

@ -4350,6 +4350,9 @@
"message": "Send link",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
},
"copyLink": {
"message": "Copy link"
},
"copySendLink": {
"message": "Copy Send link",
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."

View File

@ -115,6 +115,7 @@ export class DefaultConfigService implements ConfigService {
return DefaultFeatureFlagValue[key];
}
serverConfig.featureStates[FeatureFlag.ExtensionRefresh] = true;
return serverConfig.featureStates[key] as FeatureFlagValueType<Flag>;
}),
);

View File

@ -1,2 +1,3 @@
export * from "./icons";
export { NewSendDropdownComponent } from "./new-send-dropdown/new-send-dropdown.component";
export { SendListItemsContainerComponent } from "./send-list-items-container/send-list-items-container.component";

View File

@ -0,0 +1,54 @@
<bit-section *ngIf="sends?.length > 0">
<bit-section-header>
<h2 class="tw-font-bold" bitTypography="h5">
{{ "allSends" | i18n }}
</h2>
<span bitTypography="body1" slot="end">{{ sends.length }}</span>
</bit-section-header>
<bit-item-group>
<bit-item *ngFor="let send of sends">
<button
bit-item-content
appA11yTitle="{{ 'edit' | i18n }} - {{ send.name }}"
appStopClick
type="button"
class="tw-pb-1"
>
<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"
(click)="copySendLink(send)"
appA11yTitle="{{ 'copyLink' | i18n }} - {{ send.name }}"
>
<i class="bwi tw-text-lg bwi-clone"></i>
</button>
</bit-item-action>
<bit-item-action>
<button
type="button"
(click)="deleteSend(send)"
appA11yTitle="{{ 'delete' | i18n }} - {{ send.name }}"
>
<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

@ -0,0 +1,95 @@
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";
@Component({
imports: [
CommonModule,
ItemModule,
ButtonModule,
BadgeModule,
IconButtonModule,
SectionComponent,
TypographyModule,
JslibModule,
SectionHeaderComponent,
RouterLink,
],
selector: "app-send-list-items-container",
templateUrl: "send-list-items-container.component.html",
standalone: true,
})
export class SendListItemsContainerComponent {
sendType = SendType;
/**
* The list of sends to display.
*/
@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;
}
await this.sendApiService.delete(s.id);
try {
this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("deletedSend"),
});
} catch (e) {
this.logService.error(e);
}
}
async copySendLink(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")),
});
}
}