v4: playlists have categories of their own — a set apart from the dumps', which admins manage on /manage under "Playlist categories", next to "Dump categories". Each category now has a kind, dump or playlist, its slug and name unique within its kind only; migration 0025 rebuilds categories with the column, every existing one becoming a dump category with its dumps, and adds playlist_categories. A playlist's owner files it under any of them in the create and edit forms, and it shows them as chips on its card and its page, each leading to /playlists/<slug>.
/playlists is the new page of every public playlist, newest first (GET /api/playlists), and /playlists/<slug> a playlist category's, with a menu of the categories, linked from the user menu as "All playlists"; `playlists` is reserved as a dump category's slug, and one that had it is renamed. A profile's Playlists tab narrows to a playlist category with the same menu as its Dumps tab (?category=), and so do the Dumps and Playlists tabs of /search, each with its own kind (category and playlistCategory for GET /api/search), another tab dropping it. The category service takes the kind throughout, so a dump can't be filed under a playlist category nor the other way round, and categoryJoin is the one filter join the dump, follow and playlist services share. useCategories(kind) gives one kind's set from the one fetch, CategoryChips replaces the chips the dump card and page each drew, useCategoryFilter keeps a list to its category as the socket brings more, and useCategorySelection holds a form's picked categories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,11 @@ describe("CategorySelect", () => {
|
||||
const onToggle = vi.fn();
|
||||
const user = userEvent.setup();
|
||||
renderWithContexts(
|
||||
<CategorySelect selected={new Set(["c2"])} onToggle={onToggle} />,
|
||||
<CategorySelect
|
||||
kind="dump"
|
||||
selected={new Set(["c2"])}
|
||||
onToggle={onToggle}
|
||||
/>,
|
||||
{
|
||||
categories,
|
||||
},
|
||||
@@ -35,7 +39,7 @@ describe("CategorySelect", () => {
|
||||
|
||||
test("nothing without categories", () => {
|
||||
renderWithContexts(
|
||||
<CategorySelect selected={new Set()} onToggle={() => {}} />,
|
||||
<CategorySelect kind="dump" selected={new Set()} onToggle={() => {}} />,
|
||||
);
|
||||
expect(screen.queryByText("Categories")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ const categories: Category[] = [
|
||||
|
||||
describe("CategorySwitcher", () => {
|
||||
test("hidden with no categories", () => {
|
||||
renderWithContexts(<CategorySwitcher onSelect={() => {}} />);
|
||||
renderWithContexts(<CategorySwitcher kind="dump" onSelect={() => {}} />);
|
||||
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ describe("CategorySwitcher", () => {
|
||||
const user = userEvent.setup();
|
||||
const onSelect = vi.fn();
|
||||
renderWithContexts(
|
||||
<CategorySwitcher categorySlug="music" onSelect={onSelect} />,
|
||||
<CategorySwitcher kind="dump" categorySlug="music" onSelect={onSelect} />,
|
||||
{ categories },
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: "Music" }));
|
||||
@@ -38,7 +38,7 @@ describe("CategorySwitcher", () => {
|
||||
const user = userEvent.setup();
|
||||
const onSelect = vi.fn();
|
||||
renderWithContexts(
|
||||
<CategorySwitcher categorySlug="gone" onSelect={onSelect} />,
|
||||
<CategorySwitcher kind="dump" categorySlug="gone" onSelect={onSelect} />,
|
||||
{ categories },
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: "gone" }));
|
||||
@@ -48,7 +48,7 @@ describe("CategorySwitcher", () => {
|
||||
|
||||
test("Escape closes the menu", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithContexts(<CategorySwitcher onSelect={() => {}} />, {
|
||||
renderWithContexts(<CategorySwitcher kind="dump" onSelect={() => {}} />, {
|
||||
categories,
|
||||
});
|
||||
await user.click(screen.getByRole("button", { name: "All" }));
|
||||
|
||||
Reference in New Issue
Block a user