From 573353116b59804b8e78a362ea1326e1bd93a992 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Wed, 11 Sep 2024 14:35:13 -0700 Subject: [PATCH] remove extraneous code --- .../src/utils/extension-refresh-swap.ts | 1 - .../services/send-api.service.abstraction.ts | 3 +- .../tools/send/services/send-api.service.ts | 2 +- .../abstractions/send-form.service.ts | 2 +- .../options/options-section.component.html | 39 -------- .../options/options-section.component.ts | 91 ------------------- .../components/send-form.component.html | 4 - .../components/send-form.component.ts | 2 - .../src/send-form/send-form-container.ts | 2 - .../src/send-form/send-form.stories.ts | 3 +- .../services/default-send-form.service.ts | 2 +- 11 files changed, 7 insertions(+), 144 deletions(-) delete mode 100644 libs/tools/send/send-ui/src/send-form/components/options/options-section.component.html delete mode 100644 libs/tools/send/send-ui/src/send-form/components/options/options-section.component.ts diff --git a/libs/angular/src/utils/extension-refresh-swap.ts b/libs/angular/src/utils/extension-refresh-swap.ts index 1f5433feab8..6512be032d2 100644 --- a/libs/angular/src/utils/extension-refresh-swap.ts +++ b/libs/angular/src/utils/extension-refresh-swap.ts @@ -23,7 +23,6 @@ export function extensionRefreshSwap( defaultComponent, refreshedComponent, async () => { - return true; const configService = inject(ConfigService); return configService.getFeatureFlag(FeatureFlag.ExtensionRefresh); }, diff --git a/libs/common/src/tools/send/services/send-api.service.abstraction.ts b/libs/common/src/tools/send/services/send-api.service.abstraction.ts index e2a44880286..270123c4c1d 100644 --- a/libs/common/src/tools/send/services/send-api.service.abstraction.ts +++ b/libs/common/src/tools/send/services/send-api.service.abstraction.ts @@ -8,6 +8,7 @@ import { SendFileDownloadDataResponse } from "../models/response/send-file-downl import { SendFileUploadDataResponse } from "../models/response/send-file-upload-data.response"; import { SendResponse } from "../models/response/send.response"; import { SendAccessView } from "../models/view/send-access.view"; +import { SendView } from "../models/view/send.view"; export abstract class SendApiService { getSend: (id: string) => Promise; @@ -36,5 +37,5 @@ export abstract class SendApiService { renewSendFileUploadUrl: (sendId: string, fileId: string) => Promise; removePassword: (id: string) => Promise; delete: (id: string) => Promise; - save: (sendData: [Send, EncArrayBuffer]) => Promise; + save: (sendData: [Send, EncArrayBuffer]) => Promise; } diff --git a/libs/common/src/tools/send/services/send-api.service.ts b/libs/common/src/tools/send/services/send-api.service.ts index a7cb7468791..2cb2ff1c2f0 100644 --- a/libs/common/src/tools/send/services/send-api.service.ts +++ b/libs/common/src/tools/send/services/send-api.service.ts @@ -135,7 +135,7 @@ export class SendApiService implements SendApiServiceAbstraction { return this.apiService.send("DELETE", "/sends/" + id, null, true, false); } - async save(sendData: [Send, EncArrayBuffer]): Promise { + async save(sendData: [Send, EncArrayBuffer]): Promise { const response = await this.upload(sendData); const data = new SendData(response); diff --git a/libs/tools/send/send-ui/src/send-form/abstractions/send-form.service.ts b/libs/tools/send/send-ui/src/send-form/abstractions/send-form.service.ts index a8b84540838..b851db927b4 100644 --- a/libs/tools/send/send-ui/src/send-form/abstractions/send-form.service.ts +++ b/libs/tools/send/send-ui/src/send-form/abstractions/send-form.service.ts @@ -22,5 +22,5 @@ export abstract class SendFormService { send: SendView, file: File | ArrayBuffer, config: SendFormConfig, - ): Promise; + ): Promise; } diff --git a/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.html b/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.html deleted file mode 100644 index 8fccba6c0a8..00000000000 --- a/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.html +++ /dev/null @@ -1,39 +0,0 @@ - - -

{{ "additionalOptions" | i18n }}

-
- - - - {{ "limitSendViews" | i18n }} - - {{ "limitSendViewsHint" | i18n }} - - - - - {{ "currentAccessCount" | i18n }} - - - - - {{ "password" | i18n }} - {{ "newPassword" | i18n }} - - - - - {{ "sendPasswordDesc" | i18n }} - - - - - {{ "hideEmail" | i18n }} - - - - {{ "notes" | i18n }} - - - -
diff --git a/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.ts b/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.ts deleted file mode 100644 index 6d0865fb834..00000000000 --- a/libs/tools/send/send-ui/src/send-form/components/options/options-section.component.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { CommonModule } from "@angular/common"; -import { Component, Input, OnInit } from "@angular/core"; -import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; -import { FormBuilder, ReactiveFormsModule } from "@angular/forms"; - -import { JslibModule } from "@bitwarden/angular/jslib.module"; -import { SendView } from "@bitwarden/common/tools/send/models/view/send.view"; -import { - CardComponent, - CheckboxModule, - FormFieldModule, - IconButtonModule, - SectionComponent, - SectionHeaderComponent, - TypographyModule, -} from "@bitwarden/components"; - -import { SendFormConfig } from "../../abstractions/send-form-config.service"; -import { SendFormContainer } from "../../send-form-container"; - -@Component({ - selector: "tools-send-options-section", - templateUrl: "./options-section.component.html", - standalone: true, - imports: [ - SectionComponent, - SectionHeaderComponent, - TypographyModule, - JslibModule, - CardComponent, - FormFieldModule, - ReactiveFormsModule, - IconButtonModule, - CheckboxModule, - CommonModule, - ], -}) -export class AdditionalOptionsSectionComponent implements OnInit { - @Input({ required: true }) - config: SendFormConfig; - - @Input() - originalSendView: SendView; - - additionalOptionsForm = this.formBuilder.group({ - maxAccessCount: [null as number], - accessCount: [null as number], - notes: [null as string], - password: [null as string], - hideEmail: [false as boolean], - }); - - get hasPassword(): boolean { - return ( - this.additionalOptionsForm.value.password !== null && - this.additionalOptionsForm.value.password !== "" - ); - } - - constructor( - private sendFormContainer: SendFormContainer, - private formBuilder: FormBuilder, - ) { - this.sendFormContainer.registerChildForm("additionalOptions", this.additionalOptionsForm); - - this.additionalOptionsForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => { - this.sendFormContainer.patchSend((send) => { - Object.assign(send, { - maxAccessCount: value.maxAccessCount, - accessCount: value.accessCount, - password: value.password, - hideEmail: value.hideEmail, - notes: value.notes, - }); - return send; - }); - }); - } - - ngOnInit() { - if (this.sendFormContainer.originalSendView) { - this.additionalOptionsForm.patchValue({ - maxAccessCount: this.sendFormContainer.originalSendView.maxAccessCount, - accessCount: this.sendFormContainer.originalSendView.accessCount, - password: this.sendFormContainer.originalSendView.password, - hideEmail: this.sendFormContainer.originalSendView.hideEmail, - notes: this.sendFormContainer.originalSendView.notes, - }); - } - } -} diff --git a/libs/tools/send/send-ui/src/send-form/components/send-form.component.html b/libs/tools/send/send-ui/src/send-form/components/send-form.component.html index 198d1983cc3..8aa06756d0d 100644 --- a/libs/tools/send/send-ui/src/send-form/components/send-form.component.html +++ b/libs/tools/send/send-ui/src/send-form/components/send-form.component.html @@ -6,9 +6,5 @@ [config]="config" [originalSendView]="originalSendView" > - diff --git a/libs/tools/send/send-ui/src/send-form/components/send-form.component.ts b/libs/tools/send/send-ui/src/send-form/components/send-form.component.ts index 54c7284784e..fed4b005062 100644 --- a/libs/tools/send/send-ui/src/send-form/components/send-form.component.ts +++ b/libs/tools/send/send-ui/src/send-form/components/send-form.component.ts @@ -35,7 +35,6 @@ import { SendFormConfig } from "../abstractions/send-form-config.service"; import { SendFormService } from "../abstractions/send-form.service"; import { SendForm, SendFormContainer } from "../send-form-container"; -import { AdditionalOptionsSectionComponent } from "./options/options-section.component"; import { SendTextDetailsComponent } from "./send-details/send-text-details.component"; @Component({ @@ -58,7 +57,6 @@ import { SendTextDetailsComponent } from "./send-details/send-text-details.compo ReactiveFormsModule, SelectModule, NgIf, - AdditionalOptionsSectionComponent, SendTextDetailsComponent, ], }) diff --git a/libs/tools/send/send-ui/src/send-form/send-form-container.ts b/libs/tools/send/send-ui/src/send-form/send-form-container.ts index d54d79db171..75011f7c7e0 100644 --- a/libs/tools/send/send-ui/src/send-form/send-form-container.ts +++ b/libs/tools/send/send-ui/src/send-form/send-form-container.ts @@ -1,7 +1,6 @@ import { SendView } from "@bitwarden/common/tools/send/models/view/send.view"; import { SendFormConfig } from "./abstractions/send-form-config.service"; -import { AdditionalOptionsSectionComponent } from "./components/options/options-section.component"; import { SendTextDetailsComponent } from "./components/send-details/send-text-details.component"; /** * The complete form for a send. Includes all the sub-forms from their respective section components. @@ -9,7 +8,6 @@ import { SendTextDetailsComponent } from "./components/send-details/send-text-de */ export type SendForm = { sendTextDetailsForm?: SendTextDetailsComponent["sendTextDetailsForm"]; - additionalOptions?: AdditionalOptionsSectionComponent["additionalOptionsForm"]; }; /** diff --git a/libs/tools/send/send-ui/src/send-form/send-form.stories.ts b/libs/tools/send/send-ui/src/send-form/send-form.stories.ts index f5f0e0521e9..2c47bd62626 100644 --- a/libs/tools/send/send-ui/src/send-form/send-form.stories.ts +++ b/libs/tools/send/send-ui/src/send-form/send-form.stories.ts @@ -36,8 +36,9 @@ class TestAddEditFormService implements SendFormService { decryptSend(): Promise { return Promise.resolve(defaultConfig.originalSend as any); } - async saveSend(send: SendView, file: File | ArrayBuffer): Promise { + async saveSend(send: SendView, file: File | ArrayBuffer): Promise { await new Promise((resolve) => setTimeout(resolve, 1000)); + return send; } } diff --git a/libs/tools/send/send-ui/src/send-form/services/default-send-form.service.ts b/libs/tools/send/send-ui/src/send-form/services/default-send-form.service.ts index 7af4403dde1..9b6a6360ac7 100644 --- a/libs/tools/send/send-ui/src/send-form/services/default-send-form.service.ts +++ b/libs/tools/send/send-ui/src/send-form/services/default-send-form.service.ts @@ -19,6 +19,6 @@ export class DefaultSendFormService implements SendFormService { async saveSend(send: SendView, file: File | ArrayBuffer, config: SendFormConfig) { const sendData = await this.sendService.encrypt(send, file, send.password, null); - await this.sendApiService.save(sendData); + return await this.sendApiService.save(sendData); } }