fix(plex): complete the 409->nameTaken sweep + cover PlexLibraryPicker

The notifyCollectionEditError helper localizes the backend's duplicate-name
409 to plex.collection.nameTaken; it was applied to the New-collection panel
but two sibling collection-write sites still routed 409 through
notifyActionError, surfacing the server's raw English detail under the HU UI:

- PlexCollectionView.doRename (rename collision)
- PlexCollectionEditor.createNew (create-in-editor duplicate name)

Both now use notifyCollectionEditError, matching the create path. Also adds a
direct dom test for the extracted PlexLibraryPicker covering the enabled gate,
emptyHint, results, honest error, and no-results branches.
This commit is contained in:
2026-08-23 18:39:22 +02:00
parent 81b7660232
commit 2d1a7ff374
3 changed files with 108 additions and 5 deletions
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { Check, Plus } from "lucide-react";
import { api } from "../lib/api";
import { notifyActionError } from "../lib/actionErrors";
import { notifyCollectionEditError } from "../lib/actionErrors";
import { useScrollFade } from "../lib/useScrollFade";
import Modal from "./Modal";
import { useConfirm } from "./ConfirmProvider";
@@ -102,8 +102,9 @@ export default function PlexCollectionEditor({
setMembers((prev) => new Set(prev).add(col.id));
refresh();
} catch (e) {
// Surfaces the 409 when the name duplicates an existing collection (Plex conflates same names).
notifyActionError(e, t("plex.collection.editFailed"));
// The backend rejects a duplicate name with 409 (Plex conflates same names) — localize it to
// nameTaken rather than surfacing the server's raw English detail.
notifyCollectionEditError(e, t("plex.collection.editFailed"), t("plex.collection.nameTaken"));
} finally {
setBusy(null);
}