2022-01-12 16:01:54 +00:00
|
|
|
import { lazy } from "react";
|
2022-08-19 18:05:09 +00:00
|
|
|
import { generatePath } from "react-router-dom";
|
|
|
|
import type { Path } from "react-router-dom-v5-compat";
|
|
|
|
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-03-14 10:17:16 +00:00
|
|
|
path: "/:realm/clients/:id/authorization/permission/new/:permissionType/:selectedId?",
|
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-08-16 13:08:44 +00:00
|
|
|
legacy: true,
|
2022-01-12 16:01:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const toNewPermission = (
|
|
|
|
params: NewPermissionParams
|
2022-08-19 18:05:09 +00:00
|
|
|
): Partial<Path> => ({
|
2022-01-12 16:01:54 +00:00
|
|
|
pathname: generatePath(NewPermissionRoute.path, params),
|
|
|
|
});
|