mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
sort organizations by name within product switcher (#8980)
This commit is contained in:
parent
89df0e4fad
commit
a4b3b83c46
@ -1,12 +1,13 @@
|
|||||||
import { Component, ViewChild } from "@angular/core";
|
import { Component, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, ParamMap, Router } from "@angular/router";
|
||||||
import { combineLatest, concatMap } from "rxjs";
|
import { combineLatest, concatMap, map } from "rxjs";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
canAccessOrgAdmin,
|
canAccessOrgAdmin,
|
||||||
OrganizationService,
|
OrganizationService,
|
||||||
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
|
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
|
||||||
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { MenuComponent } from "@bitwarden/components";
|
import { MenuComponent } from "@bitwarden/components";
|
||||||
|
|
||||||
type ProductSwitcherItem = {
|
type ProductSwitcherItem = {
|
||||||
@ -48,6 +49,13 @@ export class ProductSwitcherContentComponent {
|
|||||||
this.organizationService.organizations$,
|
this.organizationService.organizations$,
|
||||||
this.route.paramMap,
|
this.route.paramMap,
|
||||||
]).pipe(
|
]).pipe(
|
||||||
|
map(([orgs, paramMap]): [Organization[], ParamMap] => {
|
||||||
|
return [
|
||||||
|
// Sort orgs by name to match the order within the sidebar
|
||||||
|
orgs.sort((a, b) => a.name.localeCompare(b.name)),
|
||||||
|
paramMap,
|
||||||
|
];
|
||||||
|
}),
|
||||||
concatMap(async ([orgs, paramMap]) => {
|
concatMap(async ([orgs, paramMap]) => {
|
||||||
const routeOrg = orgs.find((o) => o.id === paramMap.get("organizationId"));
|
const routeOrg = orgs.find((o) => o.id === paramMap.get("organizationId"));
|
||||||
// If the active route org doesn't have access to SM, find the first org that does.
|
// If the active route org doesn't have access to SM, find the first org that does.
|
||||||
|
Loading…
Reference in New Issue
Block a user