Review fixes for user authorization tab hiding (#3035)#3036
Open
ramonsmits wants to merge 9 commits into
Open
Conversation
Throughput is an admin resource server-side (ServiceControl bundles error:throughput: under the admin permission group, alongside licensing, notifications and redirects), so the top-nav Throughput item must gate on admin_read rather than failed_messages_read. This matches the existing 'Usage Setup' configuration tab, which already gates on admin_read.
The supportsUserPermissions flag was computed in EnvironmentAndVersionsStore but never consumed. Older ServiceControl versions do not expose the my/permissions endpoints, so without this guard the app would attempt to fetch permissions (and show the User Permissions tab) against an instance that returns 404. - App.vue only triggers permissionsStore.refresh() when the capability is present; the watch now also reacts to the flag becoming available. - ConfigurationView only renders the User Permissions tab when ServiceControl advertises the endpoints, in addition to auth being enabled.
App.vue's auth watch and the User Permissions view's onMounted both call refresh() on load, firing two identical pairs of requests. Share a single in-flight promise so concurrent callers reuse the same request; the slot is released once it settles, so later refreshes still re-fetch.
PageHeader and ConfigurationView each defined their own permission gate. The two predicates had drifted: PageHeader required authEnabled && isAuthenticated && summary, while ConfigurationView omitted isAuthenticated. Extract a single usePermissionGate composable exposing has(flag) so both views share identical, fail-open gating logic.
The permission endpoint paths were hardcoded in UserPermissionsStore even though ServiceControl advertises them (mypermissions_summary/mypermissions_all) in its root document. Expose those URLs from EnvironmentAndVersionsStore and fetch them through a new serviceControlClient.fetchTypedFromUrl() helper, so the frontend follows the server's routing instead of duplicating path knowledge.
The catch block discarded the underlying error, leaving no diagnostic trail when permissions fail to load. Log it via the shared logger (as the other stores do) while still surfacing the friendly message to the user.
Replace the bespoke .icon-granted/.icon-denied rules (hardcoded hex colours) with the standard Bootstrap utility classes already used elsewhere for granted/denied FAIcons (StatusIcon, EndpointInstances, ConnectionResultView).
Covers the gate's core contract: it fails open (shows everything) when authorization is disabled, when the user is unauthenticated, or while the summary is still loading; and gates per flag once enabled, authenticated and loaded. Also asserts it reacts to summary updates.
Covers: a successful refresh fetches the discovered root URLs and populates summary+descriptor; a failed request sets the friendly error and logs the cause; and concurrent refresh() calls share one in-flight request (two endpoint calls, not four) while still re-fetching once settled.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up fixes for:
Changes:
admin_read(server-side it is an admin resource, matching the Usage Setup tab).supportsUserPermissionsso permissions are only fetched and the tab only shown when ServiceControl exposes the endpoints.usePermissionGatecomposable so PageHeader and ConfigurationView use identical gating.text-success/text-dangerfor the permission icons.usePermissionGateandUserPermissionsStore.