From e7fc07d9dc969dbaf53f915454d7c3df5a9f73f6 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Thu, 18 Jan 2024 10:58:52 -0400 Subject: [PATCH] Remove search service components, since this is now configured server side, rather then through the UI. --- src/actions.ts | 29 ------- src/components/ConfigTabContainer.tsx | 2 - src/components/SearchServices.tsx | 81 ------------------- src/components/SelfTestsCategory.tsx | 8 +- src/components/SelfTestsTabContainer.tsx | 18 +---- src/components/TroubleshootingPage.tsx | 7 +- .../__tests__/ConfigTabContainer-test.tsx | 4 - .../__tests__/SelfTestsTabContainer-test.tsx | 19 +---- src/interfaces.ts | 6 -- src/reducers/index.ts | 4 - src/reducers/searchServices.ts | 10 --- 11 files changed, 11 insertions(+), 177 deletions(-) delete mode 100644 src/components/SearchServices.tsx delete mode 100644 src/reducers/searchServices.ts diff --git a/src/actions.ts b/src/actions.ts index 09f6c9df0..7c3e37f31 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -11,7 +11,6 @@ import { PatronAuthServicesData, SitewideSettingsData, MetadataServicesData, - SearchServicesData, DiscoveryServicesData, LibraryRegistrationsData, CustomListsData, @@ -86,9 +85,6 @@ export default class ActionCreator extends BaseActionCreator { static readonly METADATA_SERVICES = "METADATA_SERVICES"; static readonly EDIT_METADATA_SERVICE = "EDIT_METADATA_SERVICE"; static readonly DELETE_METADATA_SERVICE = "DELETE_METADATA_SERVICE"; - static readonly SEARCH_SERVICES = "SEARCH_SERVICES"; - static readonly EDIT_SEARCH_SERVICE = "EDIT_SEARCH_SERVICE"; - static readonly DELETE_SEARCH_SERVICE = "DELETE_SEARCH_SERVICE"; static readonly CATALOG_SERVICES = "CATALOG_SERVICES"; static readonly EDIT_CATALOG_SERVICE = "EDIT_CATALOG_SERVICE"; static readonly DELETE_CATALOG_SERVICE = "DELETE_CATALOG_SERVICE"; @@ -598,31 +594,6 @@ export default class ActionCreator extends BaseActionCreator { ).bind(this); } - fetchSearchServices() { - const url = "/admin/search_services"; - return this.fetchJSON( - ActionCreator.SEARCH_SERVICES, - url - ).bind(this); - } - - editSearchService(data: FormData) { - const url = "/admin/search_services"; - return this.postForm(ActionCreator.EDIT_SEARCH_SERVICE, url, data).bind( - this - ); - } - - deleteSearchService(identifier: string | number) { - const url = "/admin/search_service/" + identifier; - return this.postForm( - ActionCreator.DELETE_SEARCH_SERVICE, - url, - null, - "DELETE" - ).bind(this); - } - fetchCatalogServices() { const url = "/admin/catalog_services"; return this.fetchJSON( diff --git a/src/components/ConfigTabContainer.tsx b/src/components/ConfigTabContainer.tsx index edc25304b..d78a32227 100644 --- a/src/components/ConfigTabContainer.tsx +++ b/src/components/ConfigTabContainer.tsx @@ -7,7 +7,6 @@ import PatronAuthServices from "./PatronAuthServices"; import SitewideAnnouncements from "./SitewideAnnouncements"; import SitewideSettings from "./SitewideSettings"; import MetadataServices from "./MetadataServices"; -import SearchServices from "./SearchServices"; import CatalogServices from "./CatalogServices"; import DiscoveryServices from "./DiscoveryServices"; import { @@ -46,7 +45,6 @@ export default class ConfigTabContainer extends TabContainer< patronAuth: PatronAuthServices, sitewideSettings: SitewideSettings, metadata: MetadataServices, - search: SearchServices, catalogServices: CatalogServices, discovery: DiscoveryServices, sitewideAnnouncements: SitewideAnnouncements, diff --git a/src/components/SearchServices.tsx b/src/components/SearchServices.tsx deleted file mode 100644 index 0846c5dc0..000000000 --- a/src/components/SearchServices.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import * as React from "react"; -import EditableConfigList, { - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps, -} from "./EditableConfigList"; -import { connect } from "react-redux"; -import ActionCreator from "../actions"; -import { SearchServicesData, SearchServiceData } from "../interfaces"; -import ServiceEditForm from "./ServiceEditForm"; -import { Alert } from "react-bootstrap"; - -/** Right panel for search services on the system configuration page. - Shows a list of current search services and allows creating a new - service or editing or deleting an existing service. */ -export class SearchServices extends EditableConfigList< - SearchServicesData, - SearchServiceData -> { - EditForm = ServiceEditForm; - listDataKey = "search_services"; - itemTypeName = "search service"; - urlBase = "/admin/web/config/search/"; - identifierKey = "id"; - labelKey = "protocol"; - limitOne = true; - links = this.renderLinks(); - - renderLinks(): { [key: string]: JSX.Element } { - const linkBase = "/admin/web/troubleshooting/self-tests/searchServices"; - const linkElement = the troubleshooting page; - return { - info: ( - <>Self-tests for the search service have been moved to {linkElement}. - ), - footer: ( - <>Problems with your search service? Please visit {linkElement}. - ), - }; - } -} - -function mapStateToProps(state, ownProps) { - const data = Object.assign( - {}, - (state.editor.searchServices && state.editor.searchServices.data) || {} - ); - // fetchError = an error involving loading the list of search services; formError = an error upon - // submission of the create/edit form. - return { - data: data, - responseBody: - state.editor.searchServices && state.editor.searchServices.successMessage, - fetchError: state.editor.searchServices.fetchError, - formError: state.editor.searchServices.formError, - isFetching: - state.editor.searchServices.isFetching || - state.editor.searchServices.isEditing, - }; -} - -function mapDispatchToProps(dispatch, ownProps) { - const actions = new ActionCreator(null, ownProps.csrfToken); - return { - fetchData: () => dispatch(actions.fetchSearchServices()), - editItem: (data: FormData) => dispatch(actions.editSearchService(data)), - deleteItem: (identifier: string | number) => - dispatch(actions.deleteSearchService(identifier)), - }; -} - -const ConnectedSearchServices = connect< - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps ->( - mapStateToProps, - mapDispatchToProps -)(SearchServices); - -export default ConnectedSearchServices; diff --git a/src/components/SelfTestsCategory.tsx b/src/components/SelfTestsCategory.tsx index 122796ebc..72bed4c91 100644 --- a/src/components/SelfTestsCategory.tsx +++ b/src/components/SelfTestsCategory.tsx @@ -5,7 +5,6 @@ import SelfTests from "./SelfTests"; import { CollectionData, PatronAuthServiceData, - SearchServiceData, ServiceData, } from "../interfaces"; import { Panel } from "library-simplified-reusable-components"; @@ -14,17 +13,14 @@ export interface SelfTestsCategoryProps { type: string; linkName: string; csrfToken: string; - items: CollectionData[] | PatronAuthServiceData[] | SearchServiceData[]; + items: CollectionData[] | PatronAuthServiceData[]; store: Store; } export default class SelfTestsCategory extends React.Component< SelfTestsCategoryProps > { - handleUnnamed(): - | CollectionData[] - | PatronAuthServiceData[] - | SearchServiceData[] { + handleUnnamed(): CollectionData[] | PatronAuthServiceData[] { // It's possible for older systems to have services in which the name // property is null, which will block the page from loading. We check for // these services and assign them a placeholder name. diff --git a/src/components/SelfTestsTabContainer.tsx b/src/components/SelfTestsTabContainer.tsx index a5f3fdfb9..86eb395d8 100644 --- a/src/components/SelfTestsTabContainer.tsx +++ b/src/components/SelfTestsTabContainer.tsx @@ -4,11 +4,7 @@ import * as React from "react"; import { Store } from "redux"; import { connect } from "react-redux"; import ActionCreator from "../actions"; -import { - CollectionsData, - PatronAuthServicesData, - SearchServicesData, -} from "../interfaces"; +import { CollectionsData, PatronAuthServicesData } from "../interfaces"; import { RootState } from "../store"; import LoadingIndicator from "@thepalaceproject/web-opds-client/lib/components/LoadingIndicator"; import ErrorMessage from "./ErrorMessage"; @@ -32,7 +28,7 @@ export interface SelfTestsTabContainerOwnProps extends TabContainerProps { export interface SelfTestsTabContainerStateProps { fetchError?: FetchErrorData; - items?: CollectionsData | PatronAuthServicesData | SearchServicesData; + items?: CollectionsData | PatronAuthServicesData; isLoaded?: boolean; } @@ -54,7 +50,6 @@ export class SelfTestsTabContainer extends TabContainer< DISPLAY_NAMES = { collections: "Collections", patronAuthServices: "Patron Authentication", - searchServices: "Search Service Configuration", metadataServices: "Metadata Services", }; @@ -80,7 +75,7 @@ export class SelfTestsTabContainer extends TabContainer< getNames(category: string): string[] { // The name used to look up data in the store: "collections", - // "patron_auth_services", "search_services". + // "patron_auth_services". const keyName = category .split(/(?=[A-Z])/) .map((w) => w.toLowerCase()) @@ -134,12 +129,7 @@ function mapStateToProps(state, ownProps: SelfTestsTabContainerOwnProps) { function mapDispatchToProps(dispatch, ownProps: SelfTestsTabContainerOwnProps) { const actions = new ActionCreator(); - const itemTypes = [ - "Collections", - "PatronAuthServices", - "SearchServices", - "MetadataServices", - ]; + const itemTypes = ["Collections", "PatronAuthServices", "MetadataServices"]; return { fetchItems: () => itemTypes.forEach((type) => dispatch(actions["fetch" + type]())), diff --git a/src/components/TroubleshootingPage.tsx b/src/components/TroubleshootingPage.tsx index feeb0d64e..fc58c9dcd 100644 --- a/src/components/TroubleshootingPage.tsx +++ b/src/components/TroubleshootingPage.tsx @@ -38,12 +38,7 @@ export default class TroubleshootingPage extends React.Component< CATEGORIES = { diagnostics: ["coverage_provider", "script", "monitor", "other"], - "self-tests": [ - "collections", - "patronAuthServices", - "searchServices", - "metadataServices", - ], + "self-tests": ["collections", "patronAuthServices", "metadataServices"], }; constructor(props) { diff --git a/src/components/__tests__/ConfigTabContainer-test.tsx b/src/components/__tests__/ConfigTabContainer-test.tsx index 77f461ca6..5beadc11d 100644 --- a/src/components/__tests__/ConfigTabContainer-test.tsx +++ b/src/components/__tests__/ConfigTabContainer-test.tsx @@ -12,7 +12,6 @@ import IndividualAdmins from "../IndividualAdmins"; import PatronAuthServices from "../PatronAuthServices"; import SitewideSettings from "../SitewideSettings"; import MetadataServices from "../MetadataServices"; -import SearchServices from "../SearchServices"; import CatalogServices from "../CatalogServices"; import DiscoveryServices from "../DiscoveryServices"; import SitewideAnnouncements from "../SitewideAnnouncements"; @@ -68,7 +67,6 @@ describe("ConfigTabContainer", () => { PatronAuthServices, SitewideSettings, MetadataServices, - SearchServices, CatalogServices, DiscoveryServices, SitewideAnnouncements, @@ -135,7 +133,6 @@ describe("ConfigTabContainer", () => { PatronAuthServices, SitewideSettings, MetadataServices, - SearchServices, CatalogServices, DiscoveryServices, SitewideAnnouncements, @@ -186,7 +183,6 @@ describe("ConfigTabContainer", () => { PatronAuthServices, SitewideSettings, MetadataServices, - SearchServices, CatalogServices, DiscoveryServices, SitewideAnnouncements, diff --git a/src/components/__tests__/SelfTestsTabContainer-test.tsx b/src/components/__tests__/SelfTestsTabContainer-test.tsx index cd474527f..029268945 100644 --- a/src/components/__tests__/SelfTestsTabContainer-test.tsx +++ b/src/components/__tests__/SelfTestsTabContainer-test.tsx @@ -63,7 +63,7 @@ describe("SelfTestsTabContainer", () => { const nav = wrapper.find(".nav-tabs").at(0); expect(nav.length).to.equal(1); const tabs = nav.find("li"); - expect(tabs.length).to.equal(4); + expect(tabs.length).to.equal(3); const collectionsTab = tabs.at(0); expect(collectionsTab.text()).to.equal("Collections"); @@ -73,22 +73,17 @@ describe("SelfTestsTabContainer", () => { expect(patronAuthTab.text()).to.equal("Patron Authentication"); expect(patronAuthTab.hasClass("active")).to.be.false; - const searchTab = tabs.at(2); - expect(searchTab.text()).to.equal("Search Service Configuration"); - expect(searchTab.hasClass("active")).to.be.false; - - const metadataTab = tabs.at(3); + const metadataTab = tabs.at(2); expect(metadataTab.text()).to.equal("Metadata Services"); expect(metadataTab.hasClass("active")).to.be.false; }); it("renders tab content", () => { const contentComponents = wrapper.find(".tab-content > div"); - expect(contentComponents.length).to.equal(4); + expect(contentComponents.length).to.equal(3); const [ collectionsContent, patronAuthContent, - searchContent, metadataContent, ] = contentComponents.map((c) => c.childAt(0)); @@ -98,7 +93,6 @@ describe("SelfTestsTabContainer", () => { expect(collectionsContent.find(".self-tests-category").length).to.equal(1); expect(patronAuthContent.find(LoadingIndicator).length).to.equal(1); - expect(searchContent.find(LoadingIndicator).length).to.equal(1); expect(metadataContent.find(LoadingIndicator).length).to.equal(1); }); @@ -114,7 +108,7 @@ describe("SelfTestsTabContainer", () => { wrapper.setProps({ fetchError }); error = wrapper.find(ErrorMessage); - expect(error.length).to.equal(4); + expect(error.length).to.equal(3); }); it("calls goToTab", () => { @@ -163,11 +157,6 @@ describe("SelfTestsTabContainer", () => { "patron_auth_service", "patronAuth", ]); - expect(wrapper.instance().getNames("searchServices")).to.eql([ - "search_services", - "search_service", - "search", - ]); expect(wrapper.instance().getNames("metadataServices")).to.eql([ "metadata_services", "metadata_service", diff --git a/src/interfaces.ts b/src/interfaces.ts index c072d1fac..7b2ad02e5 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -376,12 +376,6 @@ export interface MetadataServicesData extends ServicesData { metadata_services: MetadataServiceData[]; } -export interface SearchServiceData extends ServiceData {} - -export interface SearchServicesData extends ServicesData { - search_services: SearchServiceData[]; -} - export interface CatalogServiceData extends ServiceData {} export interface CatalogServicesData extends ServicesData { diff --git a/src/reducers/index.ts b/src/reducers/index.ts index a4d1b3402..526626af7 100644 --- a/src/reducers/index.ts +++ b/src/reducers/index.ts @@ -15,7 +15,6 @@ import patronAuthServices from "./patronAuthServices"; import sitewideAnnouncements from "./sitewideAnnouncements"; import sitewideSettings from "./sitewideSettings"; import metadataServices from "./metadataServices"; -import searchServices from "./searchServices"; import catalogServices from "./catalogServices"; import discoveryServices from "./discoveryServices"; import registerLibraryWithDiscoveryService from "./registerLibraryWithDiscoveryService"; @@ -50,7 +49,6 @@ import { SitewideAnnouncementsData, SitewideSettingsData, MetadataServicesData, - SearchServicesData, CatalogServicesData, DiscoveryServicesData, LibraryRegistrationsData, @@ -82,7 +80,6 @@ export interface State { sitewideAnnouncements: FetchEditState; sitewideSettings: FetchEditState; metadataServices: FetchEditState; - searchServices: FetchEditState; catalogServices: FetchEditState; discoveryServices: FetchEditState; registerLibraryWithDiscoveryService: RegisterLibraryState; @@ -123,7 +120,6 @@ export default combineReducers({ sitewideAnnouncements, sitewideSettings, metadataServices, - searchServices, catalogServices, discoveryServices, registerLibraryWithDiscoveryService, diff --git a/src/reducers/searchServices.ts b/src/reducers/searchServices.ts deleted file mode 100644 index a4c5a92a8..000000000 --- a/src/reducers/searchServices.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { SearchServicesData } from "../interfaces"; -import { extraActions } from "./hasSelfTests"; -import ActionCreator from "../actions"; -import createFetchEditReducer from "./createFetchEditReducer"; - -export default createFetchEditReducer( - ActionCreator.SEARCH_SERVICES, - ActionCreator.EDIT_SEARCH_SERVICE, - extraActions -);