From 512216cf9084522d5fb2a045908579feb4ef23a5 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 20 Feb 2021 17:42:56 -0500 Subject: [PATCH] Hook up Test All Applications button in UI --- frontend/src/App/AppRoutes.js | 4 +- .../Applications/ApplicationSettings.js | 65 ++++++++++++------- .../ApplicationSettingsConnector.js | 21 ++++++ .../Store/Actions/Settings/applications.js | 7 +- 4 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 frontend/src/Settings/Applications/ApplicationSettingsConnector.js diff --git a/frontend/src/App/AppRoutes.js b/frontend/src/App/AppRoutes.js index 17aa034e0..fc207ac1b 100644 --- a/frontend/src/App/AppRoutes.js +++ b/frontend/src/App/AppRoutes.js @@ -7,7 +7,7 @@ import HistoryConnector from 'History/HistoryConnector'; import IndexerIndexConnector from 'Indexer/Index/IndexerIndexConnector'; import StatsConnector from 'Indexer/Stats/StatsConnector'; import SearchIndexConnector from 'Search/SearchIndexConnector'; -import ApplicationSettings from 'Settings/Applications/ApplicationSettings'; +import ApplicationSettingsConnector from 'Settings/Applications/ApplicationSettingsConnector'; import GeneralSettingsConnector from 'Settings/General/GeneralSettingsConnector'; import NotificationSettings from 'Settings/Notifications/NotificationSettings'; import Settings from 'Settings/Settings'; @@ -90,7 +90,7 @@ function AppRoutes(props) { - - +class ApplicationSettings extends Component { + render() { + const { + isTestingAll, + dispatchTestAllApplications + } = this.props; - + return ( + + + - - - } - /> + - - - - - ); + + + } + /> + + + + + + ); + } } +ApplicationSettings.propTypes = { + isTestingAll: PropTypes.bool.isRequired, + dispatchTestAllApplications: PropTypes.func.isRequired +}; + export default ApplicationSettings; diff --git a/frontend/src/Settings/Applications/ApplicationSettingsConnector.js b/frontend/src/Settings/Applications/ApplicationSettingsConnector.js new file mode 100644 index 000000000..827abbe16 --- /dev/null +++ b/frontend/src/Settings/Applications/ApplicationSettingsConnector.js @@ -0,0 +1,21 @@ +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { testAllApplications } from 'Store/Actions/settingsActions'; +import ApplicationSettings from './ApplicationSettings'; + +function createMapStateToProps() { + return createSelector( + (state) => state.settings.applications.isTestingAll, + (isTestingAll) => { + return { + isTestingAll + }; + } + ); +} + +const mapDispatchToProps = { + dispatchTestAllApplications: testAllApplications +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(ApplicationSettings); diff --git a/frontend/src/Store/Actions/Settings/applications.js b/frontend/src/Store/Actions/Settings/applications.js index 6e7c13b94..a670732e0 100644 --- a/frontend/src/Store/Actions/Settings/applications.js +++ b/frontend/src/Store/Actions/Settings/applications.js @@ -3,6 +3,7 @@ import createFetchHandler from 'Store/Actions/Creators/createFetchHandler'; import createFetchSchemaHandler from 'Store/Actions/Creators/createFetchSchemaHandler'; import createRemoveItemHandler from 'Store/Actions/Creators/createRemoveItemHandler'; import createSaveProviderHandler, { createCancelSaveProviderHandler } from 'Store/Actions/Creators/createSaveProviderHandler'; +import createTestAllProvidersHandler from 'Store/Actions/Creators/createTestAllProvidersHandler'; import createTestProviderHandler, { createCancelTestProviderHandler } from 'Store/Actions/Creators/createTestProviderHandler'; import createSetProviderFieldValueReducer from 'Store/Actions/Creators/Reducers/createSetProviderFieldValueReducer'; import createSetSettingValueReducer from 'Store/Actions/Creators/Reducers/createSetSettingValueReducer'; @@ -27,6 +28,7 @@ export const CANCEL_SAVE_APPLICATION = 'settings/applications/cancelSaveApplicat export const DELETE_APPLICATION = 'settings/applications/deleteApplication'; export const TEST_APPLICATION = 'settings/applications/testApplication'; export const CANCEL_TEST_APPLICATION = 'settings/applications/cancelTestApplication'; +export const TEST_ALL_APPLICATIONS = 'indexers/testAllApplications'; // // Action Creators @@ -40,6 +42,7 @@ export const cancelSaveApplication = createThunk(CANCEL_SAVE_APPLICATION); export const deleteApplication = createThunk(DELETE_APPLICATION); export const testApplication = createThunk(TEST_APPLICATION); export const cancelTestApplication = createThunk(CANCEL_TEST_APPLICATION); +export const testAllApplications = createThunk(TEST_ALL_APPLICATIONS); export const setApplicationValue = createAction(SET_APPLICATION_VALUE, (payload) => { return { @@ -75,6 +78,7 @@ export default { isSaving: false, saveError: null, isTesting: false, + isTestingAll: false, items: [], pendingChanges: {} }, @@ -90,7 +94,8 @@ export default { [CANCEL_SAVE_APPLICATION]: createCancelSaveProviderHandler(section), [DELETE_APPLICATION]: createRemoveItemHandler(section, '/applications'), [TEST_APPLICATION]: createTestProviderHandler(section, '/applications'), - [CANCEL_TEST_APPLICATION]: createCancelTestProviderHandler(section) + [CANCEL_TEST_APPLICATION]: createCancelTestProviderHandler(section), + [TEST_ALL_APPLICATIONS]: createTestAllProvidersHandler(section, '/applications') }, //