Skip to content

[UI] Integrate Sistent PermissionProvider and migrate Navigator permissions - #20590

Merged
rishiraj38 merged 5 commits into
meshery:masterfrom
rishiraj38:ui/integrate-sistent-permissions
Jul 15, 2026
Merged

rishiraj38 merged 5 commits into
meshery:masterfrom
rishiraj38:ui/integrate-sistent-permissions

Conversation

@rishiraj38

@rishiraj38 rishiraj38 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR integrates the generic, CASL-agnostic PermissionProvider introduced 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 PermissionProvider and supplying Sistent-compatible adapters, we decouple direct CASL queries from the layout layers and migrate the side navigation menu.

Key Changes

  • App Bootstrapping (_app.tsx):
    • Integrated Sistent's <PermissionProvider> at the root layout wrapper.
    • Supplied the userHasPermission callback adapter to delegate permission checks to the existing CASL ability instance.
    • Configured permissionUserContext utilizing logged-in user profile attributes and selected organization states.
  • Navigation Definitions (navigatorComponents.tsx):
    • Replaced the hardcoded CASL { action, subject } properties with declarative permissionKey identifiers on connections, credentials, workspaces, designs, and other navigation endpoints.
  • Navigation Component (Navigator.tsx):
    • Replaced inline CASL CAN check on sub-items with Sistent's new layout properties (permissionKey={permission} and permissionAction="showShield").

This aligns with the Sistent implementation changes and verifies the declarative permissions mockup.

Actions

Hide

Screenshot 2026-07-10 at 6 33 43 PM

showShield or Nothing is passed

Screenshot 2026-07-10 at 6 34 44 PM

Signed commits

  • Yes, I signed my commits.

Copilot AI review requested due to automatic review settings July 10, 2026 10:27
@rishiraj38
rishiraj38 marked this pull request as draft July 10, 2026 10:27
@github-actions github-actions Bot added the component/ui User Interface label Jul 10, 2026
gemini-code-assist[bot]

This comment was marked as outdated.

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Signed-off-by: Rishi Raj <[email protected]>

@banana-three-join banana-three-join left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@rishiraj38
rishiraj38 marked this pull request as ready for review July 14, 2026 15:13
Copilot AI review requested due to automatic review settings July 14, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread ui/pages/_app.tsx Resolved
Comment thread ui/pages/_app.tsx Resolved
@meshery meshery deleted a comment from gemini-code-assist Bot Jul 14, 2026
Copilot AI review requested due to automatic review settings July 14, 2026 15:30
@meshery meshery deleted a comment from gemini-code-assist Bot Jul 14, 2026
@meshery meshery deleted a comment from gemini-code-assist Bot Jul 14, 2026
@rishiraj38

rishiraj38 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@banana-three-join

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.

This comment was marked as resolved.

@Maanvi212006

Copy link
Copy Markdown
Contributor

Reviewed and tested locally on branch pr-20590:

  • Full unit suite: 375 files / 2509 tests passing, 0 regressions
  • navigatorComponents.test.tsx: 7/7 passing
  • tsc --noEmit: clean
  • eslint: 0 errors (1 pre-existing unused eslint-disable warning in _app.tsx line 153, unrelated/trivial — could be cleaned up in a follow-up)

Walked the diff in all 3 changed files:

  • _app.tsx: the userHasPermission adapter (ability.can(key.id, _.lowerCase(key.function))) exactly replicates the old CAN() helper's logic (confirmed in utils/can.ts), so this is behavior-preserving, not a functional change.
  • navigatorComponents.tsx: clean 1:1 mechanical migration from permission: {action, subject} to permissionKey: Keys.X across all 9 nav items — nothing missed or mismatched.
  • Navigator.tsx: confirmed via Sistent's type declarations that ListItemButton natively supports permissionKey/permissionAction="showShield" and handles disabling internally, so dropping the manual disabled={!CAN(...)} prop is safe, not a regression.

Ran the app locally against a dev backend — nav renders correctly with no permission-related console errors.

Overall: solid, well-scoped refactor.

@rishiraj38

Copy link
Copy Markdown
Contributor Author

Reviewed and tested locally on branch pr-20590:

  • Full unit suite: 375 files / 2509 tests passing, 0 regressions
  • navigatorComponents.test.tsx: 7/7 passing
  • tsc --noEmit: clean
  • eslint: 0 errors (1 pre-existing unused eslint-disable warning in _app.tsx line 153, unrelated/trivial — could be cleaned up in a follow-up)

Walked the diff in all 3 changed files:

  • _app.tsx: the userHasPermission adapter (ability.can(key.id, _.lowerCase(key.function))) exactly replicates the old CAN() helper's logic (confirmed in utils/can.ts), so this is behavior-preserving, not a functional change.
  • navigatorComponents.tsx: clean 1:1 mechanical migration from permission: {action, subject} to permissionKey: Keys.X across all 9 nav items — nothing missed or mismatched.
  • Navigator.tsx: confirmed via Sistent's type declarations that ListItemButton natively supports permissionKey/permissionAction="showShield" and handles disabling internally, so dropping the manual disabled={!CAN(...)} prop is safe, not a regression.

Ran the app locally against a dev backend — nav renders correctly with no permission-related console errors.

Overall: solid, well-scoped refactor.

Thanks @Maanvi212006 !!!

Copilot AI review requested due to automatic review settings July 15, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@rishiraj38
rishiraj38 merged commit bb78628 into meshery:master Jul 15, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Commit SHA: 0d8273fcc7fb44b46ffd89f19dbcefef24a3c55e

END-TO-END TESTS

  • Testing started at: July 15th 2026, 6:37:20 pm

📦 Test Result Summary

  • ✅ 63 passed
  • ❌ 0 failed
  • ⚠️ 0 flaked
  • ⏩ 7 skipped

⌛ Duration: 4 minutes and 9 seconds

Overall Result: 👍 All tests passed.

[Show/Hide] Test Result Details
Test Provider Browser Test Case Tags Result
1 Local chromium-local-provider Aggregation Charts are displayed ✅
2 Local chromium-local-provider alias resolution relationship ✅
3 Local chromium-local-provider alias resolution relationship ✅
4 Local chromium-local-provider alias resolution relationship ✅
5 Local chromium-local-provider alias resolution relationship ✅
6 Local chromium-local-provider alias resolution relationship ✅
7 Local chromium-local-provider alias resolution relationship ✅
8 Local chromium-local-provider alias resolution relationship ✅
9 Local chromium-local-provider alias resolution relationship ✅
10 Local chromium-local-provider alias resolution relationship ✅
11 Local chromium-local-provider Charts (Grafana) page loads ✅
12 Local chromium-local-provider config patching correctness relationship ✅
13 Local chromium-local-provider config patching correctness relationship ✅
14 Local chromium-local-provider config patching correctness relationship ✅
15 Local chromium-local-provider config patching correctness relationship ✅
16 Local chromium-local-provider config patching correctness relationship ✅
17 Local chromium-local-provider config patching correctness relationship ✅
18 Local chromium-local-provider config patching correctness relationship ✅
19 Local chromium-local-provider config patching correctness relationship ✅
20 Local chromium-local-provider config patching correctness relationship ✅
21 Local chromium-local-provider Configure Existing Istio adapter through Mesh Adapter URL from Management page unstable ⚠️
22 Local chromium-local-provider Connect to Meshery Istio Adapter and configure it ➖
23 Local chromium-local-provider Create a Model ✅
24 Local chromium-local-provider Delete Kubernetes cluster connections ➖
25 Local chromium-local-provider evaluation idempotency relationship ✅
26 Local chromium-local-provider evaluation idempotency relationship ✅
27 Local chromium-local-provider evaluation idempotency relationship ✅
28 Local chromium-local-provider evaluation idempotency relationship ✅
29 Local chromium-local-provider evaluation idempotency relationship ✅
30 Local chromium-local-provider evaluation idempotency relationship ✅
31 Local chromium-local-provider evaluation idempotency relationship ✅
32 Local chromium-local-provider evaluation idempotency relationship ✅
33 Local chromium-local-provider evaluation idempotency relationship ✅
34 Local chromium-local-provider Import a Model via CSV Import ✅
35 Local chromium-local-provider Import a Model via File Import ✅
36 Local chromium-local-provider Import a Model via Url Import ✅
37 Local chromium-local-provider Logout from current user session ✅
38 Local chromium-local-provider Metrics (Prometheus) page loads ✅
39 Local chromium-local-provider Performance dashboard controls ✅
40 Local chromium-local-provider Ping Istio Adapter unstable ⚠️
41 Local chromium-local-provider Search a Model and Export it ✅
42 Local chromium-local-provider should edit design in Design Configurator ✅
43 Local chromium-local-provider should identify relationships for All Relationships relationship ✅
44 Local chromium-local-provider should identify relationships for Container-Hierarchical-Parent-Alias-Relationship relationship ✅
45 Local chromium-local-provider should identify relationships for deployment-configmap-reference-relationship relationship ✅
46 Local chromium-local-provider should identify relationships for Hierarchical-Parent-Namespace-Relationship relationship ✅
47 Local chromium-local-provider should identify relationships for meshery-design relationship ✅
48 Local chromium-local-provider should identify relationships for pv-pvc-edge-non-binding-reference-relationship relationship ✅
49 Local chromium-local-provider should identify relationships for Service-To-Deployment-Network relationship ✅
50 Local chromium-local-provider should verify Design Configurator page elements ✅
51 Local chromium-local-provider structural integrity relationship ✅
52 Local chromium-local-provider structural integrity relationship ✅
53 Local chromium-local-provider structural integrity relationship ✅
54 Local chromium-local-provider structural integrity relationship ✅
55 Local chromium-local-provider structural integrity relationship ✅
56 Local chromium-local-provider structural integrity relationship ✅
57 Local chromium-local-provider structural integrity relationship ✅
58 Local chromium-local-provider structural integrity relationship ✅
59 Local chromium-local-provider structural integrity relationship ✅
60 Local chromium-local-provider Test if Left Navigation Panel is displayed ✅
61 Local chromium-local-provider Test if Notification button is displayed ✅
62 Local chromium-local-provider Test if Profile button is displayed ✅
63 Local chromium-local-provider Toggle "Send Anonymous Performance Results" ✅
64 Local chromium-local-provider Toggle "Send Anonymous Usage Statistics" ✅
65 Local chromium-local-provider Verify extension nav items use top-level layout ➖
66 Local chromium-local-provider Verify Meshery Adapter for Istio Section ➖
67 Local chromium-local-provider Verify Meshery Catalog Section Details ✅
68 Local chromium-local-provider Verify Meshery Design Embed Details ➖
69 Local chromium-local-provider Verify Meshery Docker Extension Details ➖
70 Local chromium-local-provider Verify Performance Analysis Details ➖
71 Local chromium-local-provider Verify that UI components are displayed ✅
72 Local local-setup authenticate as Local provider ✅

🔗 Relationship Tests

[Show/Hide] Relationship Test Details (18 tests)
Kind Type SubType From To Model Design Name Status
edge binding permission ClusterRole ServiceAccount kubernetes Understanding Relationships ❌
edge binding permission Role ServiceAccount kubernetes Understanding Relationships ❌
edge non-binding network Service Deployment kubernetes service-to-deployment-network ✅
edge non-binding network Service Deployment kubernetes meshery-design-fixture.json ✅
edge non-binding reference ClusterRoleBinding ClusterRole kubernetes meshery-design-fixture.json ❌
hierarchical parent alias Container Deployment kubernetes container-hierarchical-parent-alias-relationship ✅
hierarchical parent alias Container Deployment kubernetes deployment-configmap-reference-relationship ❌
hierarchical parent alias Container Deployment kubernetes service-to-deployment-network ✅
hierarchical parent alias Container Deployment kubernetes meshery-design-fixture.json ✅
hierarchical parent alias Container Deployment kubernetes Understanding Relationships ✅
hierarchical parent alias Container Pod kubernetes container-hierarchical-parent-alias-relationship ✅
hierarchical parent inventory * Namespace kubernetes hierarchical-parent-namespace-relationship ✅
hierarchical parent inventory * Namespace kubernetes service-to-deployment-network ✅
hierarchical parent inventory * Namespace kubernetes pv-pvc-edge-non-binding-reference-relationship ✅
hierarchical parent inventory * Namespace kubernetes Understanding Relationships ✅
hierarchical sibling matchlabels ClusterRole ClusterRole kubernetes meshery-design-fixture.json ✅
hierarchical sibling matchlabels Deployment Deployment kubernetes meshery-design-fixture.json ✅
hierarchical sibling matchlabels Service Service kubernetes meshery-design-fixture.json ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants