Skip to content

Commit 7db61ec

Browse files
committed
[PM-28451] Fix icons in application review table (bitwarden#17512)
* Fix icons in application review table * Add default icon if none is found in review applications table. Move function to computed signal * Rename function * Remove redundant if statement (cherry picked from commit 994077f)
1 parent 84eb3bf commit 7db61ec

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed

bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/application-review-dialog/new-applications-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</div>
2929

3030
<dirt-review-applications-view
31-
[applications]="getApplications()"
31+
[applications]="applicationsWithIcons()"
3232
[selectedApplications]="selectedApplications()"
3333
(onToggleSelection)="toggleSelection($event)"
3434
(onToggleAll)="toggleAll()"

bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/application-review-dialog/new-applications-dialog.component.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
} from "@bitwarden/components";
3434
import { I18nPipe } from "@bitwarden/ui-common";
3535

36+
import { CipherIcon } from "../../shared/app-table-row-scrollable.component";
3637
import { AccessIntelligenceSecurityTasksService } from "../../shared/security-tasks.service";
3738

3839
import { AssignTasksViewComponent } from "./assign-tasks-view.component";
@@ -99,6 +100,16 @@ export class NewApplicationsDialogComponent {
99100
// Applications selected to save as critical applications
100101
protected readonly selectedApplications = signal<Set<string>>(new Set());
101102

103+
protected readonly applicationIcons = signal<Map<string, CipherIcon>>(
104+
new Map<string, CipherIcon>(),
105+
);
106+
protected readonly applicationsWithIcons = computed(() => {
107+
return this.dialogParams.newApplications.map((app) => {
108+
const iconCipher = this.applicationIcons().get(app.applicationName);
109+
return { ...app, iconCipher } as ApplicationHealthReportDetail & { iconCipher: CipherIcon };
110+
});
111+
});
112+
102113
// Used to determine if there are unassigned at-risk cipher IDs
103114
private readonly _tasks!: Signal<SecurityTask[]>;
104115

@@ -150,6 +161,7 @@ export class NewApplicationsDialogComponent {
150161
private securityTasksService: AccessIntelligenceSecurityTasksService,
151162
private toastService: ToastService,
152163
) {
164+
this.setApplicationIconMap(this.dialogParams.newApplications);
153165
// Setup the _tasks signal by manually passing in the injector
154166
this._tasks = toSignal(this.securityTasksService.tasks$, {
155167
initialValue: [],
@@ -172,10 +184,6 @@ export class NewApplicationsDialogComponent {
172184
);
173185
}
174186

175-
getApplications() {
176-
return this.dialogParams.newApplications;
177-
}
178-
179187
/**
180188
* Returns true if the organization has no existing critical applications.
181189
* Used to conditionally show different titles and descriptions.
@@ -184,6 +192,22 @@ export class NewApplicationsDialogComponent {
184192
return !this.dialogParams.hasExistingCriticalApplications;
185193
}
186194

195+
/**
196+
* Maps applications to a corresponding iconCipher
197+
*
198+
* @param applications
199+
*/
200+
setApplicationIconMap(applications: ApplicationHealthReportDetail[]) {
201+
// Map the report data to include the iconCipher for each application
202+
const iconCiphers = new Map<string, CipherIcon>();
203+
applications.forEach((app) => {
204+
const iconCipher =
205+
app.cipherIds.length > 0 ? this.dataService.getCipherIcon(app.cipherIds[0]) : undefined;
206+
iconCiphers.set(app.applicationName, iconCipher);
207+
});
208+
this.applicationIcons.set(iconCiphers);
209+
}
210+
187211
/**
188212
* Toggles the selection state of an application.
189213
* @param applicationName The application to toggle

bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/application-review-dialog/review-applications-view.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
</td>
6363
<td bitTypography="body1" class="tw-py-3 tw-px-2">
6464
<div class="tw-flex tw-items-center tw-gap-2">
65-
<i class="bwi bwi-globe tw-text-muted" aria-hidden="true"></i>
65+
@if (app.iconCipher) {
66+
<app-vault-icon [cipher]="app.iconCipher"></app-vault-icon>
67+
} @else {
68+
<i class="bwi bwi-globe tw-text-muted" aria-hidden="true"></i>
69+
}
6670
<span>{{ app.applicationName }}</span>
6771
</div>
6872
</td>

bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/application-review-dialog/review-applications-view.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { FormsModule } from "@angular/forms";
55
import { ApplicationHealthReportDetail } from "@bitwarden/bit-common/dirt/reports/risk-insights";
66
import { ButtonModule, DialogModule, SearchModule, TypographyModule } from "@bitwarden/components";
77
import { I18nPipe } from "@bitwarden/ui-common";
8+
import { SharedModule } from "@bitwarden/web-vault/app/shared";
9+
10+
import { CipherIcon } from "../../shared/app-table-row-scrollable.component";
811

912
@Component({
1013
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -18,10 +21,12 @@ import { I18nPipe } from "@bitwarden/ui-common";
1821
SearchModule,
1922
TypographyModule,
2023
I18nPipe,
24+
SharedModule,
2125
],
2226
})
2327
export class ReviewApplicationsViewComponent {
24-
readonly applications = input.required<ApplicationHealthReportDetail[]>();
28+
readonly applications =
29+
input.required<Array<ApplicationHealthReportDetail & { iconCipher: CipherIcon }>>();
2530
readonly selectedApplications = input.required<Set<string>>();
2631

2732
protected readonly searchText = signal<string>("");

bitwarden_license/bit-web/src/app/dirt/access-intelligence/shared/app-table-row-scrollable.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
tabindex="0"
4646
[attr.aria-label]="'viewItem' | i18n"
4747
>
48-
<!-- Passing the first cipher of the application for app-vault-icon cipher input requirement -->
4948
<app-vault-icon *ngIf="row.iconCipher" [cipher]="row.iconCipher"></app-vault-icon>
5049
</td>
5150
<td

bitwarden_license/bit-web/src/app/dirt/access-intelligence/shared/app-table-row-scrollable.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { MenuModule, TableDataSource, TableModule } from "@bitwarden/components"
88
import { SharedModule } from "@bitwarden/web-vault/app/shared";
99
import { PipesModule } from "@bitwarden/web-vault/app/vault/individual-vault/pipes/pipes.module";
1010

11+
export type CipherIcon = CipherViewLike | undefined;
12+
1113
export type ApplicationTableDataSource = ApplicationHealthReportDetailEnriched & {
12-
iconCipher: CipherViewLike | undefined;
14+
iconCipher: CipherIcon;
1315
};
1416

1517
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush

0 commit comments

Comments
 (0)