Skip to content

Resolve permission constants dynamically from schemas - #20354

Merged
leecalcote merged 16 commits into
meshery:masterfrom
rishiraj38:refactor/dynamic-permission-constants
Jul 8, 2026
Merged

leecalcote merged 16 commits into
meshery:masterfrom
rishiraj38:refactor/dynamic-permission-constants

Conversation

@rishiraj38

@rishiraj38 rishiraj38 commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR completes the migration of the permission constants architecture. It removes the legacy compatibility layer (ui/utils/permission_constants.ts) entirely, migrating components to import and resolve all permission UUIDs (actions) and human-readable function names (subjects) directly from the @meshery/schemas package at runtime.

This eliminates hardcoded UUIDs, subject strings, and the legacy bridging layer from the UI repository, establishing @meshery/schemas as the single source of truth for permission details.

What is changing?

  • Full Key Migration: Replaced all occurrences of legacy SCREAMING_SNAKE_CASE keys (such as keys.SHARE_DESIGN) with their canonical schema-aligned PascalCase names (such as Keys.CatalogManagementShareDesign) across all 86 frontend source files (pages, components, and tests).
  • Removal of Compatibility Layer: Deleted the legacy ui/utils/permission_constants.ts file completely and resolved all components to import Keys directly from @meshery/schemas/permissions.
  • Cleanup of Deprecated Tests: Removed the deprecated vitest test suite ui/utils/__tests__/permission_constants.test.ts since the legacy mapping file was deleted.
  • Action Map Standardization: Cleaned up internal spaces-switcher action keys inside MainViewsContent.tsx (VIEW_ACTIONS) and MainDesignsContent.tsx (DESIGN_ACTIONS) to follow a consistent SCREAMING_SNAKE_CASE naming convention (DELETE_VIEW, EXPORT_DESIGN, SHARE_DESIGN), resolving mixed casing styles.

Fixes #20402

Signed commits

  • Yes, I signed my commits.

Copilot AI review requested due to automatic review settings June 29, 2026 14:24
@rishiraj38
rishiraj38 marked this pull request as draft June 29, 2026 14:24
@github-actions github-actions Bot added the component/ui User Interface label Jun 29, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors permission_constants.ts to dynamically resolve permission details from @meshery/schemas instead of using hardcoded UUIDs, bridging legacy SCREAMING_SNAKE_CASE keys with PascalCase definitions. Feedback includes correcting a copy-paste mapping error for UNINSTALL_EXTENSION and improving TypeScript type safety by avoiding the use of any in the accumulator of the reduce function.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved

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

This PR refactors the UI permission constants layer to resolve permission action UUIDs and subject strings dynamically from @meshery/schemas, replacing the previous large block of hardcoded permission metadata while aiming to preserve legacy SCREAMING_SNAKE_CASE exports.

Changes:

  • Imports PermissionDetails from @meshery/schemas/permissions and builds legacy aliases at runtime.
  • Adds a legacy-to-schema key mapping (legacyToPascal) to bridge SCREAMING_SNAKE_CASE to schema-aligned PascalCase names.
  • Exports a combined keys object intended to support both schema keys and legacy keys (currently introduces conflicts/duplication concerns).

Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved
@rishiraj38
rishiraj38 marked this pull request as ready for review July 1, 2026 17:33
Copilot AI review requested due to automatic review settings July 1, 2026 17:33

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 3 out of 4 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • ui/package-lock.json: Generated file

Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved
@rishiraj38 rishiraj38 added the pr/do-not-merge PRs not ready to be merged label Jul 1, 2026
Copilot AI review requested due to automatic review settings July 1, 2026 19:07

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 3 out of 4 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • ui/package-lock.json: Generated file

Comment thread ui/utils/permission_constants.ts Resolved
Comment thread ui/utils/permission_constants.ts Resolved

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 3 out of 4 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • ui/package-lock.json: Generated file

Comment thread ui/utils/permission_constants.ts Resolved
Copilot AI review requested due to automatic review settings July 1, 2026 19:23

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 3 out of 4 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • ui/package-lock.json: Generated file

Comment thread ui/utils/permission_constants.ts Resolved
@rishiraj38 rishiraj38 removed the pr/do-not-merge PRs not ready to be merged label Jul 1, 2026
Copilot AI review requested due to automatic review settings July 5, 2026 17:43

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 87 out of 87 changed files in this pull request and generated no new comments.

@rishiraj38

rishiraj38 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@aabidsofi19 , please take another look at the PR when you get a chance. I've updated it.

There isn't a wrapper anymore. The file now just re-exports the generated permission keys and types from @meshery/schemas/permissions. I was thinking of keeping it this way because, in the future, we can also add the permission metadata helpers in the same file, so everything related to permission keys can be imported from a single place.

Copilot AI review requested due to automatic review settings July 6, 2026 19:22
@rishiraj38

rishiraj38 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Hardcoded Permission UUIDs vs. permissions.csv

As requested, I audited the hardcoded permission UUIDs defined in permission_constants.ts on the master branch against schemas/build/permissions.csv, treating the spreadsheet as the source of truth.

Executive Summary

  • Total hardcoded permission keys: 107
  • Verified against permissions.csv: 101
  • Outdated UUID mappings updated: 6
  • Unused permission constants removed: 15

Updated Permission UUID Mappings

The following permission constants were using hardcoded UUIDs in the previous implementation. During the audit, these UUIDs were found to no longer exist in the current permissions.csv. They have been updated to use the canonical permission definitions imported from @meshery/schemas.

  • VIEW_VIEWS

    • Old hardcoded UUID: 4b3117e6-176c-4d9b-8e09-4278d2f48280
    • Current Schema Permission: KanvasViewViews
    • Current UUID: 93cba7f8-82ec-4a64-b384-f81d6acc8db3
  • CREATE_VIEW

    • Old hardcoded UUID: a7392c29-34af-4ee9-af1c-71e83876a8aa
    • Current Schema Permission: KanvasCreateView
    • Current UUID: 47ba32dc-aaa3-4c75-afdd-07fb40f38f4f
  • DELETE_VIEW

    • Old hardcoded UUID: b2b9c027-0f39-4a26-b3ed-5b30aaf82060
    • Current Schema Permission: KanvasDeleteView
    • Current UUID: 48076416-bc07-456b-bbea-49bdca239d0f
  • EDIT_VIEW

    • Old hardcoded UUID: f2e04b59-42ee-4af6-b488-7bc7047fc01b
    • Current Schema Permission: KanvasEditView
    • Current UUID: 2f8354bb-6855-4a42-8086-8d55c1c7e638
  • ASSIGN_VIEWS_TO_WORKSPACE

    • Old hardcoded UUID: 5a26b21b-bf15-4622-9681-d907fc5154fd
    • Current Schema Permission: KanvasAssignViewsToWorkspace
    • Current UUID: fb6c987b-e54c-4016-b3f3-0488228ee998
  • REMOVE_VIEWS_FROM_WORKSPACE

    • Old hardcoded UUID: 5b48eded-15d8-4c51-9ac4-b11097dbdd75
    • Current Schema Permission: KanvasUnassignViewsFromWorkspace
    • Current UUID: f77d74ef-1cae-4527-b45e-ecc1431681df

Note

These outdated hardcoded UUIDs have been replaced with the canonical permission definitions from @meshery/schemas, ensuring the UI remains aligned with the current permission registry defined in permissions.csv.


Verified Permission Mappings

The remaining 101 permission constants were verified against permissions.csv and already matched the UUIDs defined in Schemas.

Examples include:

  • ADD_CLUSTER → LifecycleManagementAddCluster
  • CREATE_WORKSPACE → WorkspaceManagementCreateWorkspace
  • DELETE_WORKSPACE → WorkspaceManagementDeleteWorkspace
  • EDIT_WORKSPACE → WorkspaceManagementEditWorkspace
  • DEPLOY_DESIGN → CatalogManagementDeployDesign

Summary

This migration:

  • Removes 15 unused permission constants that were no longer referenced.
  • Updates 6 outdated permission UUID mappings to match the canonical definitions in Schemas.
  • Preserves the remaining 101 permission mappings that were already aligned with permissions.csv.

Following this change, the UI imports permission keys directly from @meshery/schemas, eliminating duplicated UUID definitions and ensuring the UI remains aligned with the canonical permission registry.

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 88 out of 88 changed files in this pull request and generated 2 comments.

@rishiraj38
rishiraj38 force-pushed the refactor/dynamic-permission-constants branch from 1c5d7e1 to b6df4c9 Compare July 6, 2026 19:31
Copilot AI review requested due to automatic review settings July 8, 2026 12:45

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 88 out of 88 changed files in this pull request and generated 3 comments.

Comment thread ui/pages/extensions.tsx Resolved
Copilot AI review requested due to automatic review settings July 8, 2026 13:24
@rishiraj38
rishiraj38 force-pushed the refactor/dynamic-permission-constants branch from 8ee755e to 3fac11f Compare July 8, 2026 13:25

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 88 out of 88 changed files in this pull request and generated 1 comment.

Comment thread ui/pages/extensions.tsx Resolved
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Commit SHA: 3fac11f47c73c3b9bba94a17e3060b7543ecde17

END-TO-END TESTS

  • Testing started at: July 8th 2026, 1:50:21 pm

📦 Test Result Summary

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

⌛ Duration: 6 minutes and 26 seconds

Overall Result: 👎 Some tests failed.

[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 ✅

❌ Failed Test Details

The following tests failed. Click on each to see the failure reason:

❌ Performance dashboard controls (Local - chromium-local-provider)

File Location: /home/runner/work/meshery/meshery/ui/tests/e2e/performance.spec.ts

Error Message:

Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

Locator: getByTestId('performance-dashboard')
Expected: visible
Timeout: 60000ms
Error: element(s) not found

Call log:
�[2m  - Expect "toBeVisible" with timeout 60000ms�[22m
�[2m  - waiting for getByTestId('performance-dashboard')�[22m

Code Snippet:

�[0m �[90m 19 |�[39m     �[90m// wait - a longer timeout does not fix it. The real fix is a reactive�[39m
 �[90m 20 |�[39m     �[90m// permission gate, tracked in #20504.�[39m
�[31m�[1m>�[22m�[39m�[90m 21 |�[39m     �[36mawait�[39m expect(page�[33m.�[39mgetByTestId(�[32m'performance-dashboard'�[39m))�[33m.�[39mtoBeVisible()�[33m;�[39m
 �[90m    |�[39m                                                             �[31m�[1m^�[22m�[39m
 �[90m 22 |�[39m   })�[33m;�[39m
 �[90m 23 |�[39m
 �[90m 24 |�[39m   �[90m// Global chrome (navigation, notification, profile, header) is covered by the�[39m�[0m
❌ Charts (Grafana) page loads (Local - chromium-local-provider)

File Location: Not Found

Error Message:

�[31mTest timeout of 180000ms exceeded.�[39m

🔗 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 ✅

@rishiraj38
rishiraj38 dismissed stale reviews from saurabhraghuvanshii, aabidsofi19, and NSTKrishna July 8, 2026 22:15

Feedback incoporated.

@leecalcote
leecalcote merged commit 578d5ed into meshery:master Jul 8, 2026
10 of 11 checks passed
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.

[Refactor] Dynamically resolve UI permission constants from schemas

7 participants