mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-26 12:25:20 +01:00
[AC-1658] Update list command to show only organizations where the user is a member (#9453)
* Refactor list organizations command to use organizationService.memberOrganizations$ * Deprecate OrganizationService.getAll method and update CLI get command to use the organizations observable
This commit is contained in:
parent
2333059885
commit
f85b7b314c
@ -468,7 +468,7 @@ export class GetCommand extends DownloadCommand {
|
||||
if (Utils.isGuid(id)) {
|
||||
org = await this.organizationService.getFromState(id);
|
||||
} else if (id.trim() !== "") {
|
||||
let orgs = await this.organizationService.getAll();
|
||||
let orgs = await firstValueFrom(this.organizationService.organizations$);
|
||||
orgs = CliUtils.searchOrganizations(orgs, id);
|
||||
if (orgs.length > 1) {
|
||||
return Response.multipleResults(orgs.map((c) => c.id));
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
@ -239,7 +241,7 @@ export class ListCommand {
|
||||
}
|
||||
|
||||
private async listOrganizations(options: Options) {
|
||||
let organizations = await this.organizationService.getAll();
|
||||
let organizations = await firstValueFrom(this.organizationService.memberOrganizations$);
|
||||
|
||||
if (options.search != null && options.search.trim() !== "") {
|
||||
organizations = CliUtils.searchOrganizations(organizations, options.search);
|
||||
|
@ -117,6 +117,9 @@ export abstract class OrganizationService {
|
||||
hasOrganizations: () => Promise<boolean>;
|
||||
get$: (id: string) => Observable<Organization | undefined>;
|
||||
get: (id: string) => Promise<Organization>;
|
||||
/**
|
||||
* @deprecated This method is only used in key connector and will be removed soon as part of https://bitwarden.atlassian.net/browse/AC-2252.
|
||||
*/
|
||||
getAll: (userId?: string) => Promise<Organization[]>;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user