We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aced91f commit 49f5652Copy full SHA for 49f5652
site/src/components/RequirePermission/RequirePermission.tsx
@@ -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