Skip to content

Commit

Permalink
[PM-4198][TechDebt] Split up import and export modules (#6483)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
djsmith85 and djsmith85 authored Oct 10, 2023
1 parent ad86715 commit 3e720c0
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
},
],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,23 @@ 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: {
titleId: "importData",
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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -42,4 +41,4 @@ import { OrganizationImportComponent } from "./org-import.component";
},
],
})
export class OrganizationImportExportModule {}
export class OrganizationImportModule {}
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {}
10 changes: 6 additions & 4 deletions apps/web/src/app/oss-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/app/tools/import/import-routing.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -53,4 +51,4 @@ import { ImportComponent } from "./import.component";
},
],
})
export class ImportExportModule {}
export class ImportModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
},
Expand All @@ -20,4 +14,4 @@ const routes: Routes = [
@NgModule({
imports: [RouterModule.forChild(routes)],
})
export class ImportExportRoutingModule {}
export class ExportRoutingModule {}
12 changes: 12 additions & 0 deletions apps/web/src/app/tools/vault-export/export.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 3e720c0

Please sign in to comment.