Fix editProhibited flag not being set for Tokens Studio sync provider with read-only access #3629
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Tokens Studio sync provider was not properly setting the
editProhibitedflag, allowing users with read-only access to attempt write operations in the UI. While these operations would eventually fail at the backend level, the UI should prevent these attempts upfront by correctly identifying and respecting user permissions.Solution
This PR implements permission checking for the Tokens Studio provider, following the same pattern used by other sync providers (ADO, GitHub, GitLab, Bitbucket).
Changes Made
1. Added
canWrite()method toTokensStudioTokenStoragefalsefor 'viewer' or 'read-only' rolestrueif role information is unavailable (backward compatible)false(safe default)2. Enhanced GraphQL query
currentUserRolefield toGET_PROJECT_DATA_QUERY3. Updated sync operations
checkAndSetAccess()callback inuseTokensStudiohookpullTokensFromTokensStudio()andsyncTokensWithTokensStudio()editProhibitedflag based on write permissionsExample Flow
Backward Compatibility
The implementation is fully backward compatible:
currentUserRole, the method assumes write access (existing behavior)Testing
Fixes the issue where users with read-only access could see edit UI elements that would fail on save.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.