Disable Import Mixed Content checkbox once a root folder has assigned authors - #149
Open
jordanfelle wants to merge 1 commit into
Open
jordanfelle wants to merge 1 commit into
jordanfelle wants to merge 1 commit into
Conversation
… authors RootFolderController.UpdateRootFolder already fail-closes any type change (other than widening to Mixed) once an author's AudiobookRootFolderPath or EbookRootFolderPath matches the folder's path - intentional, given the history of author-path bugs in this area (Chaptarr#106, Chaptarr#112, Chaptarr#115, Chaptarr#88, Chaptarr#63, Chaptarr#28). But the Edit Root Folder modal never surfaces that constraint: the "Import Mixed Content?" checkbox stays enabled regardless, so unchecking it and saving on a populated root folder always fails with a 500 that never makes it to the user as a real validation message. Fixes Chaptarr#148. - RootFolderResource gains a HasAssignedAuthors bool, computed the same way the existing UpdateRootFolder guard does and threaded through the existing ToResource(...) overloads (extracted into a shared AnyAuthorAssignedToPath helper so both call sites agree). - GetResourceById and GetRootFolders both populate it. - EditRootFolderModalContent disables the checkbox and swaps in a new ImportMixedContentLockedHelpText explaining the fix (remove + re-add the root folder) once an existing root folder has any assigned authors. Added two RootFolderControllerTypeChangeFixture cases for the new field (present given a matching author, absent given an unrelated one). All 58 RootFolder-scoped backend tests pass; frontend lint/typecheck/build and the missing-translation-key check are clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KuNYz45Ldj4BkMEdhg5UM5
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.
Fixes #148.
Description
RootFolderController.UpdateRootFolderalready fail-closes any root-foldertype change (other than widening to
Mixed) once an author'sAudiobookRootFolderPathorEbookRootFolderPathmatches the folder's path— intentional, given the history of author-path bugs in this area (#106,
#112, #115, #88, #63, #28), and covered by the existing
RootFolderControllerTypeChangeFixturetests, which I left untouched.The bug is that the Edit Root Folder modal never surfaces that constraint.
The "Import Mixed Content?" checkbox stays enabled regardless of whether the
folder has assigned authors, so unchecking it and saving on any populated
root folder is guaranteed to fail — but only with a raw 500 that the UI
shows as a generic "An error occurred while saving the root folder" banner,
with the real, actually-helpful message (which correctly tells you to
remove and re-add the folder) buried in the network tab.
What changed
RootFolderResourcegains aHasAssignedAuthorsbool, computed the sameway
UpdateRootFolder's own guard does. I pulled that check out into ashared
AnyAuthorAssignedToPathhelper so both call sites can't drift.GetResourceByIdandGetRootFoldersboth populate the new field.EditRootFolderModalContentdisables the "Import Mixed Content?" checkboxand shows a new
ImportMixedContentLockedHelpTextstring explaining thefix (remove + re-add the root folder) whenever an existing root folder
(not a brand-new one being created) has any assigned authors.
How this was tested
dotnet test src/Chaptarr.Core.Test/Chaptarr.Core.Test.csproj --filter FullyQualifiedName~RootFolder— 58/58 passing, including two new cases added toRootFolderControllerTypeChangeFixtureforHasAssignedAuthors(present given a matching author's path, absent given an unrelated one).dotnet buildonChaptarr.Api.V1— clean.yarn linton the changed frontend file — clean (had to pull the help-text logic into a small method instead of a nested ternary to satisfyno-nested-ternary).npx tsc -p frontend/tsconfig.json— clean.node frontend/build/check-missing-translation-keys.js— clean, new key resolves.yarn build(full production webpack build) — succeeds.chaptarr/chaptarrdevelop build) to confirm the exact failure mode this fixes, before writing the patch.I don't have a way to click through the actual modal in a browser from where I'm working, so I'd appreciate a sanity check on the disabled-checkbox rendering, but the underlying field plumbing and behavior are test-covered.
A note on AI: this PR (issue #148 too) was written by Claude Code working
through a Chaptarr setup/migration task on the user's behalf. Root-caused by
reading the actual controller/test source rather than guessing, and every
claim above was verified by actually running it (builds, the existing +
new test suite, lint, typecheck, the translation-key checker, and a full
production build) rather than assumed.