fix(libraries): prevent adding documents to read-only libraries#845
Merged
thostetler merged 3 commits intoadsabs:masterfrom Apr 15, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #845 +/- ##
========================================
+ Coverage 62.5% 62.9% +0.5%
========================================
Files 317 323 +6
Lines 36576 37917 +1341
Branches 1673 1731 +58
========================================
+ Hits 22830 23830 +1000
- Misses 13706 14047 +341
Partials 40 40
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the “Add to Library” flow so read-only libraries can’t be selected/modified, and aligns UI + mocks + tests with the expected 403 behavior.
Changes:
- Disable read-only libraries in the Add to Library modal (UI affordances +
aria-disabled) and show thepermissioncolumn for clarity. - Fix async behavior by switching to
mutateAsyncso batch operations actually await API results before showing success. - Update MSW handlers and add modal tests covering read-only selection and 403 error handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/mocks/handlers/libraries.ts |
Return 403 when attempting add/remove docs on permission === 'read' libraries. |
src/components/Libraries/AddToLibraryModal.tsx |
Use mutateAsync; compute/read-only IDs; pass disabledIds; show permission column. |
src/components/Libraries/LibraryListTable.tsx |
Add disabledIds prop and apply row-level disabling semantics/styling. |
src/components/Libraries/__tests__/AddToLibraryModal.test.tsx |
Add tests for read-only disabling and 403 behavior. |
- Read-only libraries are now visually disabled in the AddToLibraryModal table and cannot be selected - Switch from mutate to mutateAsync so Promise.all correctly waits for the API response; previously it resolved immediately (void), always triggering the success banner regardless of the 403 response - Mock handler returns 403 for any add/remove attempt on a read-only library - Add tests covering selection guard and the regression case
- Remove unconditional inline style from Tr that overrode conditional backgroundColor/color props, causing disabled rows to appear highlighted - Fix malformed aria-label template string on selectable Checkbox - Replace flaky setTimeout in test with waitFor on submit button loading state
314c5ea to
7029529
Compare
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.
aria-disabled) in the Add to Library modal and cannot be selected — closes SCIX-864mutate→mutateAsyncsoPromise.allactually awaits the API call; previouslymutatereturnedvoid, causingPromise.allto resolve immediately and always show the success banner regardless of the 403 responsepermission === 'read'permissioncolumn is now visible in the modal table so users can see why some rows are disableddisabledIdsprop toLibraryListTablefor general-purpose row disabling