From 67d246606d69693f10388c49162d78df6ead5acb Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 14 Aug 2025 12:58:28 -0400 Subject: [PATCH] fix routing to policies and add run report logic to modal component --- .../no-data-modal.component.ts | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/no-data-modal.component.ts b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/no-data-modal.component.ts index ee5c703b43c..167e54321ca 100644 --- a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/no-data-modal.component.ts +++ b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/no-data-modal.component.ts @@ -1,5 +1,6 @@ import { DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; import { Component, Inject } from "@angular/core"; +import { Router } from "@angular/router"; import { ButtonModule } from "@bitwarden/components"; @@ -104,14 +105,50 @@ export class NoDataModalComponent { constructor( public dialogRef: DialogRef, @Inject(DIALOG_DATA) public data: any, + private router: Router, ) {} - navigateToPolicy(): void { - // TODO: Navigate to the policy page - // Navigate to policy page when implemented + async navigateToPolicy(): Promise { + // Check if we have the organizationId + if (!this.data.organizationId) { + return; + } + + // Close the modal first + this.dialogRef.close(true); + + // Add a small delay to ensure modal closes before navigation + await new Promise(resolve => setTimeout(resolve, 100)); + + // Try to navigate using router first + try { + const result = await this.router.navigate([ + '/organizations', + this.data.organizationId, + 'settings', + 'policies' + ]); + + // If router navigation fails, use window.location as fallback + if (!result) { + window.location.href = `/#/organizations/${this.data.organizationId}/settings/policies`; + } + } catch { + // Fallback to window.location if router navigation throws an error + window.location.href = `/#/organizations/${this.data.organizationId}/settings/policies`; + } } - runReport(): void { + async runReport(): Promise { + // Close the modal first this.dialogRef.close(true); + + // Add a small delay to ensure modal closes before triggering the report + await new Promise(resolve => setTimeout(resolve, 100)); + + // Trigger the report generation + if (this.data.riskInsightsDataService) { + this.data.riskInsightsDataService.triggerReport(); + } } }