1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

[PM-4048] Update DeleteAccountComponent on Desktop (#6846)

* [PM-4048] Use dialog service instead of modal service. Change UI file to use bit-Dialog. Remove from app module into standalone.

* [PM-4048] Update app.module imports

* [PM-4048] Fix form.

* PM-4048 - Delete Account tweak - remove unncessary delete header per discussion with product

* PM-4048 - Per CL migration guide,

* PM-4048 - (1) Remove button module import from dialog module exports (2) Add CL imports to desktop app module for delete acct dialog comp (3) Update delete acct dialog comp to use bitSubmit

* PM-4048 - Remove deprecated data-dismiss as bitDialogClose replaced it in terms of functionality.

* PM-4048 - Desktop Delete Acct - update loading button logic to latest CL standards (thanks Will!)

* PM-4048 - Must manually show errors to get "User Verification failed" message when user inputs incorrect MP.

* PM-4048 - desktop - delete-account.component.html - per PR feedback, remove non-tailwind classes and address missing bitFormButton

* PM-4048 - DeleteAccountComponent - per PR feedback, import DialogService using proper import alias.

* PM-4048 - delete-account.component.html - per PR feedback, remove no longer needed #form

* PM-4048 - delete-account.component.html - remove missed non-tailwind class

* PM-4048 - DeleteAccountComponent - per PR feedback, remove try catch as it is unnecessary as the bitSubmit handles errors

* add bespoke border to fix color contrast issue

* convert delete-account.component and user-verification.component to standalone; revert app module CL imports

* run prettier

* run prettier again

---------

Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
Co-authored-by: Jared Snider <jsnider@bitwarden.com>
Co-authored-by: William Martin <contact@willmartian.com>
This commit is contained in:
André Bispo
2023-12-19 19:02:19 +00:00
committed by GitHub
parent 7dff870c93
commit a59eb8dec7
5 changed files with 80 additions and 66 deletions

View File

@@ -1,19 +1,37 @@
import { DialogRef } from "@angular/cdk/dialog";
import { Component } from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
import { Verification } from "@bitwarden/common/auth/types/verification";
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 {
AsyncActionsModule,
ButtonModule,
CalloutModule,
DialogModule,
DialogService,
} from "@bitwarden/components";
import { UserVerificationComponent } from "../app/components/user-verification.component";
@Component({
selector: "app-delete-account",
standalone: true,
templateUrl: "delete-account.component.html",
imports: [
JslibModule,
UserVerificationComponent,
ButtonModule,
CalloutModule,
AsyncActionsModule,
DialogModule,
ReactiveFormsModule,
],
})
export class DeleteAccountComponent {
formPromise: Promise<void>;
deleteForm = this.formBuilder.group({
verification: undefined as Verification | undefined,
});
@@ -23,25 +41,23 @@ export class DeleteAccountComponent {
private platformUtilsService: PlatformUtilsService,
private formBuilder: FormBuilder,
private accountApiService: AccountApiService,
private logService: LogService,
) {}
static open(dialogService: DialogService): DialogRef<DeleteAccountComponent> {
return dialogService.open(DeleteAccountComponent);
}
get secret() {
return this.deleteForm.get("verification")?.value?.secret;
}
async submit() {
try {
const verification = this.deleteForm.get("verification").value;
this.formPromise = this.accountApiService.deleteAccount(verification);
await this.formPromise;
this.platformUtilsService.showToast(
"success",
this.i18nService.t("accountDeleted"),
this.i18nService.t("accountDeletedDesc"),
);
} catch (e) {
this.logService.error(e);
}
}
submit = async () => {
const verification = this.deleteForm.get("verification").value;
await this.accountApiService.deleteAccount(verification);
this.platformUtilsService.showToast(
"success",
this.i18nService.t("accountDeleted"),
this.i18nService.t("accountDeletedDesc"),
);
};
}