Files
siftlode/frontend/src/components/PlexMenu.tsx
T
peter dae0b80f6a feat(plex): add a movie or show to a collection from its card menu
"Add to collection…" opens a panel beside the card: the title's library's
manual collections tick it in or out, and a name + Enter creates a new one with
the title in it. It used to take the Collections page, a new collection, its
name and a title search, then another search per title. A lean endpoint lists
the collections with whether each holds the title. Admin only, as on the
title's page.

Also: a collection seeded with a show is made as a show collection (Plex type
2). Measured: as a movie one it came out empty and refused the show after.
2026-10-08 03:09:55 +02:00

37 lines
1.3 KiB
TypeScript

import { useTranslation } from "react-i18next";
import { type PlexCard } from "../lib/api";
import { type ActionMenuItem } from "./ui/ActionMenu";
import { ContextMenu } from "./ui/ContextMenu";
import { type ContextMenuController } from "./ui/useContextMenu";
import { type PlexCardActions } from "./usePlexCardActions";
/** A Plex poster list's one menu: every trigger — right-click, long-press, Shift+F10 and each card's
* "…" — opens it with the title's whole action list (`usePlexCardActions`, held by the list because
* its cards' hover "add" opens the same dialog). Render ONE per list, outside the cards. */
export function PlexMenu({
menu,
actions,
pin = true,
extra,
}: {
menu: ContextMenuController<PlexCard>;
actions: PlexCardActions;
/** False for a list of episodes: an episode is not a comfort-shelf kind. */
pin?: boolean;
/** The host list's own rows for a title, after the shared ones (a collection's "Remove"). */
extra?: (c: PlexCard) => ActionMenuItem[];
}) {
const { t } = useTranslation();
const c = menu.target;
return (
<>
<ContextMenu
menu={menu}
ariaLabel={t("plex.menu")}
items={c ? [...actions.items(c, { pin, anchor: menu.anchor }), ...(extra?.(c) ?? [])] : []}
/>
{actions.panel}
</>
);
}