Add permision check for tables & analytics #2097
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a UI-level permission gate for the Tables route and reflects the same permission in the side navigation, aligning Tables access with the existing permission-based menu patterns.
Changes:
- Redirects away from
/tableswhen the user lacksPermission.WRITE_TABLE. - Locks the Tables side-menu link when the user lacks
Permission.WRITE_TABLE.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/react-ui/src/app/routes/openops-tables/index.tsx | Adds an authorization check to block rendering the Tables iframe page for unauthorized users. |
| packages/react-ui/src/app/features/navigation/lib/menu-links-hook.ts | Locks the Tables menu item based on the same permission check. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| if (!checkAccess(Permission.WRITE_ANALYTICS)) { | ||
| return <Navigate to="/" replace />; | ||
| } |
There was a problem hiding this comment.
I know it's already used in multiple places, but maybe we can extract this
export const useCheckAccessAndRedirect = (permission: Permission) => {
const { checkAccess } = useAuthorization();
const navigate = useNavigate();
useEffect(() => {
if (!checkAccess(permission)) {
navigate('/', { replace: true });
}
}, [checkAccess, permission, navigate]);
};
There was a problem hiding this comment.
will add a small refactor in a separate PR
|



Fixes OPS-3683, OPS-3875