SM-585: Add ability to do table sort for service account list (#4943)

This commit is contained in:
Colton Hurst 2023-03-06 15:40:47 -05:00 committed by GitHub
parent fbd0d41b51
commit 75965e6408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -17,7 +17,7 @@
</button>
</sm-no-items>
<bit-table *ngIf="serviceAccounts?.length >= 1">
<bit-table *ngIf="serviceAccounts?.length >= 1" [dataSource]="dataSource">
<ng-container header>
<tr>
<th bitCell class="tw-w-0">
@ -31,9 +31,9 @@
{{ "all" | i18n }}
</label>
</th>
<th bitCell colspan="2">{{ "name" | i18n }}</th>
<th bitCell colspan="2" bitSortable="name" default>{{ "name" | i18n }}</th>
<th bitCell>{{ "secrets" | i18n }}</th>
<th bitCell>{{ "lastEdited" | i18n }}</th>
<th bitCell bitSortable="revisionDate">{{ "lastEdited" | i18n }}</th>
<th bitCell class="tw-w-0">
<button
type="button"
@ -46,8 +46,8 @@
</th>
</tr>
</ng-container>
<ng-template body>
<tr bitRow *ngFor="let serviceAccount of serviceAccounts">
<ng-template body let-rows$>
<tr bitRow *ngFor="let serviceAccount of rows$ | async">
<td bitCell>
<input
type="checkbox"

View File

@ -2,6 +2,8 @@ import { SelectionModel } from "@angular/cdk/collections";
import { Component, EventEmitter, Input, OnDestroy, Output } from "@angular/core";
import { Subject, takeUntil } from "rxjs";
import { TableDataSource } from "@bitwarden/components";
import { ServiceAccountView } from "../models/view/service-account.view";
@Component({
@ -9,6 +11,8 @@ import { ServiceAccountView } from "../models/view/service-account.view";
templateUrl: "./service-accounts-list.component.html",
})
export class ServiceAccountsListComponent implements OnDestroy {
protected dataSource = new TableDataSource<ServiceAccountView>();
@Input()
get serviceAccounts(): ServiceAccountView[] {
return this._serviceAccounts;
@ -16,6 +20,7 @@ export class ServiceAccountsListComponent implements OnDestroy {
set serviceAccounts(serviceAccounts: ServiceAccountView[]) {
this.selection.clear();
this._serviceAccounts = serviceAccounts;
this.dataSource.data = serviceAccounts;
}
private _serviceAccounts: ServiceAccountView[];