From 21539e6e9563d0454b2e929d66fd0b820753633a Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 18 Dec 2023 18:34:44 +0100 Subject: [PATCH] [PM-5299] Extract a danger-zone component (#7220) Extract a re-useable danger-zone component instead of needing to duplicate the code. --- .../settings/account.component.html | 8 ++-- .../settings/account/account.component.html | 37 ++++++++----------- .../account/danger-zone.component.html | 9 +++++ .../settings/account/danger-zone.component.ts | 15 ++++++++ .../settings/account/danger-zone.stories.ts | 36 ++++++++++++++++++ .../src/app/shared/loose-components.module.ts | 3 ++ 6 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 apps/web/src/app/auth/settings/account/danger-zone.component.html create mode 100644 apps/web/src/app/auth/settings/account/danger-zone.component.ts create mode 100644 apps/web/src/app/auth/settings/account/danger-zone.stories.ts diff --git a/apps/web/src/app/admin-console/organizations/settings/account.component.html b/apps/web/src/app/admin-console/organizations/settings/account.component.html index 300d8003a1..83e0e35cf3 100644 --- a/apps/web/src/app/admin-console/organizations/settings/account.component.html +++ b/apps/web/src/app/admin-console/organizations/settings/account.component.html @@ -78,16 +78,16 @@ {{ "save" | i18n }} -

{{ "dangerZone" | i18n }}

-
-

{{ "dangerZoneDesc" | i18n }}

+ + -
+ + diff --git a/apps/web/src/app/auth/settings/account/account.component.html b/apps/web/src/app/auth/settings/account/account.component.html index 687a78290a..84c0507e1a 100644 --- a/apps/web/src/app/auth/settings/account/account.component.html +++ b/apps/web/src/app/auth/settings/account/account.component.html @@ -2,29 +2,24 @@

{{ "myAccount" | i18n }}

- -
-

{{ "changeEmail" | i18n }}

-
+ +
+

{{ "changeEmail" | i18n }}

- -
-

{{ "dangerZone" | i18n }}

-
-
-
-

{{ "dangerZoneDesc" | i18n }}

- - - -
+ + + + + + + diff --git a/apps/web/src/app/auth/settings/account/danger-zone.component.html b/apps/web/src/app/auth/settings/account/danger-zone.component.html new file mode 100644 index 0000000000..b6f5300cb2 --- /dev/null +++ b/apps/web/src/app/auth/settings/account/danger-zone.component.html @@ -0,0 +1,9 @@ +

{{ "dangerZone" | i18n }}

+ +
+

{{ "dangerZoneDesc" | i18n }}

+ +
+ +
+
diff --git a/apps/web/src/app/auth/settings/account/danger-zone.component.ts b/apps/web/src/app/auth/settings/account/danger-zone.component.ts new file mode 100644 index 0000000000..42f198f4f0 --- /dev/null +++ b/apps/web/src/app/auth/settings/account/danger-zone.component.ts @@ -0,0 +1,15 @@ +import { Component } from "@angular/core"; + +import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { TypographyModule } from "@bitwarden/components"; + +/** + * Component for the Danger Zone section of the Account/Organization Settings page. + */ +@Component({ + selector: "app-danger-zone", + templateUrl: "danger-zone.component.html", + standalone: true, + imports: [TypographyModule, JslibModule], +}) +export class DangerZoneComponent {} diff --git a/apps/web/src/app/auth/settings/account/danger-zone.stories.ts b/apps/web/src/app/auth/settings/account/danger-zone.stories.ts new file mode 100644 index 0000000000..67e7f195f1 --- /dev/null +++ b/apps/web/src/app/auth/settings/account/danger-zone.stories.ts @@ -0,0 +1,36 @@ +import { importProvidersFrom } from "@angular/core"; +import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular"; + +import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { ButtonModule } from "@bitwarden/components"; + +import { PreloadedEnglishI18nModule } from "../../../core/tests"; + +import { DangerZoneComponent } from "./danger-zone.component"; + +export default { + title: "Web/Danger Zone", + component: DangerZoneComponent, + decorators: [ + moduleMetadata({ + imports: [ButtonModule, JslibModule], + }), + applicationConfig({ + providers: [importProvidersFrom(PreloadedEnglishI18nModule)], + }), + ], +} as Meta; + +type Story = StoryObj; + +export const Default: Story = { + render: (args) => ({ + props: args, + template: ` + + + + + `, + }), +}; diff --git a/apps/web/src/app/shared/loose-components.module.ts b/apps/web/src/app/shared/loose-components.module.ts index 604d7dcada..1f0bbe1659 100644 --- a/apps/web/src/app/shared/loose-components.module.ts +++ b/apps/web/src/app/shared/loose-components.module.ts @@ -27,6 +27,7 @@ import { SetPasswordComponent } from "../auth/set-password.component"; import { AccountComponent } from "../auth/settings/account/account.component"; import { ChangeAvatarComponent } from "../auth/settings/account/change-avatar.component"; import { ChangeEmailComponent } from "../auth/settings/account/change-email.component"; +import { DangerZoneComponent } from "../auth/settings/account/danger-zone.component"; import { DeauthorizeSessionsComponent } from "../auth/settings/account/deauthorize-sessions.component"; import { DeleteAccountComponent } from "../auth/settings/account/delete-account.component"; import { ProfileComponent } from "../auth/settings/account/profile.component"; @@ -107,6 +108,7 @@ import { SharedModule } from "./shared.module"; OrganizationBadgeModule, PipesModule, PasswordCalloutComponent, + DangerZoneComponent, ], declarations: [ AcceptFamilySponsorshipComponent, @@ -271,6 +273,7 @@ import { SharedModule } from "./shared.module"; VerifyEmailTokenComponent, VerifyRecoverDeleteComponent, LowKdfComponent, + DangerZoneComponent, ], }) export class LooseComponentsModule {}