1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00

[PM-13404] Weak Passwords Report - Sort by password weakness (#12359)

* [PM-13404] Weak Passwords Report - Sort by password weakness

* [PM-13404] Weak Passwords Report lint error fix

* Test signed commit
This commit is contained in:
albertboyd5
2025-01-27 15:25:40 -06:00
committed by GitHub
parent da422fd1bb
commit 582beaf706
2 changed files with 31 additions and 1 deletions

View File

@@ -39,7 +39,13 @@
<th bitCell bitSortable="organizationId" *ngIf="!isAdminConsoleActive">
{{ "owner" | i18n }}
</th>
<th bitCell class="tw-text-right" bitSortable="score" default>
<th
bitCell
class="tw-text-right"
bitSortable="score"
default
(sortChange)="onSortChange('score', $event)"
>
{{ "weakness" | i18n }}
</th>
</tr>

View File

@@ -59,6 +59,7 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
this.weakPasswordCiphers = [];
this.filterStatus = [0];
this.findWeakPasswords(allCiphers);
this.weakPasswordCiphers = this.sortCiphers(this.weakPasswordCiphers, "score", false);
}
protected findWeakPasswords(ciphers: CipherView[]): void {
@@ -112,6 +113,29 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
this.filterCiphersByOrg(this.weakPasswordCiphers);
}
onSortChange(field: string, event: Event) {
const target = event.target as HTMLInputElement;
const ascending = target.checked;
this.weakPasswordCiphers = this.sortCiphers(this.weakPasswordCiphers, field, ascending);
}
protected sortCiphers(
ciphers: ReportResult[],
field: string,
ascending: boolean,
): ReportResult[] {
return ciphers.sort((a, b) => {
const aValue = a[field as keyof ReportResult];
const bValue = b[field as keyof ReportResult];
if (aValue === bValue) {
return 0;
}
const comparison = aValue > bValue ? 1 : -1;
return ascending ? comparison : -comparison;
});
}
protected canManageCipher(c: CipherView): boolean {
// this will only ever be false from the org view;
return true;