mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[EC-859] update billing routes for owners of Managed orgs (#4611)
* [EC-859] update billing routes for owners of Managed orgs * [EC-859] fix observable in billing tab * [EC-859] update observable name * [EC-859] update reporting and settings observables * [EC-859] add startsWith to reporting observable * [EC-859] async pipe once in settings * [EC-859] create get$ in org service * [EC-859] transition remaining components * [EC-859] add as org to template * [EC-859] add shareReplay to observable to prevent multicasting - future proof get$ on org service * [AC-859] fix missed org
This commit is contained in:
@@ -32,7 +32,7 @@ export function canAccessReportingTab(org: Organization): boolean {
|
||||
}
|
||||
|
||||
export function canAccessBillingTab(org: Organization): boolean {
|
||||
return org.canManageBilling;
|
||||
return org.isOwner;
|
||||
}
|
||||
|
||||
export function canAccessOrgAdmin(org: Organization): boolean {
|
||||
@@ -63,6 +63,7 @@ export function isNotProviderUser(org: Organization): boolean {
|
||||
export abstract class OrganizationService {
|
||||
organizations$: Observable<Organization[]>;
|
||||
|
||||
get$: (id: string) => Observable<Organization | undefined>;
|
||||
get: (id: string) => Organization;
|
||||
getByIdentifier: (identifier: string) => Organization;
|
||||
getAll: (userId?: string) => Promise<Organization[]>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BehaviorSubject, concatMap } from "rxjs";
|
||||
import { BehaviorSubject, concatMap, map, Observable } from "rxjs";
|
||||
|
||||
import { InternalOrganizationService as InternalOrganizationServiceAbstraction } from "../../abstractions/organization/organization.service.abstraction";
|
||||
import { StateService } from "../../abstractions/state.service";
|
||||
@@ -26,6 +26,10 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
get$(id: string): Observable<Organization | undefined> {
|
||||
return this.organizations$.pipe(map((orgs) => orgs.find((o) => o.id === id)));
|
||||
}
|
||||
|
||||
async getAll(userId?: string): Promise<Organization[]> {
|
||||
const organizationsMap = await this.stateService.getOrganizations({ userId: userId });
|
||||
return Object.values(organizationsMap || {}).map((o) => new Organization(o));
|
||||
|
||||
Reference in New Issue
Block a user