mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
Compare commits
1 Commits
bug/ps-136
...
feature/ex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7fb394d28 |
@@ -17,8 +17,8 @@
|
||||
<li class="nav-item" routerLinkActive="active">
|
||||
<a class="nav-link" routerLink="/reports">{{ "reports" | i18n }}</a>
|
||||
</li>
|
||||
<li *ngIf="organizations.length >= 1" class="nav-item" routerLinkActive="active">
|
||||
<a class="nav-link" [routerLink]="['/organizations', organizations[0].id]">{{
|
||||
<li *ngIf="(organizations$ | async).length >= 1" class="nav-item" routerLinkActive="active">
|
||||
<a class="nav-link" [routerLink]="['/organizations', (organizations$ | async)[0].id]">{{
|
||||
"organizations" | i18n
|
||||
}}</a>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, NgZone, OnInit } from "@angular/core";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Observable, map } from "rxjs";
|
||||
|
||||
import { BroadcasterService } from "jslib-common/abstractions/broadcaster.service";
|
||||
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
||||
import { MessagingService } from "jslib-common/abstractions/messaging.service";
|
||||
import { OrganizationService } from "jslib-common/abstractions/organization.service";
|
||||
@@ -23,7 +23,7 @@ export class NavbarComponent implements OnInit {
|
||||
name: string;
|
||||
email: string;
|
||||
providers: Provider[] = [];
|
||||
organizations: Organization[] = [];
|
||||
organizations$ = new Observable<Organization[]>();
|
||||
|
||||
constructor(
|
||||
private messagingService: MessagingService,
|
||||
@@ -32,9 +32,7 @@ export class NavbarComponent implements OnInit {
|
||||
private providerService: ProviderService,
|
||||
private syncService: SyncService,
|
||||
private organizationService: OrganizationService,
|
||||
private i18nService: I18nService,
|
||||
private broadcasterService: BroadcasterService,
|
||||
private ngZone: NgZone
|
||||
private i18nService: I18nService
|
||||
) {
|
||||
this.selfHosted = this.platformUtilsService.isSelfHost();
|
||||
}
|
||||
@@ -52,26 +50,17 @@ export class NavbarComponent implements OnInit {
|
||||
}
|
||||
this.providers = await this.providerService.getAll();
|
||||
|
||||
this.organizations = await this.buildOrganizations();
|
||||
|
||||
this.broadcasterService.subscribe(this.constructor.name, async (message: any) => {
|
||||
this.ngZone.run(async () => {
|
||||
switch (message.command) {
|
||||
case "organizationCreated":
|
||||
if (this.organizations.length < 1) {
|
||||
this.organizations = await this.buildOrganizations();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.organizations$ = await this.buildOrganizations();
|
||||
}
|
||||
|
||||
async buildOrganizations() {
|
||||
const allOrgs = await this.organizationService.getAll();
|
||||
return allOrgs
|
||||
.filter((org) => OrgNavigationPermissionsService.canAccessAdmin(org))
|
||||
.sort(Utils.getSortFunction(this.i18nService, "name"));
|
||||
return this.organizations$.pipe(
|
||||
map((orgs) => {
|
||||
return orgs
|
||||
.filter((org) => OrgNavigationPermissionsService.canAccessAdmin(org))
|
||||
.sort(Utils.getSortFunction(this.i18nService, "name"));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
lock() {
|
||||
|
||||
@@ -300,7 +300,6 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
this.formPromise = doSubmit();
|
||||
const organizationId = await this.formPromise;
|
||||
this.onSuccess.emit({ organizationId: organizationId });
|
||||
this.messagingService.send("organizationCreated", organizationId);
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user