Skip to content

Commit 49f5652

Browse files
committed
Add simple wrapper
1 parent aced91f commit 49f5652

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { FC } from "react"
2+
import { Navigate } from "react-router"
3+
4+
export interface RequirePermissionProps {
5+
children: JSX.Element
6+
isFeatureVisible: boolean
7+
}
8+
9+
/**
10+
* Wraps routes that are available based on RBAC or licensing.
11+
*/
12+
export const RequirePermission: FC<RequirePermissionProps> = ({ children, isFeatureVisible }) => {
13+
if (!isFeatureVisible) {
14+
return <Navigate to="/workspaces" />
15+
} else {
16+
return children
17+
}
18+
}

0 commit comments

Comments
 (0)