Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add simple wrapper
  • Loading branch information
presleyp committed Aug 24, 2022
commit 49f56529aa6096f5f30d0aaecfd9fb05df49c052
18 changes: 18 additions & 0 deletions site/src/components/RequirePermission/RequirePermission.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { FC } from "react"
import { Navigate } from "react-router"

export interface RequirePermissionProps {
children: JSX.Element
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would PropsWithChildren help here? reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using it here and got a TS error, not sure why!

Copy link
Contributor

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
}
}