From 3e4711e4c5348c27df30302b47553d62d3eed183 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 20d4cd81a..83f881505 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -12,7 +12,6 @@ import { SitewideSettingsData, MetadataServicesData, AnalyticsServicesData, - SearchServicesData, DiscoveryServicesData, LibraryRegistrationsData, CustomListsData, @@ -90,9 +89,6 @@ export default class ActionCreator extends BaseActionCreator { static readonly ANALYTICS_SERVICES = "ANALYTICS_SERVICES"; static readonly EDIT_ANALYTICS_SERVICE = "EDIT_ANALYTICS_SERVICE"; static readonly DELETE_ANALYTICS_SERVICE = "DELETE_ANALYTICS_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"; @@ -627,31 +623,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 2cfbec0d0..3c9f82669 100644 --- a/src/components/ConfigTabContainer.tsx +++ b/src/components/ConfigTabContainer.tsx @@ -8,7 +8,6 @@ import SitewideAnnouncements from "./SitewideAnnouncements"; import SitewideSettings from "./SitewideSettings"; import MetadataServices from "./MetadataServices"; import AnalyticsServices from "./AnalyticsServices"; -import SearchServices from "./SearchServices"; import CatalogServices from "./CatalogServices"; import DiscoveryServices from "./DiscoveryServices"; import { @@ -48,7 +47,6 @@ export default class ConfigTabContainer extends TabContainer< sitewideSettings: SitewideSettings, metadata: MetadataServices, analytics: AnalyticsServices, - 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 aeaaefad9..76023c8d6 100644 --- a/src/components/__tests__/ConfigTabContainer-test.tsx +++ b/src/components/__tests__/ConfigTabContainer-test.tsx @@ -13,7 +13,6 @@ import PatronAuthServices from "../PatronAuthServices"; import SitewideSettings from "../SitewideSettings"; import MetadataServices from "../MetadataServices"; import AnalyticsServices from "../AnalyticsServices"; -import SearchServices from "../SearchServices"; import CatalogServices from "../CatalogServices"; import DiscoveryServices from "../DiscoveryServices"; import SitewideAnnouncements from "../SitewideAnnouncements"; @@ -70,7 +69,6 @@ describe("ConfigTabContainer", () => { SitewideSettings, MetadataServices, AnalyticsServices, - SearchServices, CatalogServices, DiscoveryServices, SitewideAnnouncements, @@ -138,7 +136,6 @@ describe("ConfigTabContainer", () => { PatronAuthServices, SitewideSettings, MetadataServices, - SearchServices, CatalogServices, DiscoveryServices, AnalyticsServices, @@ -190,7 +187,6 @@ describe("ConfigTabContainer", () => { PatronAuthServices, SitewideSettings, MetadataServices, - SearchServices, CatalogServices, DiscoveryServices, AnalyticsServices, 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 759c152d8..cd1472331 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -375,12 +375,6 @@ export interface AnalyticsServicesData extends ServicesData { analytics_services: AnalyticsServiceData[]; } -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 6457a006b..8a329cb67 100644 --- a/src/reducers/index.ts +++ b/src/reducers/index.ts @@ -16,7 +16,6 @@ import sitewideAnnouncements from "./sitewideAnnouncements"; import sitewideSettings from "./sitewideSettings"; import metadataServices from "./metadataServices"; import analyticsServices from "./analyticsServices"; -import searchServices from "./searchServices"; import catalogServices from "./catalogServices"; import discoveryServices from "./discoveryServices"; import registerLibraryWithDiscoveryService from "./registerLibraryWithDiscoveryService"; @@ -52,7 +51,6 @@ import { SitewideSettingsData, MetadataServicesData, AnalyticsServicesData, - SearchServicesData, CatalogServicesData, DiscoveryServicesData, LibraryRegistrationsData, @@ -85,7 +83,6 @@ export interface State { sitewideSettings: FetchEditState; metadataServices: FetchEditState; analyticsServices: FetchEditState; - searchServices: FetchEditState; catalogServices: FetchEditState; discoveryServices: FetchEditState; registerLibraryWithDiscoveryService: RegisterLibraryState; @@ -127,7 +124,6 @@ export default combineReducers({ sitewideSettings, metadataServices, analyticsServices, - 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 -);