diff --git a/frontend/src/Activity/Blacklist/BlacklistConnector.js b/frontend/src/Activity/Blacklist/BlacklistConnector.js index 29cf3e08a..466cc40b7 100644 --- a/frontend/src/Activity/Blacklist/BlacklistConnector.js +++ b/frontend/src/Activity/Blacklist/BlacklistConnector.js @@ -126,6 +126,7 @@ class BlacklistConnector extends Component { } BlacklistConnector.propTypes = { + useCurrentPage: PropTypes.bool.isRequired, isClearingBlacklistExecuting: PropTypes.bool.isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired, fetchBlacklist: PropTypes.func.isRequired, diff --git a/frontend/src/Activity/History/HistoryConnector.js b/frontend/src/Activity/History/HistoryConnector.js index 35591f258..c351487a6 100644 --- a/frontend/src/Activity/History/HistoryConnector.js +++ b/frontend/src/Activity/History/HistoryConnector.js @@ -137,6 +137,7 @@ class HistoryConnector extends Component { } HistoryConnector.propTypes = { + useCurrentPage: PropTypes.bool.isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired, fetchHistory: PropTypes.func.isRequired, gotoHistoryFirstPage: PropTypes.func.isRequired, diff --git a/frontend/src/Store/Actions/blacklistActions.js b/frontend/src/Store/Actions/blacklistActions.js index d6fbfb99b..ee7f44f84 100644 --- a/frontend/src/Store/Actions/blacklistActions.js +++ b/frontend/src/Store/Actions/blacklistActions.js @@ -132,7 +132,7 @@ export const reducers = createHandleActions({ [SET_BLACKLIST_TABLE_OPTION]: createSetTableOptionReducer(section), - [CLEAR_BLACKLIST]: createClearReducer('history', { + [CLEAR_BLACKLIST]: createClearReducer(section, { isFetching: false, isPopulated: false, error: null, diff --git a/frontend/src/Store/Actions/systemActions.js b/frontend/src/Store/Actions/systemActions.js index de156cde2..1007399a0 100644 --- a/frontend/src/Store/Actions/systemActions.js +++ b/frontend/src/Store/Actions/systemActions.js @@ -5,6 +5,7 @@ import { filterTypes, sortDirections } from 'Helpers/Props'; import { createThunk, handleThunks } from 'Store/thunks'; import { setAppValue } from 'Store/Actions/appActions'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; +import createClearReducer from './Creators/Reducers/createClearReducer'; import createFetchHandler from './Creators/createFetchHandler'; import createRemoveItemHandler from './Creators/createRemoveItemHandler'; import createHandleActions from './Creators/createHandleActions'; @@ -199,7 +200,8 @@ export const GOTO_LAST_LOGS_PAGE = 'system/logs/gotoLogsLastPage'; export const GOTO_LOGS_PAGE = 'system/logs/gotoLogsPage'; export const SET_LOGS_SORT = 'system/logs/setLogsSort'; export const SET_LOGS_FILTER = 'system/logs/setLogsFilter'; -export const SET_LOGS_TABLE_OPTION = 'system/logs/ssetLogsTableOption'; +export const SET_LOGS_TABLE_OPTION = 'system/logs/setLogsTableOption'; +export const CLEAR_LOGS_TABLE = 'system/logs/clearLogsTable'; export const FETCH_LOG_FILES = 'system/logFiles/fetchLogFiles'; export const FETCH_UPDATE_LOG_FILES = 'system/updateLogFiles/fetchUpdateLogFiles'; @@ -233,6 +235,7 @@ export const gotoLogsPage = createThunk(GOTO_LOGS_PAGE); export const setLogsSort = createThunk(SET_LOGS_SORT); export const setLogsFilter = createThunk(SET_LOGS_FILTER); export const setLogsTableOption = createAction(SET_LOGS_TABLE_OPTION); +export const clearLogsTable = createAction(CLEAR_LOGS_TABLE); export const fetchLogFiles = createThunk(FETCH_LOG_FILES); export const fetchUpdateLogFiles = createThunk(FETCH_UPDATE_LOG_FILES); @@ -370,6 +373,15 @@ export const reducers = createHandleActions({ }; }, - [SET_LOGS_TABLE_OPTION]: createSetTableOptionReducer('logs') + [SET_LOGS_TABLE_OPTION]: createSetTableOptionReducer('logs'), + + [CLEAR_LOGS_TABLE]: createClearReducer(section, { + isFetching: false, + isPopulated: false, + error: null, + items: [], + totalPages: 0, + totalRecords: 0 + }) }, defaultState, section); diff --git a/frontend/src/System/Events/LogsTableConnector.js b/frontend/src/System/Events/LogsTableConnector.js index c02d67650..d2cb6caf8 100644 --- a/frontend/src/System/Events/LogsTableConnector.js +++ b/frontend/src/System/Events/LogsTableConnector.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import withCurrentPage from 'Components/withCurrentPage'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import { executeCommand } from 'Store/Actions/commandActions'; import * as systemActions from 'Store/Actions/systemActions'; @@ -32,7 +33,17 @@ class LogsTableConnector extends Component { // Lifecycle componentDidMount() { - this.props.fetchLogs(); + const { + useCurrentPage, + fetchLogs, + gotoLogsFirstPage + } = this.props; + + if (useCurrentPage) { + fetchLogs(); + } else { + gotoLogsFirstPage(); + } } componentDidUpdate(prevProps) { @@ -111,6 +122,7 @@ class LogsTableConnector extends Component { } LogsTableConnector.propTypes = { + useCurrentPage: PropTypes.bool.isRequired, clearLogExecuting: PropTypes.bool.isRequired, fetchLogs: PropTypes.func.isRequired, gotoLogsFirstPage: PropTypes.func.isRequired, @@ -124,4 +136,6 @@ LogsTableConnector.propTypes = { executeCommand: PropTypes.func.isRequired }; -export default connect(createMapStateToProps, mapDispatchToProps)(LogsTableConnector); +export default withCurrentPage( + connect(createMapStateToProps, mapDispatchToProps)(LogsTableConnector) +);