mirror of https://github.com/coder/coder.git
22 lines
449 B
TypeScript
22 lines
449 B
TypeScript
import { FC } from "react"
|
|
import { Navigate } from "react-router-dom"
|
|
|
|
export interface RequirePermissionProps {
|
|
children: JSX.Element
|
|
isFeatureVisible: boolean
|
|
}
|
|
|
|
/**
|
|
* Wraps routes that are available based on RBAC or licensing.
|
|
*/
|
|
export const RequirePermission: FC<RequirePermissionProps> = ({
|
|
children,
|
|
isFeatureVisible,
|
|
}) => {
|
|
if (!isFeatureVisible) {
|
|
return <Navigate to="/workspaces" />
|
|
} else {
|
|
return children
|
|
}
|
|
}
|