From 2d52959cd107db51218933d1ebab058abb814cce Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Mon, 2 Oct 2023 12:38:31 -0300 Subject: [PATCH] Remove logging configuration components. --- src/actions.ts | 29 ----- src/components/ConfigTabContainer.tsx | 2 - src/components/LoggingServices.tsx | 61 ---------- .../__tests__/LoggingServices-test.tsx | 106 ------------------ src/interfaces.ts | 6 - src/reducers/index.ts | 4 - src/reducers/loggingServices.ts | 8 -- 7 files changed, 216 deletions(-) delete mode 100644 src/components/LoggingServices.tsx delete mode 100644 src/components/__tests__/LoggingServices-test.tsx delete mode 100644 src/reducers/loggingServices.ts diff --git a/src/actions.ts b/src/actions.ts index e0e2e2e9c..20d4cd81a 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -22,7 +22,6 @@ import { MediaData, LanguagesData, RightsStatusData, - LoggingServicesData, CatalogServicesData, SelfTestsData, PatronData, @@ -85,9 +84,6 @@ export default class ActionCreator extends BaseActionCreator { static readonly SITEWIDE_SETTINGS = "SITEWIDE_SETTINGS"; static readonly EDIT_SITEWIDE_SETTING = "EDIT_SITEWIDE_SETTING"; static readonly DELETE_SITEWIDE_SETTING = "DELETE_SITEWIDE_SETTING"; - static readonly LOGGING_SERVICES = "LOGGING_SERVICES"; - static readonly EDIT_LOGGING_SERVICE = "EDIT_LOGGING_SERVICE"; - static readonly DELETE_LOGGING_SERVICE = "DELETE_LOGGING_SERVICE"; static readonly METADATA_SERVICES = "METADATA_SERVICES"; static readonly EDIT_METADATA_SERVICE = "EDIT_METADATA_SERVICE"; static readonly DELETE_METADATA_SERVICE = "DELETE_METADATA_SERVICE"; @@ -581,31 +577,6 @@ export default class ActionCreator extends BaseActionCreator { ).bind(this); } - fetchLoggingServices() { - const url = "/admin/logging_services"; - return this.fetchJSON( - ActionCreator.LOGGING_SERVICES, - url - ).bind(this); - } - - editLoggingService(data: FormData) { - const url = "/admin/logging_services"; - return this.postForm(ActionCreator.EDIT_LOGGING_SERVICE, url, data).bind( - this - ); - } - - deleteLoggingService(identifier: string | number) { - const url = "/admin/logging_service/" + identifier; - return this.postForm( - ActionCreator.DELETE_LOGGING_SERVICE, - url, - null, - "DELETE" - ).bind(this); - } - fetchMetadataServices() { const url = "/admin/metadata_services"; return this.fetchJSON( diff --git a/src/components/ConfigTabContainer.tsx b/src/components/ConfigTabContainer.tsx index 8f5e7e3c3..2cfbec0d0 100644 --- a/src/components/ConfigTabContainer.tsx +++ b/src/components/ConfigTabContainer.tsx @@ -11,7 +11,6 @@ import AnalyticsServices from "./AnalyticsServices"; import SearchServices from "./SearchServices"; import CatalogServices from "./CatalogServices"; import DiscoveryServices from "./DiscoveryServices"; -import LoggingServices from "./LoggingServices"; import { TabContainer, TabContainerProps, @@ -47,7 +46,6 @@ export default class ConfigTabContainer extends TabContainer< collections: Collections, patronAuth: PatronAuthServices, sitewideSettings: SitewideSettings, - logging: LoggingServices, metadata: MetadataServices, analytics: AnalyticsServices, search: SearchServices, diff --git a/src/components/LoggingServices.tsx b/src/components/LoggingServices.tsx deleted file mode 100644 index 9218b5580..000000000 --- a/src/components/LoggingServices.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import EditableConfigList, { - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps, -} from "./EditableConfigList"; -import { connect } from "react-redux"; -import ActionCreator from "../actions"; -import { LoggingServicesData, LoggingServiceData } from "../interfaces"; -import ServiceEditForm from "./ServiceEditForm"; - -/** Right panel for logging settings on the system configuration page. - Shows a list of current logging settings and allows creating a new - setting or editing or deleting an existing setting. */ -export class LoggingServices extends EditableConfigList< - LoggingServicesData, - LoggingServiceData -> { - EditForm = ServiceEditForm; - listDataKey = "logging_services"; - itemTypeName = "logging service"; - urlBase = "/admin/web/config/logging/"; - identifierKey = "id"; - labelKey = "protocol"; -} - -function mapStateToProps(state, ownProps) { - // fetchError = an error involving loading the list of logging services; formError = an error upon submission of the - // create/edit form. - return { - data: state.editor.loggingServices && state.editor.loggingServices.data, - responseBody: - state.editor.loggingServices && - state.editor.loggingServices.successMessage, - fetchError: state.editor.loggingServices.fetchError, - formError: state.editor.loggingServices.formError, - isFetching: - state.editor.loggingServices.isFetching || - state.editor.loggingServices.isEditing, - }; -} - -function mapDispatchToProps(dispatch, ownProps) { - const actions = new ActionCreator(null, ownProps.csrfToken); - return { - fetchData: () => dispatch(actions.fetchLoggingServices()), - editItem: (data: FormData) => dispatch(actions.editLoggingService(data)), - deleteItem: (identifier: string | number) => - dispatch(actions.deleteLoggingService(identifier)), - }; -} - -const ConnectedLoggingSettings = connect< - EditableConfigListStateProps, - EditableConfigListDispatchProps, - EditableConfigListOwnProps ->( - mapStateToProps, - mapDispatchToProps -)(LoggingServices); - -export default ConnectedLoggingSettings; diff --git a/src/components/__tests__/LoggingServices-test.tsx b/src/components/__tests__/LoggingServices-test.tsx deleted file mode 100644 index 1153fb6bb..000000000 --- a/src/components/__tests__/LoggingServices-test.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import { expect } from "chai"; -import { stub } from "sinon"; - -import * as React from "react"; -import { mount } from "enzyme"; - -import Admin from "../../models/Admin"; -import { LoggingServices } from "../LoggingServices"; - -describe("LoggingServices", () => { - let wrapper; - let fetchData; - let editItem; - const data = { - logging_services: [ - { - id: 1, - label: "loggly", - name: "loggly", - protocol: "loggly", - sitewide: true, - }, - ], - protocols: [ - { - label: "loggly", - name: "loggly", - settings: [ - { - key: "user", - label: "Username", - }, - { - key: "password", - label: "Password", - }, - { - key: "url", - label: "URL", - }, - ], - sitewide: true, - }, - { - label: "sysLog", - name: "sysLog", - settings: [ - { - key: "log_format", - label: "Log Format", - options: [ - { - key: "json", - label: "json", - }, - { - key: "text", - label: "text", - }, - ], - type: "select", - }, - { - key: "message_template", - label: "template", - }, - ], - sitewide: true, - }, - ], - }; - - const pause = () => { - return new Promise((resolve) => setTimeout(resolve, 0)); - }; - - beforeEach(() => { - const systemAdmin = new Admin([{ role: "system", library: "nypl" }]); - - fetchData = stub(); - editItem = stub().returns( - new Promise((resolve) => resolve()) - ); - - wrapper = mount( - , - { context: { admin: systemAdmin } } - ); - }); - - it("shows logging service list", () => { - const loggingService = wrapper.find("li"); - expect(loggingService.length).to.equal(1); - expect(loggingService.at(0).text()).to.contain( - "Edit Pencil IconlogglyDeleteTrash Icon" - ); - const editLink = loggingService.at(0).find("a").at(0); - expect(editLink.props().href).to.equal("/admin/web/config/logging/edit/1"); - }); -}); diff --git a/src/interfaces.ts b/src/interfaces.ts index 9db3efb86..759c152d8 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -363,12 +363,6 @@ export interface SitewideSettingsData { all_settings: SettingData[]; } -export interface LoggingServiceData extends ServiceData {} - -export interface LoggingServicesData extends ServicesData { - logging_services: LoggingServiceData[]; -} - export interface MetadataServiceData extends ServiceData {} export interface MetadataServicesData extends ServicesData { diff --git a/src/reducers/index.ts b/src/reducers/index.ts index 4cfbd9e29..6457a006b 100644 --- a/src/reducers/index.ts +++ b/src/reducers/index.ts @@ -14,7 +14,6 @@ import individualAdmins from "./individualAdmins"; import patronAuthServices from "./patronAuthServices"; import sitewideAnnouncements from "./sitewideAnnouncements"; import sitewideSettings from "./sitewideSettings"; -import loggingServices from "./loggingServices"; import metadataServices from "./metadataServices"; import analyticsServices from "./analyticsServices"; import searchServices from "./searchServices"; @@ -51,7 +50,6 @@ import { PatronAuthServicesData, SitewideAnnouncementsData, SitewideSettingsData, - LoggingServicesData, MetadataServicesData, AnalyticsServicesData, SearchServicesData, @@ -85,7 +83,6 @@ export interface State { patronAuthServices: FetchEditState; sitewideAnnouncements: FetchEditState; sitewideSettings: FetchEditState; - loggingServices: FetchEditState; metadataServices: FetchEditState; analyticsServices: FetchEditState; searchServices: FetchEditState; @@ -128,7 +125,6 @@ export default combineReducers({ patronAuthServices, sitewideAnnouncements, sitewideSettings, - loggingServices, metadataServices, analyticsServices, searchServices, diff --git a/src/reducers/loggingServices.ts b/src/reducers/loggingServices.ts deleted file mode 100644 index f9ff6f424..000000000 --- a/src/reducers/loggingServices.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { LoggingServicesData } from "../interfaces"; -import ActionCreator from "../actions"; -import createFetchEditReducer from "./createFetchEditReducer"; - -export default createFetchEditReducer( - ActionCreator.LOGGING_SERVICES, - ActionCreator.EDIT_LOGGING_SERVICE -);