-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-27933] Skip assign tasks view if no critical applications are selected #17351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Banrion
merged 2 commits into
main
from
dirt/pm-27933/review-applications-skip-when-no-tasks
Nov 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,16 @@ import { CommonModule } from "@angular/common"; | |
| import { | ||
| ChangeDetectionStrategy, | ||
| Component, | ||
| computed, | ||
| DestroyRef, | ||
| Inject, | ||
| inject, | ||
| Injector, | ||
| Signal, | ||
| signal, | ||
| } from "@angular/core"; | ||
| import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; | ||
| import { from, switchMap, take } from "rxjs"; | ||
| import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop"; | ||
| import { from, of, switchMap, take } from "rxjs"; | ||
|
|
||
| import { | ||
| ApplicationHealthReportDetail, | ||
|
|
@@ -17,7 +20,8 @@ import { | |
| import { getUniqueMembers } from "@bitwarden/bit-common/dirt/reports/risk-insights/helpers"; | ||
| import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
| import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; | ||
| import { OrganizationId } from "@bitwarden/common/types/guid"; | ||
| import { CipherId, OrganizationId } from "@bitwarden/common/types/guid"; | ||
| import { SecurityTask, SecurityTaskStatus } from "@bitwarden/common/vault/tasks"; | ||
| import { | ||
| ButtonModule, | ||
| DIALOG_DATA, | ||
|
|
@@ -70,9 +74,9 @@ export type NewApplicationsDialogResultType = | |
| (typeof NewApplicationsDialogResultType)[keyof typeof NewApplicationsDialogResultType]; | ||
|
|
||
| @Component({ | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| selector: "dirt-new-applications-dialog", | ||
| templateUrl: "./new-applications-dialog.component.html", | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| imports: [ | ||
| CommonModule, | ||
| ButtonModule, | ||
|
|
@@ -95,24 +99,63 @@ export class NewApplicationsDialogComponent { | |
| // Applications selected to save as critical applications | ||
| protected readonly selectedApplications = signal<Set<string>>(new Set()); | ||
|
|
||
| // Assign tasks variables | ||
| readonly atRiskCriticalApplicationsCount = signal<number>(0); | ||
| readonly totalCriticalApplicationsCount = signal<number>(0); | ||
| readonly atRiskCriticalMembersCount = signal<number>(0); | ||
| // Used to determine if there are unassigned at-risk cipher IDs | ||
| private readonly _tasks!: Signal<SecurityTask[]>; | ||
|
|
||
| // Computed properties for selected applications | ||
| protected readonly newCriticalApplications = computed(() => { | ||
| return this.dialogParams.newApplications.filter((newApp) => | ||
| this.selectedApplications().has(newApp.applicationName), | ||
| ); | ||
| }); | ||
|
|
||
| // New at risk critical applications | ||
| protected readonly newAtRiskCriticalApplications = computed(() => { | ||
| return this.newCriticalApplications().filter((app) => app.atRiskPasswordCount > 0); | ||
| }); | ||
|
|
||
| // Count of unique members with at-risk passwords in newly marked critical applications | ||
| protected readonly atRiskCriticalMembersCount = computed(() => { | ||
| return getUniqueMembers(this.newCriticalApplications().flatMap((x) => x.atRiskMemberDetails)) | ||
| .length; | ||
| }); | ||
|
|
||
| protected readonly newUnassignedAtRiskCipherIds = computed<CipherId[]>(() => { | ||
| const newAtRiskCipherIds = this.newCriticalApplications().flatMap((app) => app.atRiskCipherIds); | ||
| const tasks = this._tasks(); | ||
|
|
||
| if (tasks.length === 0) { | ||
| return newAtRiskCipherIds; | ||
| } | ||
|
|
||
| const inProgressTasks = tasks.filter((task) => task.status === SecurityTaskStatus.Pending); | ||
| const assignedIdSet = new Set(inProgressTasks.map((task) => task.cipherId)); | ||
| const unassignedIds = newAtRiskCipherIds.filter((id) => !assignedIdSet.has(id)); | ||
| return unassignedIds; | ||
| }); | ||
|
|
||
| readonly saving = signal<boolean>(false); | ||
|
|
||
| // Loading states | ||
| protected readonly markingAsCritical = signal<boolean>(false); | ||
|
|
||
| constructor( | ||
| @Inject(DIALOG_DATA) protected dialogParams: NewApplicationsDialogData, | ||
| private dialogRef: DialogRef<NewApplicationsDialogResultType>, | ||
| private dataService: RiskInsightsDataService, | ||
| private toastService: ToastService, | ||
| private dialogRef: DialogRef<NewApplicationsDialogResultType>, | ||
| private dialogService: DialogService, | ||
| private i18nService: I18nService, | ||
| private accessIntelligenceSecurityTasksService: AccessIntelligenceSecurityTasksService, | ||
| private injector: Injector, | ||
| private logService: LogService, | ||
| ) {} | ||
| private securityTasksService: AccessIntelligenceSecurityTasksService, | ||
| private toastService: ToastService, | ||
| ) { | ||
| // Setup the _tasks signal by manually passing in the injector | ||
| this._tasks = toSignal(this.securityTasksService.tasks$, { | ||
| initialValue: [], | ||
| injector: this.injector, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Opens the new applications dialog | ||
|
|
@@ -170,54 +213,63 @@ export class NewApplicationsDialogComponent { | |
| }); | ||
| } | ||
|
|
||
| handleMarkAsCritical() { | ||
| if (this.markingAsCritical() || this.saving()) { | ||
| return; // Prevent action if already processing | ||
| } | ||
| this.markingAsCritical.set(true); | ||
|
|
||
| const onlyNewCriticalApplications = this.dialogParams.newApplications.filter((newApp) => | ||
| this.selectedApplications().has(newApp.applicationName), | ||
| ); | ||
|
|
||
| // Count only critical applications that have at-risk passwords | ||
| const atRiskCriticalApplicationsCount = onlyNewCriticalApplications.filter( | ||
| (app) => app.atRiskPasswordCount > 0, | ||
| ).length; | ||
| this.atRiskCriticalApplicationsCount.set(atRiskCriticalApplicationsCount); | ||
|
|
||
| // Total number of selected critical applications | ||
| this.totalCriticalApplicationsCount.set(onlyNewCriticalApplications.length); | ||
| // Checks if there are selected applications and proceeds to assign tasks | ||
| async handleMarkAsCritical() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ The if (this.markingAsCritical()) {
return;
}
this.markingAsCritical.set(true);And then set it to |
||
| if (this.selectedApplications().size === 0) { | ||
| const confirmed = await this.dialogService.openSimpleDialog({ | ||
| title: { key: "confirmNoSelectedCriticalApplicationsTitle" }, | ||
| content: { key: "confirmNoSelectedCriticalApplicationsDesc" }, | ||
| type: "warning", | ||
| }); | ||
|
|
||
| const atRiskCriticalMembersCount = getUniqueMembers( | ||
| onlyNewCriticalApplications.flatMap((x) => x.atRiskMemberDetails), | ||
| ).length; | ||
| this.atRiskCriticalMembersCount.set(atRiskCriticalMembersCount); | ||
| if (!confirmed) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| this.currentView.set(DialogView.AssignTasks); | ||
| this.markingAsCritical.set(false); | ||
| // Skip the assign tasks view if there are no new unassigned at-risk cipher IDs | ||
| if (this.newUnassignedAtRiskCipherIds().length === 0) { | ||
| this.handleAssignTasks(); | ||
| } else { | ||
| this.currentView.set(DialogView.AssignTasks); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Handles the assign tasks button click | ||
| */ | ||
| // Saves the application review and assigns tasks for unassigned at-risk ciphers | ||
| protected handleAssignTasks() { | ||
| if (this.saving()) { | ||
| return; // Prevent double-click | ||
| } | ||
| this.saving.set(true); | ||
|
|
||
| const reviewedDate = new Date(); | ||
| const updatedApplications = this.dialogParams.newApplications.map((app) => { | ||
| const isCritical = this.selectedApplications().has(app.applicationName); | ||
| return { | ||
| applicationName: app.applicationName, | ||
| isCritical, | ||
| reviewedDate, | ||
| }; | ||
| }); | ||
|
|
||
| // Save the application review dates and critical markings | ||
| this.dataService.criticalApplicationAtRiskCipherIds$ | ||
| this.dataService | ||
| .saveApplicationReviewStatus(updatedApplications) | ||
| .pipe( | ||
| takeUntilDestroyed(this.destroyRef), // Satisfy eslint rule | ||
| take(1), // Handle unsubscribe for one off operation | ||
| switchMap((criticalApplicationAtRiskCipherIds) => { | ||
| return from( | ||
| this.accessIntelligenceSecurityTasksService.requestPasswordChangeForCriticalApplications( | ||
| this.dialogParams.organizationId, | ||
| criticalApplicationAtRiskCipherIds, | ||
| ), | ||
| takeUntilDestroyed(this.destroyRef), // Satisfy eslint rule, | ||
Banrion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| take(1), | ||
| switchMap(() => { | ||
| // Assign password change tasks for unassigned at-risk ciphers for critical applications | ||
| return of(this.newUnassignedAtRiskCipherIds()).pipe( | ||
| takeUntilDestroyed(this.destroyRef), // Satisfy eslint rule | ||
Banrion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| switchMap((criticalApplicationAtRiskCipherIds) => { | ||
| return from( | ||
| this.securityTasksService.requestPasswordChangeForCriticalApplications( | ||
| this.dialogParams.organizationId, | ||
| criticalApplicationAtRiskCipherIds, | ||
| ), | ||
| ); | ||
| }), | ||
Banrion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| }), | ||
| ) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.