From 4f09ae52abb8a83bc26c33e584f48b7215d72225 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Wed, 27 Aug 2025 22:10:32 +1000 Subject: [PATCH] [PM-25203] Resolve circular dependencies through LooseComponentsModule (#16157) * Update modules to not import loose-components Instead they should import their dependencies directly. Only OssModule imports loose-components.module.ts. * Remove unused imports and exports --- .../organizations/collections/vault.module.ts | 2 - .../organizations/members/members.module.ts | 4 +- .../organizations/organization.module.ts | 4 +- .../organizations/policies/policies.module.ts | 5 ++- .../organization-reporting.module.ts | 9 +--- .../settings/organization-settings.module.ts | 9 +++- .../two-factor/two-factor-setup.component.ts | 5 ++- .../organization-billing.module.ts | 4 +- apps/web/src/app/oss.module.ts | 7 ++- apps/web/src/app/shared/index.ts | 1 - .../src/app/shared/loose-components.module.ts | 44 +------------------ .../app/tools/import/org-import.component.ts | 5 ++- .../org-vault-export.component.ts | 5 ++- .../vault/individual-vault/vault.module.ts | 3 +- .../device-approvals.component.ts | 4 +- .../organizations/organizations.module.ts | 4 +- 16 files changed, 38 insertions(+), 77 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/collections/vault.module.ts b/apps/web/src/app/admin-console/organizations/collections/vault.module.ts index 037a27cd781..1a093ff8352 100644 --- a/apps/web/src/app/admin-console/organizations/collections/vault.module.ts +++ b/apps/web/src/app/admin-console/organizations/collections/vault.module.ts @@ -1,6 +1,5 @@ import { NgModule } from "@angular/core"; -import { LooseComponentsModule } from "../../../shared/loose-components.module"; import { SharedModule } from "../../../shared/shared.module"; import { OrganizationBadgeModule } from "../../../vault/individual-vault/organization-badge/organization-badge.module"; import { ViewComponent } from "../../../vault/individual-vault/view.component"; @@ -15,7 +14,6 @@ import { VaultComponent } from "./vault.component"; imports: [ VaultRoutingModule, SharedModule, - LooseComponentsModule, GroupBadgeModule, CollectionNameBadgeComponent, OrganizationBadgeModule, diff --git a/apps/web/src/app/admin-console/organizations/members/members.module.ts b/apps/web/src/app/admin-console/organizations/members/members.module.ts index efc091cb335..e5bc5f29a3b 100644 --- a/apps/web/src/app/admin-console/organizations/members/members.module.ts +++ b/apps/web/src/app/admin-console/organizations/members/members.module.ts @@ -6,7 +6,7 @@ import { PasswordCalloutComponent } from "@bitwarden/auth/angular"; import { ScrollLayoutDirective } from "@bitwarden/components"; import { OrganizationFreeTrialWarningComponent } from "@bitwarden/web-vault/app/billing/organizations/warnings/components"; -import { LooseComponentsModule } from "../../../shared"; +import { HeaderModule } from "../../../layouts/header/header.module"; import { SharedOrganizationModule } from "../shared"; import { BulkConfirmDialogComponent } from "./components/bulk/bulk-confirm-dialog.component"; @@ -22,10 +22,10 @@ import { MembersComponent } from "./members.component"; @NgModule({ imports: [ SharedOrganizationModule, - LooseComponentsModule, MembersRoutingModule, UserDialogModule, PasswordCalloutComponent, + HeaderModule, ScrollingModule, PasswordStrengthV2Component, ScrollLayoutDirective, diff --git a/apps/web/src/app/admin-console/organizations/organization.module.ts b/apps/web/src/app/admin-console/organizations/organization.module.ts index d956174149b..2f0077d313e 100644 --- a/apps/web/src/app/admin-console/organizations/organization.module.ts +++ b/apps/web/src/app/admin-console/organizations/organization.module.ts @@ -4,7 +4,7 @@ import { NgModule } from "@angular/core"; import { ScrollLayoutDirective } from "@bitwarden/components"; import { OrganizationWarningsModule } from "@bitwarden/web-vault/app/billing/organizations/warnings/organization-warnings.module"; -import { LooseComponentsModule } from "../../shared"; +import { HeaderModule } from "../../layouts/header/header.module"; import { CoreOrganizationModule } from "./core"; import { GroupAddEditComponent } from "./manage/group-add-edit.component"; @@ -19,7 +19,7 @@ import { AccessSelectorModule } from "./shared/components/access-selector"; AccessSelectorModule, CoreOrganizationModule, OrganizationsRoutingModule, - LooseComponentsModule, + HeaderModule, ScrollingModule, ScrollLayoutDirective, OrganizationWarningsModule, diff --git a/apps/web/src/app/admin-console/organizations/policies/policies.module.ts b/apps/web/src/app/admin-console/organizations/policies/policies.module.ts index 3999f36ecad..95b22497eba 100644 --- a/apps/web/src/app/admin-console/organizations/policies/policies.module.ts +++ b/apps/web/src/app/admin-console/organizations/policies/policies.module.ts @@ -1,6 +1,7 @@ import { NgModule } from "@angular/core"; -import { LooseComponentsModule, SharedModule } from "../../../shared"; +import { HeaderModule } from "../../../layouts/header/header.module"; +import { SharedModule } from "../../../shared"; import { DisableSendPolicyComponent } from "./disable-send.component"; import { MasterPasswordPolicyComponent } from "./master-password.component"; @@ -17,7 +18,7 @@ import { SingleOrgPolicyComponent } from "./single-org.component"; import { TwoFactorAuthenticationPolicyComponent } from "./two-factor-authentication.component"; @NgModule({ - imports: [SharedModule, LooseComponentsModule], + imports: [SharedModule, HeaderModule], declarations: [ DisableSendPolicyComponent, MasterPasswordPolicyComponent, diff --git a/apps/web/src/app/admin-console/organizations/reporting/organization-reporting.module.ts b/apps/web/src/app/admin-console/organizations/reporting/organization-reporting.module.ts index 22c3edcf240..46599d7da46 100644 --- a/apps/web/src/app/admin-console/organizations/reporting/organization-reporting.module.ts +++ b/apps/web/src/app/admin-console/organizations/reporting/organization-reporting.module.ts @@ -1,19 +1,14 @@ import { NgModule } from "@angular/core"; import { ReportsSharedModule } from "../../../dirt/reports"; -import { LooseComponentsModule } from "../../../shared"; +import { HeaderModule } from "../../../layouts/header/header.module"; import { SharedModule } from "../../../shared/shared.module"; import { OrganizationReportingRoutingModule } from "./organization-reporting-routing.module"; import { ReportsHomeComponent } from "./reports-home.component"; @NgModule({ - imports: [ - SharedModule, - ReportsSharedModule, - OrganizationReportingRoutingModule, - LooseComponentsModule, - ], + imports: [SharedModule, ReportsSharedModule, OrganizationReportingRoutingModule, HeaderModule], declarations: [ReportsHomeComponent], }) export class OrganizationReportingModule {} diff --git a/apps/web/src/app/admin-console/organizations/settings/organization-settings.module.ts b/apps/web/src/app/admin-console/organizations/settings/organization-settings.module.ts index bfff3b2aa2e..9b0c3035e98 100644 --- a/apps/web/src/app/admin-console/organizations/settings/organization-settings.module.ts +++ b/apps/web/src/app/admin-console/organizations/settings/organization-settings.module.ts @@ -2,8 +2,11 @@ import { NgModule } from "@angular/core"; import { ItemModule } from "@bitwarden/components"; -import { LooseComponentsModule, SharedModule } from "../../../shared"; +import { DangerZoneComponent } from "../../../auth/settings/account/danger-zone.component"; +import { HeaderModule } from "../../../layouts/header/header.module"; +import { SharedModule } from "../../../shared"; import { AccountFingerprintComponent } from "../../../shared/components/account-fingerprint/account-fingerprint.component"; +import { PremiumBadgeComponent } from "../../../vault/components/premium-badge.component"; import { PoliciesModule } from "../../organizations/policies"; import { AccountComponent } from "./account.component"; @@ -13,10 +16,12 @@ import { TwoFactorSetupComponent } from "./two-factor-setup.component"; @NgModule({ imports: [ SharedModule, - LooseComponentsModule, PoliciesModule, OrganizationSettingsRoutingModule, AccountFingerprintComponent, + DangerZoneComponent, + HeaderModule, + PremiumBadgeComponent, ItemModule, ], declarations: [AccountComponent, TwoFactorSetupComponent], diff --git a/apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts b/apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts index 7259c3f0fe8..e538e72a77e 100644 --- a/apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts +++ b/apps/web/src/app/auth/settings/two-factor/two-factor-setup.component.ts @@ -33,8 +33,9 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { DialogRef, DialogService, ItemModule } from "@bitwarden/components"; -import { LooseComponentsModule } from "../../../shared/loose-components.module"; +import { HeaderModule } from "../../../layouts/header/header.module"; import { SharedModule } from "../../../shared/shared.module"; +import { PremiumBadgeComponent } from "../../../vault/components/premium-badge.component"; import { TwoFactorRecoveryComponent } from "./two-factor-recovery.component"; import { TwoFactorSetupAuthenticatorComponent } from "./two-factor-setup-authenticator.component"; @@ -47,7 +48,7 @@ import { TwoFactorVerifyComponent } from "./two-factor-verify.component"; @Component({ selector: "app-two-factor-setup", templateUrl: "two-factor-setup.component.html", - imports: [ItemModule, LooseComponentsModule, SharedModule], + imports: [ItemModule, HeaderModule, PremiumBadgeComponent, SharedModule], }) export class TwoFactorSetupComponent implements OnInit, OnDestroy { organizationId: string; diff --git a/apps/web/src/app/billing/organizations/organization-billing.module.ts b/apps/web/src/app/billing/organizations/organization-billing.module.ts index d8f4b7393aa..707a854de02 100644 --- a/apps/web/src/app/billing/organizations/organization-billing.module.ts +++ b/apps/web/src/app/billing/organizations/organization-billing.module.ts @@ -4,7 +4,7 @@ import { NgModule } from "@angular/core"; // eslint-disable-next-line no-restricted-imports import { BannerModule } from "../../../../../../libs/components/src/banner/banner.module"; import { UserVerificationModule } from "../../auth/shared/components/user-verification"; -import { LooseComponentsModule } from "../../shared"; +import { HeaderModule } from "../../layouts/header/header.module"; import { BillingSharedModule } from "../shared"; import { AdjustSubscription } from "./adjust-subscription.component"; @@ -29,7 +29,7 @@ import { SubscriptionStatusComponent } from "./subscription-status.component"; UserVerificationModule, BillingSharedModule, OrganizationPlansComponent, - LooseComponentsModule, + HeaderModule, BannerModule, ], declarations: [ diff --git a/apps/web/src/app/oss.module.ts b/apps/web/src/app/oss.module.ts index d5fe718412a..4e04910246f 100644 --- a/apps/web/src/app/oss.module.ts +++ b/apps/web/src/app/oss.module.ts @@ -3,7 +3,9 @@ import { NgModule } from "@angular/core"; import { AuthModule } from "./auth"; import { LoginModule } from "./auth/login/login.module"; import { TrialInitiationModule } from "./billing/trial-initiation/trial-initiation.module"; -import { LooseComponentsModule, SharedModule } from "./shared"; +import { HeaderModule } from "./layouts/header/header.module"; +import { SharedModule } from "./shared"; +import { LooseComponentsModule } from "./shared/loose-components.module"; import { AccessComponent } from "./tools/send/send-access/access.component"; import { OrganizationBadgeModule } from "./vault/individual-vault/organization-badge/organization-badge.module"; import { VaultFilterModule } from "./vault/individual-vault/vault-filter/vault-filter.module"; @@ -15,6 +17,7 @@ import "./shared/locales"; imports: [ SharedModule, LooseComponentsModule, + HeaderModule, TrialInitiationModule, VaultFilterModule, OrganizationBadgeModule, @@ -24,7 +27,7 @@ import "./shared/locales"; ], exports: [ SharedModule, - LooseComponentsModule, + HeaderModule, TrialInitiationModule, VaultFilterModule, OrganizationBadgeModule, diff --git a/apps/web/src/app/shared/index.ts b/apps/web/src/app/shared/index.ts index 7defcdedfda..7a1160c4105 100644 --- a/apps/web/src/app/shared/index.ts +++ b/apps/web/src/app/shared/index.ts @@ -1,2 +1 @@ export * from "./shared.module"; -export * from "./loose-components.module"; diff --git a/apps/web/src/app/shared/loose-components.module.ts b/apps/web/src/app/shared/loose-components.module.ts index d7dbdbc4ae5..f7f3aa3bfee 100644 --- a/apps/web/src/app/shared/loose-components.module.ts +++ b/apps/web/src/app/shared/loose-components.module.ts @@ -1,18 +1,7 @@ import { NgModule } from "@angular/core"; -import { - PasswordCalloutComponent, - UserVerificationFormInputComponent, - VaultTimeoutInputComponent, -} from "@bitwarden/auth/angular"; -import { LayoutComponent, NavigationModule } from "@bitwarden/components"; - -import { OrganizationLayoutComponent } from "../admin-console/organizations/layouts/organization-layout.component"; -import { VerifyRecoverDeleteOrgComponent } from "../admin-console/organizations/manage/verify-recover-delete-org.component"; import { RecoverDeleteComponent } from "../auth/recover-delete.component"; import { RecoverTwoFactorComponent } from "../auth/recover-two-factor.component"; -import { DangerZoneComponent } from "../auth/settings/account/danger-zone.component"; -import { UserVerificationModule } from "../auth/shared/components/user-verification"; import { VerifyEmailTokenComponent } from "../auth/verify-email-token.component"; import { VerifyRecoverDeleteComponent } from "../auth/verify-recover-delete.component"; import { FreeBitwardenFamiliesComponent } from "../billing/members/free-bitwarden-families.component"; @@ -30,33 +19,15 @@ import { UnsecuredWebsitesReportComponent as OrgUnsecuredWebsitesReportComponent import { WeakPasswordsReportComponent as OrgWeakPasswordsReportComponent } from "../dirt/reports/pages/organizations/weak-passwords-report.component"; import { RemovePasswordComponent } from "../key-management/key-connector/remove-password.component"; import { HeaderModule } from "../layouts/header/header.module"; -import { PremiumBadgeComponent } from "../vault/components/premium-badge.component"; import { OrganizationBadgeModule } from "../vault/individual-vault/organization-badge/organization-badge.module"; import { PipesModule } from "../vault/individual-vault/pipes/pipes.module"; -import { AccountFingerprintComponent } from "./components/account-fingerprint/account-fingerprint.component"; import { SharedModule } from "./shared.module"; // Please do not add to this list of declarations - we should refactor these into modules when doing so makes sense until there are none left. // If you are building new functionality, please create or extend a feature module instead. @NgModule({ - imports: [ - SharedModule, - UserVerificationModule, - AccountFingerprintComponent, - OrganizationBadgeModule, - PipesModule, - PasswordCalloutComponent, - UserVerificationFormInputComponent, - DangerZoneComponent, - LayoutComponent, - NavigationModule, - HeaderModule, - OrganizationLayoutComponent, - VerifyRecoverDeleteOrgComponent, - VaultTimeoutInputComponent, - PremiumBadgeComponent, - ], + imports: [SharedModule, HeaderModule, OrganizationBadgeModule, PipesModule], declarations: [ OrgExposedPasswordsReportComponent, OrgInactiveTwoFactorReportComponent, @@ -73,25 +44,12 @@ import { SharedModule } from "./shared.module"; VerifyRecoverDeleteComponent, ], exports: [ - UserVerificationModule, - PremiumBadgeComponent, - OrganizationLayoutComponent, - OrgExposedPasswordsReportComponent, - OrgInactiveTwoFactorReportComponent, - OrgReusedPasswordsReportComponent, - OrgUnsecuredWebsitesReportComponent, - OrgWeakPasswordsReportComponent, - PremiumBadgeComponent, RecoverDeleteComponent, RecoverTwoFactorComponent, RemovePasswordComponent, SponsoredFamiliesComponent, - FreeBitwardenFamiliesComponent, - SponsoringOrgRowComponent, VerifyEmailTokenComponent, VerifyRecoverDeleteComponent, - HeaderModule, - DangerZoneComponent, ], }) export class LooseComponentsModule {} diff --git a/apps/web/src/app/tools/import/org-import.component.ts b/apps/web/src/app/tools/import/org-import.component.ts index fd833f3a698..8fb5a582b1a 100644 --- a/apps/web/src/app/tools/import/org-import.component.ts +++ b/apps/web/src/app/tools/import/org-import.component.ts @@ -14,13 +14,14 @@ import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { ImportCollectionServiceAbstraction } from "@bitwarden/importer-core"; import { ImportComponent } from "@bitwarden/importer-ui"; -import { LooseComponentsModule, SharedModule } from "../../shared"; +import { HeaderModule } from "../../layouts/header/header.module"; +import { SharedModule } from "../../shared"; import { ImportCollectionAdminService } from "./import-collection-admin.service"; @Component({ templateUrl: "org-import.component.html", - imports: [SharedModule, ImportComponent, LooseComponentsModule], + imports: [SharedModule, ImportComponent, HeaderModule], providers: [ { provide: ImportCollectionServiceAbstraction, diff --git a/apps/web/src/app/tools/vault-export/org-vault-export.component.ts b/apps/web/src/app/tools/vault-export/org-vault-export.component.ts index 94cc9bf18f7..a1de4814a13 100644 --- a/apps/web/src/app/tools/vault-export/org-vault-export.component.ts +++ b/apps/web/src/app/tools/vault-export/org-vault-export.component.ts @@ -5,11 +5,12 @@ import { ActivatedRoute } from "@angular/router"; import { ExportComponent } from "@bitwarden/vault-export-ui"; -import { LooseComponentsModule, SharedModule } from "../../shared"; +import { HeaderModule } from "../../layouts/header/header.module"; +import { SharedModule } from "../../shared"; @Component({ templateUrl: "org-vault-export.component.html", - imports: [SharedModule, ExportComponent, LooseComponentsModule], + imports: [SharedModule, ExportComponent, HeaderModule], }) export class OrganizationVaultExportComponent implements OnInit { protected routeOrgId: string = null; diff --git a/apps/web/src/app/vault/individual-vault/vault.module.ts b/apps/web/src/app/vault/individual-vault/vault.module.ts index 57d3df30df7..573eceef64a 100644 --- a/apps/web/src/app/vault/individual-vault/vault.module.ts +++ b/apps/web/src/app/vault/individual-vault/vault.module.ts @@ -3,7 +3,7 @@ import { NgModule } from "@angular/core"; import { CollectionNameBadgeComponent } from "../../admin-console/organizations/collections"; import { GroupBadgeModule } from "../../admin-console/organizations/collections/group-badge/group-badge.module"; import { CollectionDialogComponent } from "../../admin-console/organizations/shared/components/collection-dialog"; -import { LooseComponentsModule, SharedModule } from "../../shared"; +import { SharedModule } from "../../shared"; import { BulkDialogsModule } from "./bulk-action-dialogs/bulk-dialogs.module"; import { OrganizationBadgeModule } from "./organization-badge/organization-badge.module"; @@ -20,7 +20,6 @@ import { ViewComponent } from "./view.component"; CollectionNameBadgeComponent, PipesModule, SharedModule, - LooseComponentsModule, BulkDialogsModule, CollectionDialogComponent, VaultComponent, diff --git a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/device-approvals/device-approvals.component.ts b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/device-approvals/device-approvals.component.ts index f41b91261f7..bd62d972500 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/device-approvals/device-approvals.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/device-approvals/device-approvals.component.ts @@ -21,7 +21,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service"; import { TableDataSource, NoItemsModule, ToastService } from "@bitwarden/components"; import { KeyService } from "@bitwarden/key-management"; -import { LooseComponentsModule } from "@bitwarden/web-vault/app/shared"; +import { HeaderModule } from "@bitwarden/web-vault/app/layouts/header/header.module"; import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module"; @Component({ @@ -43,7 +43,7 @@ import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module"; ], }), ] satisfies SafeProvider[], - imports: [SharedModule, NoItemsModule, LooseComponentsModule], + imports: [SharedModule, NoItemsModule, HeaderModule], }) export class DeviceApprovalsComponent implements OnInit, OnDestroy { tableDataSource = new TableDataSource(); diff --git a/bitwarden_license/bit-web/src/app/admin-console/organizations/organizations.module.ts b/bitwarden_license/bit-web/src/app/admin-console/organizations/organizations.module.ts index e19d028b007..9fce712e325 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/organizations/organizations.module.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/organizations/organizations.module.ts @@ -1,6 +1,6 @@ import { NgModule } from "@angular/core"; -import { LooseComponentsModule } from "@bitwarden/web-vault/app/shared"; +import { HeaderModule } from "@bitwarden/web-vault/app/layouts/header/header.module"; import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module"; import { SsoComponent } from "../../auth/sso/sso.component"; @@ -11,7 +11,7 @@ import { ScimComponent } from "./manage/scim.component"; import { OrganizationsRoutingModule } from "./organizations-routing.module"; @NgModule({ - imports: [SharedModule, OrganizationsRoutingModule, LooseComponentsModule], + imports: [SharedModule, OrganizationsRoutingModule, HeaderModule], declarations: [ SsoComponent, ScimComponent,