From f465eaa7705c9ecdb740defc0577751525b2bd93 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Tue, 19 Sep 2023 09:24:35 -0300 Subject: [PATCH] Remove storage services component. (#87) --- src/actions.ts | 29 -------- src/components/ConfigTabContainer.tsx | 2 - src/components/StorageServices.tsx | 72 ------------------- .../__tests__/ConfigTabContainer-test.tsx | 4 -- src/interfaces.ts | 6 -- src/reducers/index.ts | 4 -- src/reducers/storageServices.ts | 8 --- 7 files changed, 125 deletions(-) delete mode 100644 src/components/StorageServices.tsx delete mode 100644 src/reducers/storageServices.ts diff --git a/src/actions.ts b/src/actions.ts index 854f5dc9b..e0e2e2e9c 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -22,7 +22,6 @@ import { MediaData, LanguagesData, RightsStatusData, - StorageServicesData, LoggingServicesData, CatalogServicesData, SelfTestsData, @@ -98,9 +97,6 @@ export default class ActionCreator extends BaseActionCreator { static readonly SEARCH_SERVICES = "SEARCH_SERVICES"; static readonly EDIT_SEARCH_SERVICE = "EDIT_SEARCH_SERVICE"; static readonly DELETE_SEARCH_SERVICE = "DELETE_SEARCH_SERVICE"; - static readonly STORAGE_SERVICES = "STORAGE_SERVICES"; - static readonly EDIT_STORAGE_SERVICE = "EDIT_STORAGE_SERVICE"; - static readonly DELETE_STORAGE_SERVICE = "DELETE_STORAGE_SERVICE"; static readonly CATALOG_SERVICES = "CATALOG_SERVICES"; static readonly EDIT_CATALOG_SERVICE = "EDIT_CATALOG_SERVICE"; static readonly DELETE_CATALOG_SERVICE = "DELETE_CATALOG_SERVICE"; @@ -685,31 +681,6 @@ export default class ActionCreator extends BaseActionCreator { ).bind(this); } - fetchStorageServices() { - const url = "/admin/storage_services"; - return this.fetchJSON( - ActionCreator.STORAGE_SERVICES, - url - ).bind(this); - } - - editStorageService(data: FormData) { - const url = "/admin/storage_services"; - return this.postForm(ActionCreator.EDIT_STORAGE_SERVICE, url, data).bind( - this - ); - } - - deleteStorageService(identifier: string | number) { - const url = "/admin/storage_service/" + identifier; - return this.postForm( - ActionCreator.DELETE_STORAGE_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 06491c333..8f5e7e3c3 100644 --- a/src/components/ConfigTabContainer.tsx +++ b/src/components/ConfigTabContainer.tsx @@ -9,7 +9,6 @@ import SitewideSettings from "./SitewideSettings"; import MetadataServices from "./MetadataServices"; import AnalyticsServices from "./AnalyticsServices"; import SearchServices from "./SearchServices"; -import StorageServices from "./StorageServices"; import CatalogServices from "./CatalogServices"; import DiscoveryServices from "./DiscoveryServices"; import LoggingServices from "./LoggingServices"; @@ -52,7 +51,6 @@ export default class ConfigTabContainer extends TabContainer< metadata: MetadataServices, analytics: AnalyticsServices, search: SearchServices, - storage: StorageServices, catalogServices: CatalogServices, discovery: DiscoveryServices, sitewideAnnouncements: SitewideAnnouncements, diff --git a/src/components/StorageServices.tsx b/src/components/StorageServices.tsx deleted file mode 100644 index cf71048e8..000000000 --- a/src/components/StorageServices.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import EditableConfigList, { - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps, -} from "./EditableConfigList"; -import { connect } from "react-redux"; -import ActionCreator from "../actions"; -import { StorageServicesData, StorageServiceData } from "../interfaces"; -import ServiceEditForm from "./ServiceEditForm"; - -/** Right panel for storage services on the system configuration page. */ -export class StorageServices extends EditableConfigList< - StorageServicesData, - StorageServiceData -> { - EditForm = ServiceEditForm; - listDataKey = "storage_services"; - itemTypeName = "storage service"; - urlBase = "/admin/web/config/storage/"; - identifierKey = "id"; - labelKey = "protocol"; - - label(item): string { - for (const protocol of this.props.data.protocols) { - if (protocol.name === item.protocol) { - return `${item.name}: ${protocol.label}`; - } - } - return item.protocol; - } -} - -function mapStateToProps(state, ownProps) { - const data = Object.assign( - {}, - (state.editor.storageServices && state.editor.storageServices.data) || {} - ); - // fetchError = an error involving loading the list of storage services; formError = an error upon - // submission of the create/edit form. - return { - data: data, - responseBody: - state.editor.storageServices && - state.editor.storageServices.successMessage, - fetchError: state.editor.storageServices.fetchError, - formError: state.editor.storageServices.formError, - isFetching: - state.editor.storageServices.isFetching || - state.editor.storageServices.isEditing, - }; -} - -function mapDispatchToProps(dispatch, ownProps) { - const actions = new ActionCreator(null, ownProps.csrfToken); - return { - fetchData: () => dispatch(actions.fetchStorageServices()), - editItem: (data: FormData) => dispatch(actions.editStorageService(data)), - deleteItem: (identifier: string | number) => - dispatch(actions.deleteStorageService(identifier)), - }; -} - -const ConnectedStorageServices = connect< - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps ->( - mapStateToProps, - mapDispatchToProps -)(StorageServices); - -export default ConnectedStorageServices; diff --git a/src/components/__tests__/ConfigTabContainer-test.tsx b/src/components/__tests__/ConfigTabContainer-test.tsx index b596d3788..aeaaefad9 100644 --- a/src/components/__tests__/ConfigTabContainer-test.tsx +++ b/src/components/__tests__/ConfigTabContainer-test.tsx @@ -14,7 +14,6 @@ import SitewideSettings from "../SitewideSettings"; import MetadataServices from "../MetadataServices"; import AnalyticsServices from "../AnalyticsServices"; import SearchServices from "../SearchServices"; -import StorageServices from "../StorageServices"; import CatalogServices from "../CatalogServices"; import DiscoveryServices from "../DiscoveryServices"; import SitewideAnnouncements from "../SitewideAnnouncements"; @@ -72,7 +71,6 @@ describe("ConfigTabContainer", () => { MetadataServices, AnalyticsServices, SearchServices, - StorageServices, CatalogServices, DiscoveryServices, SitewideAnnouncements, @@ -141,7 +139,6 @@ describe("ConfigTabContainer", () => { SitewideSettings, MetadataServices, SearchServices, - StorageServices, CatalogServices, DiscoveryServices, AnalyticsServices, @@ -194,7 +191,6 @@ describe("ConfigTabContainer", () => { SitewideSettings, MetadataServices, SearchServices, - StorageServices, CatalogServices, DiscoveryServices, AnalyticsServices, diff --git a/src/interfaces.ts b/src/interfaces.ts index 6891192e6..9db3efb86 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -387,12 +387,6 @@ export interface SearchServicesData extends ServicesData { search_services: SearchServiceData[]; } -export interface StorageServiceData extends ServiceData {} - -export interface StorageServicesData extends ServicesData { - storage_services: StorageServiceData[]; -} - export interface CatalogServiceData extends ServiceData {} export interface CatalogServicesData extends ServicesData { diff --git a/src/reducers/index.ts b/src/reducers/index.ts index 1116f939b..4cfbd9e29 100644 --- a/src/reducers/index.ts +++ b/src/reducers/index.ts @@ -18,7 +18,6 @@ import loggingServices from "./loggingServices"; import metadataServices from "./metadataServices"; import analyticsServices from "./analyticsServices"; import searchServices from "./searchServices"; -import storageServices from "./storageServices"; import catalogServices from "./catalogServices"; import discoveryServices from "./discoveryServices"; import registerLibraryWithDiscoveryService from "./registerLibraryWithDiscoveryService"; @@ -56,7 +55,6 @@ import { MetadataServicesData, AnalyticsServicesData, SearchServicesData, - StorageServicesData, CatalogServicesData, DiscoveryServicesData, LibraryRegistrationsData, @@ -91,7 +89,6 @@ export interface State { metadataServices: FetchEditState; analyticsServices: FetchEditState; searchServices: FetchEditState; - storageServices: FetchEditState; catalogServices: FetchEditState; discoveryServices: FetchEditState; registerLibraryWithDiscoveryService: RegisterLibraryState; @@ -135,7 +132,6 @@ export default combineReducers({ metadataServices, analyticsServices, searchServices, - storageServices, catalogServices, discoveryServices, registerLibraryWithDiscoveryService, diff --git a/src/reducers/storageServices.ts b/src/reducers/storageServices.ts deleted file mode 100644 index 3296f80e0..000000000 --- a/src/reducers/storageServices.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { StorageServicesData } from "../interfaces"; -import ActionCreator from "../actions"; -import createFetchEditReducer from "./createFetchEditReducer"; - -export default createFetchEditReducer( - ActionCreator.STORAGE_SERVICES, - ActionCreator.EDIT_STORAGE_SERVICE -);