1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 10:43:35 +00:00
Files
browser/bitwarden_license/bit-web/src/app/admin-console/providers/providers-routing.module.ts
Addison Beck 72355d26e1 Restructure the provider-permissions guard to be Angular 17+ compliant (#9609)
* Document the `provider-permissions` guard in code

* Restructure the `provider-permissions` guard to be Angular 17+ compliant
2024-07-02 10:35:51 -05:00

178 lines
5.3 KiB
TypeScript

import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { AuthGuard } from "@bitwarden/angular/auth/guards";
import { AnonLayoutWrapperComponent } from "@bitwarden/auth/angular";
import { Provider } from "@bitwarden/common/admin-console/models/domain/provider";
import { ProvidersComponent } from "@bitwarden/web-vault/app/admin-console/providers/providers.component";
import { FrontendLayoutComponent } from "@bitwarden/web-vault/app/layouts/frontend-layout.component";
import { UserLayoutComponent } from "@bitwarden/web-vault/app/layouts/user-layout.component";
import {
ManageClientsComponent,
ProviderSubscriptionComponent,
hasConsolidatedBilling,
ProviderBillingHistoryComponent,
} from "../../billing/providers";
import { ClientsComponent } from "./clients/clients.component";
import { CreateOrganizationComponent } from "./clients/create-organization.component";
import { providerPermissionsGuard } from "./guards/provider-permissions.guard";
import { AcceptProviderComponent } from "./manage/accept-provider.component";
import { EventsComponent } from "./manage/events.component";
import { PeopleComponent } from "./manage/people.component";
import { ProvidersLayoutComponent } from "./providers-layout.component";
import { AccountComponent } from "./settings/account.component";
import { SetupProviderComponent } from "./setup/setup-provider.component";
import { SetupComponent } from "./setup/setup.component";
const routes: Routes = [
{
path: "",
canActivate: [AuthGuard],
component: UserLayoutComponent,
children: [
{
path: "",
canActivate: [AuthGuard],
component: ProvidersComponent,
data: { titleId: "providers" },
},
],
},
{
path: "",
component: FrontendLayoutComponent,
children: [
{
path: "setup-provider",
component: SetupProviderComponent,
data: { titleId: "setupProvider" },
},
],
},
{
path: "",
component: AnonLayoutWrapperComponent,
children: [
{
path: "accept-provider",
component: AcceptProviderComponent,
data: {
pageTitle: "joinProvider",
titleId: "acceptProvider",
},
},
],
},
{
path: "",
canActivate: [AuthGuard],
children: [
{
path: "setup",
component: SetupComponent,
},
{
path: ":providerId",
component: ProvidersLayoutComponent,
canActivate: [providerPermissionsGuard()],
children: [
{ path: "", pathMatch: "full", redirectTo: "clients" },
{ path: "clients/create", component: CreateOrganizationComponent },
{ path: "clients", component: ClientsComponent, data: { titleId: "clients" } },
{
path: "manage-client-organizations",
canActivate: [hasConsolidatedBilling],
component: ManageClientsComponent,
data: { titleId: "clients" },
},
{
path: "manage",
children: [
{
path: "",
pathMatch: "full",
redirectTo: "people",
},
{
path: "people",
component: PeopleComponent,
canActivate: [
providerPermissionsGuard((provider: Provider) => provider.canManageUsers),
],
data: {
titleId: "people",
},
},
{
path: "events",
component: EventsComponent,
canActivate: [
providerPermissionsGuard((provider: Provider) => provider.canAccessEventLogs),
],
data: {
titleId: "eventLogs",
},
},
],
},
{
path: "billing",
canActivate: [hasConsolidatedBilling],
children: [
{
path: "",
pathMatch: "full",
redirectTo: "subscription",
},
{
path: "subscription",
component: ProviderSubscriptionComponent,
canActivate: [providerPermissionsGuard()],
data: {
titleId: "subscription",
},
},
{
path: "history",
component: ProviderBillingHistoryComponent,
canActivate: [providerPermissionsGuard()],
data: {
titleId: "billingHistory",
},
},
],
},
{
path: "settings",
children: [
{
path: "",
pathMatch: "full",
redirectTo: "account",
},
{
path: "account",
component: AccountComponent,
canActivate: [
providerPermissionsGuard((provider: Provider) => provider.isProviderAdmin),
],
data: {
titleId: "myProvider",
},
},
],
},
],
},
],
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ProvidersRoutingModule {}