From 3e720c05f21a68e78fab196c9fec08d1374c1fdc Mon Sep 17 00:00:00 2001 From: Daniel James Smith <2670567+djsmith85@users.noreply.github.com> Date: Tue, 10 Oct 2023 19:12:13 +0200 Subject: [PATCH] [PM-4198][TechDebt] Split up import and export modules (#6483) * Split up import/export into separate modules * Fix routing and apply PR feedback * Renamed OrganizationExport exports to OrganizationVaultExport * Renamed filenames according to export rename --------- Co-authored-by: Daniel James Smith --- .../organization-settings-routing.module.ts | 18 ++++++++++--- .../org-import-routing.module.ts} | 16 +++--------- .../org-import.component.ts | 4 +-- .../org-import.module.ts} | 9 +++---- .../org-vault-export-routing.module.ts | 25 +++++++++++++++++++ .../org-vault-export.component.ts} | 6 ++--- .../vault-export/org-vault-export.module.ts | 12 +++++++++ apps/web/src/app/oss-routing.module.ts | 10 +++++--- .../file-password-prompt.component.html | 0 .../dialog/file-password-prompt.component.ts | 0 .../dialog/import-error-dialog.component.html | 0 .../dialog/import-error-dialog.component.ts | 0 .../import-success-dialog.component.html | 0 .../dialog/import-success-dialog.component.ts | 0 .../{import-export => import}/dialog/index.ts | 0 .../app/tools/import/import-routing.module.ts | 17 +++++++++++++ .../import.component.html | 0 .../import.component.ts | 0 .../import.module.ts} | 8 +++--- .../export-routing.module.ts} | 10 ++------ .../export.component.html | 0 .../export.component.ts | 0 .../app/tools/vault-export/export.module.ts | 12 +++++++++ 23 files changed, 103 insertions(+), 44 deletions(-) rename apps/web/src/app/admin-console/organizations/tools/{import-export/org-import-export-routing.module.ts => import/org-import-routing.module.ts} (53%) rename apps/web/src/app/admin-console/organizations/tools/{import-export => import}/org-import.component.ts (95%) rename apps/web/src/app/admin-console/organizations/tools/{import-export/org-import-export.module.ts => import/org-import.module.ts} (81%) create mode 100644 apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export-routing.module.ts rename apps/web/src/app/admin-console/organizations/tools/{import-export/org-export.component.ts => vault-export/org-vault-export.component.ts} (92%) create mode 100644 apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.module.ts rename apps/web/src/app/tools/{import-export => import}/dialog/file-password-prompt.component.html (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/file-password-prompt.component.ts (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/import-error-dialog.component.html (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/import-error-dialog.component.ts (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/import-success-dialog.component.html (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/import-success-dialog.component.ts (100%) rename apps/web/src/app/tools/{import-export => import}/dialog/index.ts (100%) create mode 100644 apps/web/src/app/tools/import/import-routing.module.ts rename apps/web/src/app/tools/{import-export => import}/import.component.html (100%) rename apps/web/src/app/tools/{import-export => import}/import.component.ts (100%) rename apps/web/src/app/tools/{import-export/import-export.module.ts => import/import.module.ts} (85%) rename apps/web/src/app/tools/{import-export/import-export-routing.module.ts => vault-export/export-routing.module.ts} (60%) rename apps/web/src/app/tools/{import-export => vault-export}/export.component.html (100%) rename apps/web/src/app/tools/{import-export => vault-export}/export.component.ts (100%) create mode 100644 apps/web/src/app/tools/vault-export/export.module.ts diff --git a/apps/web/src/app/admin-console/organizations/settings/organization-settings-routing.module.ts b/apps/web/src/app/admin-console/organizations/settings/organization-settings-routing.module.ts index 7feda23f5c..1606d86497 100644 --- a/apps/web/src/app/admin-console/organizations/settings/organization-settings-routing.module.ts +++ b/apps/web/src/app/admin-console/organizations/settings/organization-settings-routing.module.ts @@ -45,10 +45,20 @@ const routes: Routes = [ }, { path: "tools", - loadChildren: () => - import("../tools/import-export/org-import-export.module").then( - (m) => m.OrganizationImportExportModule - ), + children: [ + { + path: "import", + loadChildren: () => + import("../tools/import/org-import.module").then((m) => m.OrganizationImportModule), + }, + { + path: "export", + loadChildren: () => + import("../tools/vault-export/org-vault-export.module").then( + (m) => m.OrganizationVaultExportModule + ), + }, + ], }, ], }, diff --git a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export-routing.module.ts b/apps/web/src/app/admin-console/organizations/tools/import/org-import-routing.module.ts similarity index 53% rename from apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export-routing.module.ts rename to apps/web/src/app/admin-console/organizations/tools/import/org-import-routing.module.ts index c0430ab2e0..9b4b4b5c78 100644 --- a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export-routing.module.ts +++ b/apps/web/src/app/admin-console/organizations/tools/import/org-import-routing.module.ts @@ -3,14 +3,13 @@ import { RouterModule, Routes } from "@angular/router"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; -import { OrganizationPermissionsGuard } from "../../../../admin-console/organizations/guards/org-permissions.guard"; +import { OrganizationPermissionsGuard } from "../../guards/org-permissions.guard"; -import { OrganizationExportComponent } from "./org-export.component"; import { OrganizationImportComponent } from "./org-import.component"; const routes: Routes = [ { - path: "import", + path: "", component: OrganizationImportComponent, canActivate: [OrganizationPermissionsGuard], data: { @@ -18,18 +17,9 @@ const routes: Routes = [ organizationPermissions: (org: Organization) => org.canAccessImportExport, }, }, - { - path: "export", - component: OrganizationExportComponent, - canActivate: [OrganizationPermissionsGuard], - data: { - titleId: "exportVault", - organizationPermissions: (org: Organization) => org.canAccessImportExport, - }, - }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], }) -export class OrganizationImportExportRoutingModule {} +export class OrganizationImportRoutingModule {} diff --git a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import.component.ts b/apps/web/src/app/admin-console/organizations/tools/import/org-import.component.ts similarity index 95% rename from apps/web/src/app/admin-console/organizations/tools/import-export/org-import.component.ts rename to apps/web/src/app/admin-console/organizations/tools/import/org-import.component.ts index e8dad8baf4..b514f2bcf3 100644 --- a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import.component.ts +++ b/apps/web/src/app/admin-console/organizations/tools/import/org-import.component.ts @@ -18,11 +18,11 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv import { DialogService } from "@bitwarden/components"; import { ImportServiceAbstraction } from "@bitwarden/importer"; -import { ImportComponent } from "../../../../tools/import-export/import.component"; +import { ImportComponent } from "../../../../tools/import/import.component"; @Component({ selector: "app-org-import", - templateUrl: "../../../../tools/import-export/import.component.html", + templateUrl: "../../../../tools/import/import.component.html", }) // eslint-disable-next-line rxjs-angular/prefer-takeuntil export class OrganizationImportComponent extends ImportComponent { diff --git a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export.module.ts b/apps/web/src/app/admin-console/organizations/tools/import/org-import.module.ts similarity index 81% rename from apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export.module.ts rename to apps/web/src/app/admin-console/organizations/tools/import/org-import.module.ts index e40e961ac9..66a22158e2 100644 --- a/apps/web/src/app/admin-console/organizations/tools/import-export/org-import-export.module.ts +++ b/apps/web/src/app/admin-console/organizations/tools/import/org-import.module.ts @@ -15,13 +15,12 @@ import { import { LooseComponentsModule, SharedModule } from "../../../../shared"; -import { OrganizationExportComponent } from "./org-export.component"; -import { OrganizationImportExportRoutingModule } from "./org-import-export-routing.module"; +import { OrganizationImportRoutingModule } from "./org-import-routing.module"; import { OrganizationImportComponent } from "./org-import.component"; @NgModule({ - imports: [SharedModule, LooseComponentsModule, OrganizationImportExportRoutingModule], - declarations: [OrganizationImportComponent, OrganizationExportComponent], + imports: [SharedModule, LooseComponentsModule, OrganizationImportRoutingModule], + declarations: [OrganizationImportComponent], providers: [ { provide: ImportApiServiceAbstraction, @@ -42,4 +41,4 @@ import { OrganizationImportComponent } from "./org-import.component"; }, ], }) -export class OrganizationImportExportModule {} +export class OrganizationImportModule {} diff --git a/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export-routing.module.ts b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export-routing.module.ts new file mode 100644 index 0000000000..e3e809a550 --- /dev/null +++ b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export-routing.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from "@angular/core"; +import { RouterModule, Routes } from "@angular/router"; + +import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; + +import { OrganizationPermissionsGuard } from "../../guards/org-permissions.guard"; + +import { OrganizationVaultExportComponent } from "./org-vault-export.component"; + +const routes: Routes = [ + { + path: "", + component: OrganizationVaultExportComponent, + canActivate: [OrganizationPermissionsGuard], + data: { + titleId: "exportVault", + organizationPermissions: (org: Organization) => org.canAccessImportExport, + }, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], +}) +export class OrganizationVaultExportRoutingModule {} diff --git a/apps/web/src/app/admin-console/organizations/tools/import-export/org-export.component.ts b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.component.ts similarity index 92% rename from apps/web/src/app/admin-console/organizations/tools/import-export/org-export.component.ts rename to apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.component.ts index 9ea1442fd1..ae91150f60 100644 --- a/apps/web/src/app/admin-console/organizations/tools/import-export/org-export.component.ts +++ b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.component.ts @@ -14,14 +14,14 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl import { DialogService } from "@bitwarden/components"; import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export"; -import { ExportComponent } from "../../../../tools/import-export/export.component"; +import { ExportComponent } from "../../../../tools/vault-export/export.component"; @Component({ selector: "app-org-export", - templateUrl: "../../../../tools/import-export/export.component.html", + templateUrl: "../../../../tools/vault-export/export.component.html", }) // eslint-disable-next-line rxjs-angular/prefer-takeuntil -export class OrganizationExportComponent extends ExportComponent { +export class OrganizationVaultExportComponent extends ExportComponent { constructor( cryptoService: CryptoService, i18nService: I18nService, diff --git a/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.module.ts b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.module.ts new file mode 100644 index 0000000000..34b4fa4adb --- /dev/null +++ b/apps/web/src/app/admin-console/organizations/tools/vault-export/org-vault-export.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from "@angular/core"; + +import { LooseComponentsModule, SharedModule } from "../../../../shared"; + +import { OrganizationVaultExportRoutingModule } from "./org-vault-export-routing.module"; +import { OrganizationVaultExportComponent } from "./org-vault-export.component"; + +@NgModule({ + imports: [SharedModule, LooseComponentsModule, OrganizationVaultExportRoutingModule], + declarations: [OrganizationVaultExportComponent], +}) +export class OrganizationVaultExportModule {} diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index 58d3f60134..d8a57cd3fb 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -254,11 +254,13 @@ const routes: Routes = [ children: [ { path: "", pathMatch: "full", redirectTo: "generator" }, { - path: "", + path: "import", + loadChildren: () => import("./tools/import/import.module").then((m) => m.ImportModule), + }, + { + path: "export", loadChildren: () => - import("./tools/import-export/import-export.module").then( - (m) => m.ImportExportModule - ), + import("./tools/vault-export/export.module").then((m) => m.ExportModule), }, { path: "generator", diff --git a/apps/web/src/app/tools/import-export/dialog/file-password-prompt.component.html b/apps/web/src/app/tools/import/dialog/file-password-prompt.component.html similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/file-password-prompt.component.html rename to apps/web/src/app/tools/import/dialog/file-password-prompt.component.html diff --git a/apps/web/src/app/tools/import-export/dialog/file-password-prompt.component.ts b/apps/web/src/app/tools/import/dialog/file-password-prompt.component.ts similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/file-password-prompt.component.ts rename to apps/web/src/app/tools/import/dialog/file-password-prompt.component.ts diff --git a/apps/web/src/app/tools/import-export/dialog/import-error-dialog.component.html b/apps/web/src/app/tools/import/dialog/import-error-dialog.component.html similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/import-error-dialog.component.html rename to apps/web/src/app/tools/import/dialog/import-error-dialog.component.html diff --git a/apps/web/src/app/tools/import-export/dialog/import-error-dialog.component.ts b/apps/web/src/app/tools/import/dialog/import-error-dialog.component.ts similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/import-error-dialog.component.ts rename to apps/web/src/app/tools/import/dialog/import-error-dialog.component.ts diff --git a/apps/web/src/app/tools/import-export/dialog/import-success-dialog.component.html b/apps/web/src/app/tools/import/dialog/import-success-dialog.component.html similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/import-success-dialog.component.html rename to apps/web/src/app/tools/import/dialog/import-success-dialog.component.html diff --git a/apps/web/src/app/tools/import-export/dialog/import-success-dialog.component.ts b/apps/web/src/app/tools/import/dialog/import-success-dialog.component.ts similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/import-success-dialog.component.ts rename to apps/web/src/app/tools/import/dialog/import-success-dialog.component.ts diff --git a/apps/web/src/app/tools/import-export/dialog/index.ts b/apps/web/src/app/tools/import/dialog/index.ts similarity index 100% rename from apps/web/src/app/tools/import-export/dialog/index.ts rename to apps/web/src/app/tools/import/dialog/index.ts diff --git a/apps/web/src/app/tools/import/import-routing.module.ts b/apps/web/src/app/tools/import/import-routing.module.ts new file mode 100644 index 0000000000..82d0a73384 --- /dev/null +++ b/apps/web/src/app/tools/import/import-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from "@angular/core"; +import { RouterModule, Routes } from "@angular/router"; + +import { ImportComponent } from "./import.component"; + +const routes: Routes = [ + { + path: "", + component: ImportComponent, + data: { titleId: "importData" }, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], +}) +export class ImportRoutingModule {} diff --git a/apps/web/src/app/tools/import-export/import.component.html b/apps/web/src/app/tools/import/import.component.html similarity index 100% rename from apps/web/src/app/tools/import-export/import.component.html rename to apps/web/src/app/tools/import/import.component.html diff --git a/apps/web/src/app/tools/import-export/import.component.ts b/apps/web/src/app/tools/import/import.component.ts similarity index 100% rename from apps/web/src/app/tools/import-export/import.component.ts rename to apps/web/src/app/tools/import/import.component.ts diff --git a/apps/web/src/app/tools/import-export/import-export.module.ts b/apps/web/src/app/tools/import/import.module.ts similarity index 85% rename from apps/web/src/app/tools/import-export/import-export.module.ts rename to apps/web/src/app/tools/import/import.module.ts index d180417cdc..34f71cfab7 100644 --- a/apps/web/src/app/tools/import-export/import-export.module.ts +++ b/apps/web/src/app/tools/import/import.module.ts @@ -20,15 +20,13 @@ import { ImportSuccessDialogComponent, FilePasswordPromptComponent, } from "./dialog"; -import { ExportComponent } from "./export.component"; -import { ImportExportRoutingModule } from "./import-export-routing.module"; +import { ImportRoutingModule } from "./import-routing.module"; import { ImportComponent } from "./import.component"; @NgModule({ - imports: [SharedModule, LooseComponentsModule, ImportExportRoutingModule], + imports: [SharedModule, LooseComponentsModule, ImportRoutingModule], declarations: [ ImportComponent, - ExportComponent, FilePasswordPromptComponent, ImportErrorDialogComponent, ImportSuccessDialogComponent, @@ -53,4 +51,4 @@ import { ImportComponent } from "./import.component"; }, ], }) -export class ImportExportModule {} +export class ImportModule {} diff --git a/apps/web/src/app/tools/import-export/import-export-routing.module.ts b/apps/web/src/app/tools/vault-export/export-routing.module.ts similarity index 60% rename from apps/web/src/app/tools/import-export/import-export-routing.module.ts rename to apps/web/src/app/tools/vault-export/export-routing.module.ts index 101e149d7f..3afda4a06f 100644 --- a/apps/web/src/app/tools/import-export/import-export-routing.module.ts +++ b/apps/web/src/app/tools/vault-export/export-routing.module.ts @@ -2,16 +2,10 @@ import { NgModule } from "@angular/core"; import { RouterModule, Routes } from "@angular/router"; import { ExportComponent } from "./export.component"; -import { ImportComponent } from "./import.component"; const routes: Routes = [ { - path: "import", - component: ImportComponent, - data: { titleId: "importData" }, - }, - { - path: "export", + path: "", component: ExportComponent, data: { titleId: "exportVault" }, }, @@ -20,4 +14,4 @@ const routes: Routes = [ @NgModule({ imports: [RouterModule.forChild(routes)], }) -export class ImportExportRoutingModule {} +export class ExportRoutingModule {} diff --git a/apps/web/src/app/tools/import-export/export.component.html b/apps/web/src/app/tools/vault-export/export.component.html similarity index 100% rename from apps/web/src/app/tools/import-export/export.component.html rename to apps/web/src/app/tools/vault-export/export.component.html diff --git a/apps/web/src/app/tools/import-export/export.component.ts b/apps/web/src/app/tools/vault-export/export.component.ts similarity index 100% rename from apps/web/src/app/tools/import-export/export.component.ts rename to apps/web/src/app/tools/vault-export/export.component.ts diff --git a/apps/web/src/app/tools/vault-export/export.module.ts b/apps/web/src/app/tools/vault-export/export.module.ts new file mode 100644 index 0000000000..aca8bdbd4e --- /dev/null +++ b/apps/web/src/app/tools/vault-export/export.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from "@angular/core"; + +import { LooseComponentsModule, SharedModule } from "../../shared"; + +import { ExportRoutingModule } from "./export-routing.module"; +import { ExportComponent } from "./export.component"; + +@NgModule({ + imports: [SharedModule, LooseComponentsModule, ExportRoutingModule], + declarations: [ExportComponent], +}) +export class ExportModule {}