1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-02 18:17:46 +01:00

Updating reports to use new modal for view/edit cipher

This commit is contained in:
--global 2024-12-12 15:31:45 -05:00
parent c11f429ddb
commit 255291b0c9
12 changed files with 115 additions and 82 deletions

View File

@ -1,7 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@ -9,7 +8,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { PasswordRepromptService, DefaultCipherFormConfigService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { ExposedPasswordsReportComponent as BaseExposedPasswordsReportComponent } from "../../../tools/reports/pages/exposed-passwords-report.component";
@ -28,21 +28,23 @@ export class ExposedPasswordsReportComponent
constructor(
cipherService: CipherService,
auditService: AuditService,
modalService: ModalService,
dialogService: DialogService,
organizationService: OrganizationService,
private route: ActivatedRoute,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormService: DefaultCipherFormConfigService,
) {
super(
cipherService,
auditService,
organizationService,
modalService,
dialogService,
passwordRepromptService,
i18nService,
syncService,
cipherFormService,
);
}

View File

@ -1,14 +1,14 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { InactiveTwoFactorReportComponent as BaseInactiveTwoFactorReportComponent } from "../../../tools/reports/pages/inactive-two-factor-report.component";
@ -24,22 +24,24 @@ export class InactiveTwoFactorReportComponent
{
constructor(
cipherService: CipherService,
modalService: ModalService,
dialogService: DialogService,
private route: ActivatedRoute,
logService: LogService,
passwordRepromptService: PasswordRepromptService,
organizationService: OrganizationService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
organizationService,
modalService,
dialogService,
logService,
passwordRepromptService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -1,14 +1,14 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { ReusedPasswordsReportComponent as BaseReusedPasswordsReportComponent } from "../../../tools/reports/pages/reused-passwords-report.component";
@ -26,20 +26,22 @@ export class ReusedPasswordsReportComponent
constructor(
cipherService: CipherService,
modalService: ModalService,
dialogService: DialogService,
private route: ActivatedRoute,
organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
organizationService,
modalService,
dialogService,
passwordRepromptService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -2,13 +2,13 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { CollectionService } from "@bitwarden/admin-console/common";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { UnsecuredWebsitesReportComponent as BaseUnsecuredWebsitesReportComponent } from "../../../tools/reports/pages/unsecured-websites-report.component";
@ -24,22 +24,24 @@ export class UnsecuredWebsitesReportComponent
{
constructor(
cipherService: CipherService,
modalService: ModalService,
dialogService: DialogService,
private route: ActivatedRoute,
organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
collectionService: CollectionService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
organizationService,
modalService,
dialogService,
passwordRepromptService,
i18nService,
syncService,
collectionService,
cipherFormConfigService,
);
}

View File

@ -1,7 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
@ -9,7 +8,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { WeakPasswordsReportComponent as BaseWeakPasswordsReportComponent } from "../../../tools/reports/pages/weak-passwords-report.component";
@ -28,21 +28,23 @@ export class WeakPasswordsReportComponent
constructor(
cipherService: CipherService,
passwordStrengthService: PasswordStrengthServiceAbstraction,
modalService: ModalService,
dialogService: DialogService,
private route: ActivatedRoute,
organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
passwordStrengthService,
organizationService,
modalService,
dialogService,
passwordRepromptService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -6,6 +6,7 @@ import {
VaultTimeoutInputComponent,
} from "@bitwarden/auth/angular";
import { LayoutComponent, NavigationModule } from "@bitwarden/components";
import { DefaultCipherFormConfigService } from "@bitwarden/vault";
import { OrganizationLayoutComponent } from "../admin-console/organizations/layouts/organization-layout.component";
import { EventsComponent as OrgEventsComponent } from "../admin-console/organizations/manage/events.component";
@ -244,5 +245,6 @@ import { SharedModule } from "./shared.module";
HeaderModule,
DangerZoneComponent,
],
providers: [DefaultCipherFormConfigService],
})
export class LooseComponentsModule {}

View File

@ -1,20 +1,27 @@
import { DialogRef } from "@angular/cdk/dialog";
import { Directive, ViewChild, ViewContainerRef, OnDestroy } from "@angular/core";
import { BehaviorSubject, Observable, Subject, takeUntil } from "rxjs";
import { BehaviorSubject, lastValueFrom, Observable, Subject, takeUntil } from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { OrganizationId } from "@bitwarden/common/types/guid";
import { CipherId, CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { TableDataSource } from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService, TableDataSource } from "@bitwarden/components";
import {
CipherFormConfig,
DefaultCipherFormConfigService,
PasswordRepromptService,
} from "@bitwarden/vault";
import { AddEditComponent } from "../../../vault/individual-vault/add-edit.component";
import { AddEditComponent as OrgAddEditComponent } from "../../../vault/org-vault/add-edit.component";
import {
VaultItemDialogComponent,
VaultItemDialogMode,
VaultItemDialogResult,
} from "../../../vault/components/vault-item-dialog/vault-item-dialog.component";
@Directive()
export class CipherReportComponent implements OnDestroy {
@ -37,14 +44,16 @@ export class CipherReportComponent implements OnDestroy {
currentFilterStatus: number | string;
protected filterOrgStatus$ = new BehaviorSubject<number | string>(0);
private destroyed$: Subject<void> = new Subject();
private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined;
constructor(
protected cipherService: CipherService,
private modalService: ModalService,
private dialogService: DialogService,
protected passwordRepromptService: PasswordRepromptService,
protected organizationService: OrganizationService,
protected i18nService: I18nService,
private syncService: SyncService,
private cipherFormConfigService: DefaultCipherFormConfigService,
) {
this.organizations$ = this.organizationService.organizations$;
this.organizations$.pipe(takeUntil(this.destroyed$)).subscribe((orgs) => {
@ -125,43 +134,46 @@ export class CipherReportComponent implements OnDestroy {
this.loading = false;
this.hasLoaded = true;
}
async selectCipher(cipher: CipherView) {
if (!(await this.repromptCipher(cipher))) {
const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
"edit",
cipher.id as CipherId,
cipher.type,
);
await this.openVaultItemDialog("view", cipherFormConfig);
}
/**
* Open the combined view / edit dialog for a cipher.
* @param mode - Starting mode of the dialog.
* @param formConfig - Configuration for the form when editing/adding a cipher.
* @param activeCollectionId - The active collection ID.
*/
async openVaultItemDialog(
mode: VaultItemDialogMode,
formConfig: CipherFormConfig,
activeCollectionId?: CollectionId,
) {
this.vaultItemDialogRef = VaultItemDialogComponent.open(this.dialogService, {
mode,
formConfig,
activeCollectionId,
});
const result = await lastValueFrom(this.vaultItemDialogRef.closed);
this.vaultItemDialogRef = undefined;
// When the dialog is closed for a premium upgrade, return early as the user
// should be navigated to the subscription settings elsewhere
if (result === VaultItemDialogResult.PremiumUpgrade) {
return;
}
const type = this.organization != null ? OrgAddEditComponent : AddEditComponent;
const [modal, childComponent] = await this.modalService.openViewRef(
type,
this.cipherAddEditModalRef,
(comp: OrgAddEditComponent | AddEditComponent) => {
if (this.organization != null) {
(comp as OrgAddEditComponent).organization = this.organization;
comp.organizationId = this.organization.id;
}
comp.cipherId = cipher == null ? null : cipher.id;
// eslint-disable-next-line rxjs/no-async-subscribe
comp.onSavedCipher.subscribe(async () => {
modal.close();
await this.load();
});
// eslint-disable-next-line rxjs/no-async-subscribe
comp.onDeletedCipher.subscribe(async () => {
modal.close();
await this.load();
});
// eslint-disable-next-line rxjs/no-async-subscribe
comp.onRestoredCipher.subscribe(async () => {
modal.close();
await this.load();
});
},
);
return childComponent;
// If the dialog was closed by deleting the cipher, refresh the report.
if (result === VaultItemDialogResult.Deleted || result === VaultItemDialogResult.Saved) {
await this.load();
}
}
protected async setCiphers() {

View File

@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@ -8,7 +7,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { CipherReportComponent } from "./cipher-report.component";
@ -25,18 +25,20 @@ export class ExposedPasswordsReportComponent extends CipherReportComponent imple
protected cipherService: CipherService,
protected auditService: AuditService,
protected organizationService: OrganizationService,
modalService: ModalService,
dialogService: DialogService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
modalService,
dialogService,
passwordRepromptService,
organizationService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@ -9,7 +8,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { CipherReportComponent } from "./cipher-report.component";
@ -25,19 +25,21 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
constructor(
protected cipherService: CipherService,
protected organizationService: OrganizationService,
modalService: ModalService,
dialogService: DialogService,
private logService: LogService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
modalService,
dialogService,
passwordRepromptService,
organizationService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -1,13 +1,13 @@
import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { CipherReportComponent } from "./cipher-report.component";
@ -22,18 +22,20 @@ export class ReusedPasswordsReportComponent extends CipherReportComponent implem
constructor(
protected cipherService: CipherService,
protected organizationService: OrganizationService,
modalService: ModalService,
dialogService: DialogService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
modalService,
dialogService,
passwordRepromptService,
organizationService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -1,14 +1,14 @@
import { Component, OnInit } from "@angular/core";
import { CollectionService, Collection } from "@bitwarden/admin-console/common";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault";
import { DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { CipherReportComponent } from "./cipher-report.component";
@ -22,19 +22,21 @@ export class UnsecuredWebsitesReportComponent extends CipherReportComponent impl
constructor(
protected cipherService: CipherService,
protected organizationService: OrganizationService,
modalService: ModalService,
dialogService: DialogService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
private collectionService: CollectionService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
modalService,
dialogService,
passwordRepromptService,
organizationService,
i18nService,
syncService,
cipherFormConfigService,
);
}

View File

@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
@ -9,8 +8,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { BadgeVariant } from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";
import { BadgeVariant, DialogService } from "@bitwarden/components";
import { DefaultCipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { CipherReportComponent } from "./cipher-report.component";
@ -30,18 +29,20 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
protected cipherService: CipherService,
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
protected organizationService: OrganizationService,
modalService: ModalService,
dialogService: DialogService,
passwordRepromptService: PasswordRepromptService,
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: DefaultCipherFormConfigService,
) {
super(
cipherService,
modalService,
dialogService,
passwordRepromptService,
organizationService,
i18nService,
syncService,
cipherFormConfigService,
);
}