1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

[PS-1843] Sort organizations in buildOrganizations (#4015)

* Sort organizations in buildOrganizations

* Add sort by name to Organization Switcher
This commit is contained in:
Justin Baur
2022-11-08 21:56:27 -05:00
committed by GitHub
parent 88de7d2b47
commit d6a6dedbba
2 changed files with 11 additions and 4 deletions

View File

@@ -1,11 +1,12 @@
import { Component, Input, OnInit } from "@angular/core"; import { Component, Input, OnInit } from "@angular/core";
import { Observable } from "rxjs"; import { map, Observable } from "rxjs";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { import {
canAccessAdmin, canAccessAdmin,
OrganizationService, OrganizationService,
} from "@bitwarden/common/abstractions/organization/organization.service.abstraction"; } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { Utils } from "@bitwarden/common/misc/utils";
import { Organization } from "@bitwarden/common/models/domain/organization"; import { Organization } from "@bitwarden/common/models/domain/organization";
@Component({ @Component({
@@ -22,7 +23,8 @@ export class OrganizationSwitcherComponent implements OnInit {
async ngOnInit() { async ngOnInit() {
this.organizations$ = this.organizationService.organizations$.pipe( this.organizations$ = this.organizationService.organizations$.pipe(
canAccessAdmin(this.i18nService) canAccessAdmin(this.i18nService),
map((orgs) => orgs.sort(Utils.getSortFunction(this.i18nService, "name")))
); );
this.loaded = true; this.loaded = true;

View File

@@ -37,8 +37,13 @@ export class VaultFilterService {
return new Set(await this.stateService.getCollapsedGroupings()); return new Set(await this.stateService.getCollapsedGroupings());
} }
buildOrganizations(): Promise<Organization[]> { async buildOrganizations(): Promise<Organization[]> {
return this.organizationService.getAll(); let organizations = await this.organizationService.getAll();
if (organizations != null) {
organizations = organizations.sort((a, b) => a.name.localeCompare(b.name));
}
return organizations;
} }
buildNestedFolders(organizationId?: string): Observable<DynamicTreeNode<FolderView>> { buildNestedFolders(organizationId?: string): Observable<DynamicTreeNode<FolderView>> {