Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bitwarden/clients into arch/split-k…
Browse files Browse the repository at this point in the history
…m-ui
  • Loading branch information
Hinton committed Jan 28, 2025
2 parents d615815 + 582beaf commit ed5291a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions libs/common/src/platform/sync/core-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ApiService } from "../../abstractions/api.service";
import { AccountService } from "../../auth/abstractions/account.service";
import { AuthService } from "../../auth/abstractions/auth.service";
import { AuthenticationStatus } from "../../auth/enums/authentication-status";
import { getUserId } from "../../auth/services/account.service";
import {
SyncCipherNotification,
SyncFolderNotification,
Expand Down Expand Up @@ -59,7 +58,7 @@ export abstract class CoreSyncService implements SyncService {
abstract fullSync(forceSync: boolean, allowThrowOnError?: boolean): Promise<boolean>;

async getLastSync(): Promise<Date> {
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
if (userId == null) {
return null;
}
Expand Down
5 changes: 2 additions & 3 deletions libs/common/src/platform/sync/default-sync.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom } from "rxjs";
import { firstValueFrom, map } from "rxjs";

import {
CollectionService,
Expand Down Expand Up @@ -34,7 +34,6 @@ import { InternalMasterPasswordServiceAbstraction } from "../../auth/abstraction
import { TokenService } from "../../auth/abstractions/token.service";
import { AuthenticationStatus } from "../../auth/enums/authentication-status";
import { ForceSetPasswordReason } from "../../auth/models/domain/force-set-password-reason";
import { getUserId } from "../../auth/services/account.service";
import { DomainSettingsService } from "../../autofill/services/domain-settings.service";
import { BillingAccountProfileStateService } from "../../billing/abstractions";
import { DomainsResponse } from "../../models/response/domains.response";
Expand Down Expand Up @@ -108,7 +107,7 @@ export class DefaultSyncService extends CoreSyncService {

@sequentialize(() => "fullSync")
override async fullSync(forceSync: boolean, allowThrowOnError = false): Promise<boolean> {
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
this.syncStarted();
const authStatus = await firstValueFrom(this.authService.authStatusFor$(userId));
if (authStatus === AuthenticationStatus.LoggedOut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#btn
type="button"
role="tab"
class="tw-h-6 tw-w-6 tw-p-0 tw-flex tw-items-center tw-justify-center tw-border-2 tw-border-solid tw-rounded-full tw-transition tw-bg-transparent tw-border-transparent focus-visible:tw-outline-none focus-visible:tw-border-primary-600"
class="tw-size-6 tw-p-0 tw-flex tw-items-center tw-justify-center tw-border-2 tw-border-solid tw-rounded-full tw-transition tw-bg-transparent tw-border-transparent focus-visible:tw-outline-none focus-visible:tw-border-primary-600"
[ngClass]="dynamicClasses"
[attr.aria-selected]="isActive"
[attr.tabindex]="isActive ? 0 : -1"
Expand Down

0 comments on commit ed5291a

Please sign in to comment.