mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +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:
@@ -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;
|
||||||
|
|||||||
@@ -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>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user