2022-01-12 16:01:54 +00:00
|
|
|
import { lazy } from "react";
|
2022-08-19 18:05:09 +00:00
|
|
|
import type { Path } from "react-router-dom-v5-compat";
|
2022-08-22 14:29:35 +00:00
|
|
|
import { generatePath } from "react-router-dom-v5-compat";
|
2022-08-19 18:05:09 +00:00
|
|
|
import type { RouteDef } from "../../route-config";
|
2022-01-12 16:01:54 +00:00
|
|
|
|
|
|
|
export type PermissionType = "resource" | "scope";
|
|
|
|
|
|
|
|
export type NewPermissionParams = {
|
|
|
|
realm: string;
|
|
|
|
id: string;
|
|
|
|
permissionType: PermissionType;
|
2022-03-14 10:17:16 +00:00
|
|
|
selectedId?: string;
|
2022-01-12 16:01:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const NewPermissionRoute: RouteDef = {
|
2022-08-22 14:29:35 +00:00
|
|
|
path: "/:realm/clients/:id/authorization/permission/new/:permissionType",
|
2022-01-12 16:01:54 +00:00
|
|
|
component: lazy(() => import("../authorization/PermissionDetails")),
|
|
|
|
breadcrumb: (t) => t("clients:createPermission"),
|
2022-05-30 09:23:24 +00:00
|
|
|
access: "view-clients",
|
2022-01-12 16:01:54 +00:00
|
|
|
};
|
|
|
|
|
2022-08-22 14:29:35 +00:00
|
|
|
export const NewPermissionWithSelectedIdRoute: RouteDef = {
|
|
|
|
...NewPermissionRoute,
|
2022-10-11 09:31:05 +00:00
|
|
|
path: "/:realm/clients/:id/authorization/permission/new/:permissionType/:selectedId",
|
2022-08-22 14:29:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const toNewPermission = (params: NewPermissionParams): Partial<Path> => {
|
|
|
|
const path = params.selectedId
|
|
|
|
? NewPermissionWithSelectedIdRoute.path
|
|
|
|
: NewPermissionRoute.path;
|
|
|
|
|
|
|
|
return {
|
|
|
|
pathname: generatePath(path, params),
|
|
|
|
};
|
|
|
|
};
|