fix: gate org inventory UI and fetch on can_view_org_inventory (ISSUE-163)#166
Merged
Conversation
…-163) - Add canViewOrgInventory memo (view|edit|admin implies view access) - Skip getOrgInventory fetch when permissions loading or user lacks can_view_org_inventory — no 403 surfaced - Revert to personal mode silently after permissions resolve without view access - Use permissionsFetchedForOrgId ref to avoid premature revert before fetch completes - Remove misleading "no permission to add" info alert; showAddButton already gates the add action
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the inventory page to gate organization inventory loading and UI behavior on resolved organization inventory permissions, avoiding unnecessary 403 errors for users without view access.
Changes:
- Adds
canViewOrgInventorybased on view/edit/admin permission hierarchy. - Skips organization inventory fetches while permissions are loading or view access is absent.
- Reverts back to personal inventory after permissions resolve without org inventory view access and removes the no-add-permission info alert.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…view-only org behavior
…gsLoaded - Add allOrgOptions (unfiltered) for the share dialog so members can share to any org they belong to, regardless of inventory view perms - orgOptions (view-filtered) remains the source for the View selector only - Add orgsLoaded ref; validation effect now only runs after fetchOrganizations completes, preventing premature reset of a valid sessionStorage org selection
6 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.
Summary
canViewOrgInventorymemo that correctly reflects the permission hierarchy (can_viewORcan_editORcan_adminall imply view access)GET /api/orgs/:orgId/inventoryentirely when permissions are still loading or the user lackscan_view_org_inventory— no 403 errors are surfacedpermissionsFetchedForOrgIdref to ensure the revert only fires after a real fetch completes, not on initial render before the fetch has startedshowAddButtonalready hides the add control for users without edit/admin accessTest plan
can_view_org_inventory: false— selecting the org in the View dropdown should immediately return to "My Inventory" with no error banner and no inventory API call firedcan_view_org_inventory: trueandcan_edit_org_inventory: false— org inventory loads and displays, but no Add button visiblecan_edit_org_inventory: true— full org inventory with Add button visible and functionalGET /api/orgs/:orgId/inventoryis not called when user lacks view permission (check Network tab)Closes #163