2022-08-25 23:20:31 +00:00
|
|
|
import { FC } from "react"
|
2023-08-02 18:28:16 +00:00
|
|
|
import { Navigate } from "react-router-dom"
|
2022-08-25 23:20:31 +00:00
|
|
|
|
|
|
|
export interface RequirePermissionProps {
|
|
|
|
children: JSX.Element
|
|
|
|
isFeatureVisible: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps routes that are available based on RBAC or licensing.
|
|
|
|
*/
|
2022-10-10 17:33:35 +00:00
|
|
|
export const RequirePermission: FC<RequirePermissionProps> = ({
|
|
|
|
children,
|
|
|
|
isFeatureVisible,
|
|
|
|
}) => {
|
2022-08-25 23:20:31 +00:00
|
|
|
if (!isFeatureVisible) {
|
|
|
|
return <Navigate to="/workspaces" />
|
|
|
|
} else {
|
|
|
|
return children
|
|
|
|
}
|
|
|
|
}
|