1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00
Files
browser/apps/web/src/app/organizations/layouts/organization-layout.component.ts
Shane Melton 4b57d28e28 [EC-646] Org Admin Vault Refresh November Release Prep (#3913)
* [EC-646] Remove links from Manage component

These links are no longer necessary as they are now located in the new OAVR tabs.

* [EC-646] Re-introduce the canAccessManageTab helper

* [EC-646] Re-introduce /manage route in Organization routing module

- Add the parent /manage route
- Add child routes for collections, people, and groups

* [EC-646] Adjust Org admin tabs

Re-introduce the Manage tab and remove Groups and Members tabs.

* [EC-646] Change Members title back to People

* [EC-646] Move missing billing components

Some billing components were in the org settings module and needed to be moved the org billing module

* [EC-646] Fix import file upload button

-Update to use click event handler and tailwind class to hide input. Avoids inline styles/js blocked by CSP

- Fix broken async pipe

* [EC-646] Fix groups and people page overflow

Remove the container and page-content wrapper as the pages are no longer on their own tab

* [EC-646] Change People to Members

Change the text regarding managing members from People to Members to more closely follow changes coming later in the OAVR. Also update the URL to use /manage/members

* [EC-646] Cherry-pick ae39afe to fix tab text color

* [EC-646] Fix org routing permissions helpers

- Add canAccessVaultTab helper
- Update canAccessOrgAdmin include check for vault tab access
- Simplify canManageCollections

* [EC-646] Fix Manage tab conditional logic

- Add *ngIf condition for rendering Manage tab
- Re-introduce dynamic route for Manage tab
2022-10-28 08:53:27 -07:00

96 lines
2.7 KiB
TypeScript

import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { map, mergeMap, Observable, Subject, takeUntil } from "rxjs";
import {
canAccessBillingTab,
canAccessGroupsTab,
canAccessManageTab,
canAccessMembersTab,
canAccessReportingTab,
canAccessSettingsTab,
getOrganizationById,
OrganizationService,
} from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
import { Organization } from "@bitwarden/common/models/domain/organization";
@Component({
selector: "app-organization-layout",
templateUrl: "organization-layout.component.html",
})
export class OrganizationLayoutComponent implements OnInit, OnDestroy {
organization$: Observable<Organization>;
private _destroy = new Subject<void>();
constructor(private route: ActivatedRoute, private organizationService: OrganizationService) {}
ngOnInit() {
document.body.classList.remove("layout_frontend");
this.organization$ = this.route.params
.pipe(takeUntil(this._destroy))
.pipe<string>(map((p) => p.organizationId))
.pipe(
mergeMap((id) => {
return this.organizationService.organizations$
.pipe(takeUntil(this._destroy))
.pipe(getOrganizationById(id));
})
);
}
ngOnDestroy() {
this._destroy.next();
this._destroy.complete();
}
canShowSettingsTab(organization: Organization): boolean {
return canAccessSettingsTab(organization);
}
canShowManageTab(organization: Organization): boolean {
return canAccessManageTab(organization);
}
canShowMembersTab(organization: Organization): boolean {
return canAccessMembersTab(organization);
}
canShowGroupsTab(organization: Organization): boolean {
return canAccessGroupsTab(organization);
}
canShowReportsTab(organization: Organization): boolean {
return canAccessReportingTab(organization);
}
canShowBillingTab(organization: Organization): boolean {
return canAccessBillingTab(organization);
}
getReportTabLabel(organization: Organization): string {
return organization.useEvents ? "reporting" : "reports";
}
getReportRoute(organization: Organization): string {
return organization.useEvents ? "reporting/events" : "reporting/reports";
}
getManageRoute(organization: Organization): string {
let route: string;
switch (true) {
case organization.canManageUsers:
route = "manage/members";
break;
case organization.canViewAssignedCollections || organization.canViewAllCollections:
route = "manage/collections";
break;
case organization.canManageGroups:
route = "manage/groups";
break;
}
return route;
}
}