1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-12720] - sort organizations in vault item owner select (#13419)

* sort owner select options and filters by name

* don't sort filters

* fix tests

* fix tests

* set organizations in ngOninit

* move assignment up

* Revert change to add-edit.component.ts. Move assignment up.

* fix tests
This commit is contained in:
Jordan Aasen
2025-02-24 13:53:02 -08:00
committed by GitHub
parent c8b3e4c6dc
commit 8552578fbb
3 changed files with 40 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ import { OrganizationUserType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import {
@@ -74,6 +75,8 @@ export class ItemDetailsSectionComponent implements OnInit {
/** The email address associated with the active account */
protected userEmail$ = this.accountService.activeAccount$.pipe(map((account) => account.email));
protected organizations: Organization[] = [];
@Input({ required: true })
config: CipherFormConfig;
@@ -90,10 +93,6 @@ export class ItemDetailsSectionComponent implements OnInit {
return this.config.mode === "partial-edit";
}
get organizations(): Organization[] {
return this.config.organizations;
}
get allowPersonalOwnership() {
return this.config.allowPersonalOwnership;
}
@@ -186,6 +185,10 @@ export class ItemDetailsSectionComponent implements OnInit {
}
async ngOnInit() {
this.organizations = this.config.organizations.sort(
Utils.getSortFunction(this.i18nService, "name"),
);
if (!this.allowPersonalOwnership && this.organizations.length === 0) {
throw new Error("No organizations available for ownership.");
}