2021-07-23 20:01:47 +02:00
|
|
|
import { Component } from "@angular/core";
|
2021-07-21 11:32:27 +02:00
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { ProviderService } from "@bitwarden/common/abstractions/provider.service";
|
|
|
|
import { Provider } from "@bitwarden/common/models/domain/provider";
|
2021-07-21 11:32:27 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "providers-layout",
|
|
|
|
templateUrl: "providers-layout.component.html",
|
|
|
|
})
|
2022-08-26 18:09:28 +02:00
|
|
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
2021-07-21 11:32:27 +02:00
|
|
|
export class ProvidersLayoutComponent {
|
|
|
|
provider: Provider;
|
|
|
|
private providerId: string;
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-12-14 17:10:26 +01:00
|
|
|
constructor(private route: ActivatedRoute, private providerService: ProviderService) {}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-21 11:32:27 +02:00
|
|
|
ngOnInit() {
|
|
|
|
document.body.classList.remove("layout_frontend");
|
2022-08-26 18:09:28 +02:00
|
|
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
|
2021-07-21 11:32:27 +02:00
|
|
|
this.route.params.subscribe(async (params) => {
|
|
|
|
this.providerId = params.providerId;
|
|
|
|
await this.load();
|
|
|
|
});
|
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-21 11:32:27 +02:00
|
|
|
async load() {
|
2021-12-14 17:10:26 +01:00
|
|
|
this.provider = await this.providerService.get(this.providerId);
|
2021-07-21 11:32:27 +02:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-21 11:32:27 +02:00
|
|
|
get showMenuBar() {
|
2021-07-23 20:01:47 +02:00
|
|
|
return this.showManageTab || this.showSettingsTab;
|
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-23 20:01:47 +02:00
|
|
|
get showManageTab() {
|
|
|
|
return this.provider.canManageUsers || this.provider.canAccessEventLogs;
|
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-23 20:01:47 +02:00
|
|
|
get showSettingsTab() {
|
|
|
|
return this.provider.isProviderAdmin;
|
2021-07-21 11:32:27 +02:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
|
2021-07-21 11:32:27 +02:00
|
|
|
get manageRoute(): string {
|
|
|
|
switch (true) {
|
|
|
|
case this.provider.canManageUsers:
|
|
|
|
return "manage/people";
|
|
|
|
case this.provider.canAccessEventLogs:
|
|
|
|
return "manage/events";
|
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2021-07-21 11:32:27 +02:00
|
|
|
}
|