Skip to content

Commit

Permalink
Merge branch 'master' into sm/sm-949-service-account-event-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
differsthecat authored Oct 10, 2023
2 parents 1056495 + 524123a commit 1f483c1
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 48 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/vault/*", "src/**/*"] }]
}
},
{
"files": ["apps/browser/src/**/*.ts", "libs/**/*.ts"],
"excludedFiles": "apps/browser/src/autofill/{content,notification}/**/*.ts",
"rules": {
"no-restricted-syntax": [
"error",
{
"message": "Using addListener in the browser popup produces a memory leak in Safari, use `BrowserApi.messageListener` instead",
"selector": "CallExpression > [object.object.object.name='chrome'][object.object.property.name='runtime'][object.property.name='onMessage'][property.name='addListener']"
},
{
"message": "Using addListener in the browser popup produces a memory leak in Safari, use `BrowserApi.storageChangeListener` instead",
"selector": "CallExpression > [object.object.object.name='chrome'][object.object.property.name='storage'][object.property.name='onChanged'][property.name='addListener']"
}
]
}
}
]
}
2 changes: 2 additions & 0 deletions apps/browser/src/platform/browser/browser-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class BrowserApi {
name: string,
callback: (message: any, sender: chrome.runtime.MessageSender, response: any) => void
) {
// eslint-disable-next-line no-restricted-syntax
chrome.runtime.onMessage.addListener(callback);

if (BrowserApi.isSafariApi && !BrowserApi.isBackgroundPage(window)) {
Expand All @@ -219,6 +220,7 @@ export class BrowserApi {
static storageChangeListener(
callback: Parameters<typeof chrome.storage.onChanged.addListener>[0]
) {
// eslint-disable-next-line no-restricted-syntax
chrome.storage.onChanged.addListener(callback);

if (BrowserApi.isSafariApi && !BrowserApi.isBackgroundPage(window)) {
Expand Down
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 {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<bit-dialog dialogSize="small">
<bit-dialog dialogSize="default">
<ng-container bitDialogTitle>
<span>{{ title | i18n }}</span>
<span class="tw-text-sm tw-normal-case tw-text-muted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<bit-dialog dialogSize="small">
<bit-dialog dialogSize="default">
<span bitDialogTitle>{{ title | i18n }}</span>
<span bitDialogContent>
<div *ngIf="loading" class="tw-text-center">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<bit-dialog dialogSize="small">
<bit-dialog dialogSize="default">
<ng-container bitDialogTitle>
<span>{{ title }}</span>
<span class="tw-text-sm tw-normal-case tw-text-muted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<bit-dialog dialogSize="small">
<bit-dialog dialogSize="default">
<ng-container bitDialogTitle>{{ title | i18n }}</ng-container>
<div bitDialogContent>
<div *ngIf="loading" class="tw-text-center">
Expand Down

0 comments on commit 1f483c1

Please sign in to comment.