Skip to content

Commit 28dc244

Browse files
authored
fix error in console (#17468)
1 parent 0912d1a commit 28dc244

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<bit-badge-list [items]="groupNames" [maxItems]="3" variant="secondary"></bit-badge-list>
1+
<bit-badge-list [items]="groupNames()" [maxItems]="3" variant="secondary"></bit-badge-list>
Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
1-
// FIXME: Update this file to be type safe and remove this and next line
2-
// @ts-strict-ignore
3-
import { Component, Input, OnChanges } from "@angular/core";
1+
import { ChangeDetectionStrategy, Component, computed, input } from "@angular/core";
42

53
import { SelectionReadOnlyRequest } from "@bitwarden/common/admin-console/models/request/selection-read-only.request";
64
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
75

86
import { GroupView } from "../../core";
97

10-
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
11-
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
128
@Component({
139
selector: "app-group-badge",
1410
templateUrl: "group-name-badge.component.html",
1511
standalone: false,
12+
changeDetection: ChangeDetectionStrategy.OnPush,
1613
})
17-
export class GroupNameBadgeComponent implements OnChanges {
18-
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
19-
// eslint-disable-next-line @angular-eslint/prefer-signals
20-
@Input() selectedGroups: SelectionReadOnlyRequest[];
21-
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
22-
// eslint-disable-next-line @angular-eslint/prefer-signals
23-
@Input() allGroups: GroupView[];
14+
export class GroupNameBadgeComponent {
15+
readonly selectedGroups = input<SelectionReadOnlyRequest[]>([]);
16+
readonly allGroups = input<GroupView[]>([]);
2417

25-
protected groupNames: string[] = [];
18+
protected readonly groupNames = computed(() => {
19+
const allGroups = this.allGroups();
20+
if (!allGroups) {
21+
return [];
22+
}
2623

27-
constructor(private i18nService: I18nService) {}
28-
29-
ngOnChanges() {
30-
this.groupNames = this.selectedGroups
24+
return this.selectedGroups()
3125
.map((g) => {
32-
return this.allGroups.find((o) => o.id === g.id)?.name;
26+
return allGroups.find((o) => o.id === g.id)?.name;
3327
})
28+
.filter((name): name is string => name !== undefined)
3429
.sort(this.i18nService.collator.compare);
35-
}
30+
});
31+
32+
constructor(private i18nService: I18nService) {}
3633
}

0 commit comments

Comments
 (0)