Repository navigation
[UI] Integrate Sistent PermissionProvider and migrate Navigator permissions - #20590
Conversation
Signed-off-by: Rishi Raj <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: Rishi Raj <[email protected]>
banana-three-join
left a comment
There was a problem hiding this comment.
Are there any caveats to switching from SessionStorage to the JS Heap for handling the storage of the current org? I know hard refreshes and tab duplication will clear it, but those are fine as far as I'm concerned. Are there any SSR-specific gotchas we should look out for with this change?
Signed-off-by: Rishi Raj <[email protected]>
Signed-off-by: Rishi Raj <[email protected]>
|
There's actually no switch from sessionStorage to JS heap for the org itself; useGetSelectedOrganization() derives from RTK Query hooks (useGetUserPrefQuery + useGetOrgsQuery), which fetch from the server and live in the Redux store cache. The org selection was already server-backed. The userContext here is only used for display inside the PermissionShield tooltip (shows "User: X, Org: Y, Roles: Z" when a user lacks permission). It's purely cosmetic; no authorization logic depends on it. On SSR: _app.tsx runs client-side only (Next.js custom App), and both RTK Query hooks skip on the server (no window/sessionStorage access). The useMemo will just produce undefined/empty values during SSR, and the PermissionProvider handles that gracefully; sistent's usePermissionUserContext() returns undefined when no context is available, and the tooltip section is conditionally rendered (userContext && (userContext.userName || userContext.orgName)). So no SSR gotchas. |
|
Reviewed and tested locally on branch
Walked the diff in all 3 changed files:
Ran the app locally against a dev backend — nav renders correctly with no permission-related console errors. Overall: solid, well-scoped refactor. |
Thanks @Maanvi212006 !!! |
|
Commit SHA: END-TO-END TESTS
📦 Test Result Summary
⌛ Duration: 4 minutes and 9 seconds Overall Result: 👍 All tests passed. [Show/Hide] Test Result Details
🔗 Relationship Tests [Show/Hide] Relationship Test Details (18 tests)
|
Description
This PR integrates the generic, CASL-agnostic
PermissionProviderintroduced in layer5io/sistent#1704 into the Meshery UI workspace. It acts as the primary integration and mockup implementation verifying the new permissions flow.By wrapping the application in
PermissionProviderand supplying Sistent-compatible adapters, we decouple direct CASL queries from the layout layers and migrate the side navigation menu.Key Changes
<PermissionProvider>at the root layout wrapper.userHasPermissioncallback adapter to delegate permission checks to the existing CASLabilityinstance.permissionUserContextutilizing logged-in user profile attributes and selected organization states.{ action, subject }properties with declarativepermissionKeyidentifiers on connections, credentials, workspaces, designs, and other navigation endpoints.CANcheck on sub-items with Sistent's new layout properties (permissionKey={permission}andpermissionAction="showShield").This aligns with the Sistent implementation changes and verifies the declarative permissions mockup.
Actions
Hide
showShield or Nothing is passed
Signed commits