diff --git a/src/components/CustomListEditor.tsx b/src/components/CustomListEditor.tsx index 03be0f33fc..1d60a48fe4 100644 --- a/src/components/CustomListEditor.tsx +++ b/src/components/CustomListEditor.tsx @@ -2,12 +2,7 @@ import * as React from "react"; import { Button, Panel } from "library-simplified-reusable-components"; import { CollectionData } from "@thepalaceproject/web-opds-client/lib/interfaces"; -import { - AdvancedSearchQuery, - LanguagesData, - LibraryData, - CollectionData as AdminCollectionData, -} from "../interfaces"; +import { AdvancedSearchQuery, LanguagesData, LibraryData } from "../interfaces"; import { CustomListEditorProperties, @@ -24,7 +19,6 @@ import ShareIcon from "./icons/ShareIcon"; export type CustomListEditorProps = { autoUpdateStatus?: string; - collections?: AdminCollectionData[]; entries?: CustomListEditorEntriesData; entryPoints?: string[]; isAutoUpdateEnabled?: boolean; @@ -56,7 +50,6 @@ export type CustomListEditorProps = { save: () => void; search: () => void; share?: () => Promise; - toggleCollection?: (id: number) => void; updateProperty?: (name: string, value) => void; updateSearchParam?: (name: string, value) => void; addAdvSearchQuery?: (builderName: string, query: AdvancedSearchQuery) => void; @@ -77,7 +70,6 @@ export type CustomListEditorProps = { export default function CustomListEditor({ autoUpdateStatus, - collections, entries, entryPoints, isAutoUpdateEnabled, @@ -109,7 +101,6 @@ export default function CustomListEditor({ save, search, share, - toggleCollection, updateProperty, updateSearchParam, addAdvSearchQuery, @@ -119,7 +110,7 @@ export default function CustomListEditor({ removeAdvSearchQuery, selectAdvSearchQuery, }: CustomListEditorProps) { - const { collections: listCollections, name } = properties; + const { name } = properties; // Automatically execute the search when the list being edited changes, or finishes loading // (which means a stored query may have been loaded). @@ -234,36 +225,6 @@ export default function CustomListEditor({ /> )} - {collections?.length > 0 && ( -
- -
- Automatically add new books from these collections to this - list: -
- - {collections.map(({ id, name }) => ( - toggleCollection?.(parseInt(id))} - /> - ))} -
- } - /> - - )} - { let save; let search; let share; - let toggleCollection; let loadMoreSearchResults; let loadMoreEntries; let updateProperty; @@ -35,27 +34,6 @@ describe("CustomListEditor", () => { navigationLinks: [], }; - const collections = [ - { - id: 1, - name: "collection 1", - protocol: "protocol", - libraries: [{ short_name: "library" }], - }, - { - id: 2, - name: "collection 2", - protocol: "protocol", - libraries: [{ short_name: "library" }], - }, - { - id: 3, - name: "collection 3", - protocol: "protocol", - libraries: [{ short_name: "library" }], - }, - ]; - const entries = { baseline: [], baselineTotalCount: 0, @@ -118,7 +96,6 @@ describe("CustomListEditor", () => { search = stub(); share = stub(); - toggleCollection = stub(); updateProperty = stub(); updateSearchParam = stub(); @@ -146,7 +123,6 @@ describe("CustomListEditor", () => { wrapper = mount( { save={save} search={search} share={share} - toggleCollection={toggleCollection} updateProperty={updateProperty} updateSearchParam={updateSearchParam} />, @@ -269,38 +244,6 @@ describe("CustomListEditor", () => { expect(entriesEditor.props().opdsFeedUrl).to.equal(undefined); }); - it("shows collections", () => { - const collectionsPanel = wrapper.find("#add-from-collections-panel"); - const inputs = collectionsPanel.find(EditableInput); - - expect(inputs.length).to.equal(3); - - expect(inputs.at(0).props().label).to.equal("collection 1"); - expect(inputs.at(0).props().value).to.equal(1); - expect(inputs.at(0).props().checked).to.equal(false); - - expect(inputs.at(1).props().label).to.equal("collection 2"); - expect(inputs.at(1).props().value).to.equal(2); - expect(inputs.at(1).props().checked).to.equal(true); - - expect(inputs.at(2).props().label).to.equal("collection 3"); - expect(inputs.at(2).props().value).to.equal(3); - expect(inputs.at(2).props().checked).to.equal(false); - }); - - it("disables collection inputs when isOwner is false", () => { - wrapper.setProps({ - isOwner: false, - }); - - const collectionsPanel = wrapper.find("#add-from-collections-panel"); - const inputs = collectionsPanel.find(EditableInput); - - expect(inputs.at(0).prop("disabled")).to.equal(true); - expect(inputs.at(1).prop("disabled")).to.equal(true); - expect(inputs.at(2).prop("disabled")).to.equal(true); - }); - it("disables entry point options when isOwner is false", () => { wrapper.setProps({ isOwner: false, @@ -316,17 +259,17 @@ describe("CustomListEditor", () => { it("shows entry point options", () => { const inputs = wrapper.find(EditableInput); - expect(inputs.at(3).props().label).to.equal("All"); - expect(inputs.at(3).props().value).to.equal("All"); - expect(inputs.at(3).props().checked).to.equal(true); + expect(inputs.at(0).props().label).to.equal("All"); + expect(inputs.at(0).props().value).to.equal("All"); + expect(inputs.at(0).props().checked).to.equal(true); - expect(inputs.at(4).props().label).to.equal("Book"); - expect(inputs.at(4).props().value).to.equal("Book"); - expect(inputs.at(4).props().checked).to.equal(false); + expect(inputs.at(1).props().label).to.equal("Book"); + expect(inputs.at(1).props().value).to.equal("Book"); + expect(inputs.at(1).props().checked).to.equal(false); - expect(inputs.at(5).props().label).to.equal("Audio"); - expect(inputs.at(5).props().value).to.equal("Audio"); - expect(inputs.at(5).props().checked).to.equal(false); + expect(inputs.at(2).props().label).to.equal("Audio"); + expect(inputs.at(2).props().value).to.equal("Audio"); + expect(inputs.at(2).props().checked).to.equal(false); }); it("enables the save button when the list has changes and is valid", () => { @@ -398,15 +341,6 @@ describe("CustomListEditor", () => { expect(buttonContainer.length).to.equal(0); }); - it("calls toggleCollection when a collection checkbox is changed", () => { - const inputs = wrapper.find(".collections input"); - - inputs.at(1).simulate("change"); - - expect(toggleCollection.callCount).to.equal(1); - expect(toggleCollection.args[0]).to.deep.equal([2]); - }); - it("renders a CustomListSearch component", () => { wrapper.setProps({ startingTitle: "Begin the Begin" });