Skip to content

Disable Import Mixed Content checkbox once a root folder has assigned authors - #149

Open
jordanfelle wants to merge 1 commit into
Chaptarr:developfrom
jordanfelle:lock-mixed-root-folder-type-ui
Open

jordanfelle wants to merge 1 commit into
Chaptarr:developfrom
jordanfelle:lock-mixed-root-folder-type-ui

Conversation

@jordanfelle

Copy link
Copy Markdown

Fixes #148.

Description

RootFolderController.UpdateRootFolder already fail-closes any root-folder
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 (#106,
#112, #115, #88, #63, #28), and covered by the existing
RootFolderControllerTypeChangeFixture tests, 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

  • RootFolderResource gains a HasAssignedAuthors bool, computed the same
    way UpdateRootFolder's own guard does. I pulled that check out into a
    shared AnyAuthorAssignedToPath helper so both call sites can't drift.
  • GetResourceById and GetRootFolders both populate the new field.
  • EditRootFolderModalContent disables the "Import Mixed Content?" checkbox
    and shows a new ImportMixedContentLockedHelpText string explaining the
    fix (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 to RootFolderControllerTypeChangeFixture for HasAssignedAuthors (present given a matching author's path, absent given an unrelated one).
  • dotnet build on Chaptarr.Api.V1 — clean.
  • yarn lint on the changed frontend file — clean (had to pull the help-text logic into a small method instead of a nested ternary to satisfy no-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.
  • Reproduced the original bug against a live instance first (473-author library, chaptarr/chaptarr develop 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.

… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Import Mixed Content checkbox doesn't reflect that root folders with assigned authors can't change type

1 participant