Fixed: Log events not loading from the first page when revisiting

pull/2900/head
Mark McDowall 6 years ago
parent a3baab9671
commit 36fe4eaa49

@ -126,6 +126,7 @@ class BlacklistConnector extends Component {
} }
BlacklistConnector.propTypes = { BlacklistConnector.propTypes = {
useCurrentPage: PropTypes.bool.isRequired,
isClearingBlacklistExecuting: PropTypes.bool.isRequired, isClearingBlacklistExecuting: PropTypes.bool.isRequired,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
fetchBlacklist: PropTypes.func.isRequired, fetchBlacklist: PropTypes.func.isRequired,

@ -137,6 +137,7 @@ class HistoryConnector extends Component {
} }
HistoryConnector.propTypes = { HistoryConnector.propTypes = {
useCurrentPage: PropTypes.bool.isRequired,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
fetchHistory: PropTypes.func.isRequired, fetchHistory: PropTypes.func.isRequired,
gotoHistoryFirstPage: PropTypes.func.isRequired, gotoHistoryFirstPage: PropTypes.func.isRequired,

@ -132,7 +132,7 @@ export const reducers = createHandleActions({
[SET_BLACKLIST_TABLE_OPTION]: createSetTableOptionReducer(section), [SET_BLACKLIST_TABLE_OPTION]: createSetTableOptionReducer(section),
[CLEAR_BLACKLIST]: createClearReducer('history', { [CLEAR_BLACKLIST]: createClearReducer(section, {
isFetching: false, isFetching: false,
isPopulated: false, isPopulated: false,
error: null, error: null,

@ -5,6 +5,7 @@ import { filterTypes, sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import { setAppValue } from 'Store/Actions/appActions'; import { setAppValue } from 'Store/Actions/appActions';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createClearReducer from './Creators/Reducers/createClearReducer';
import createFetchHandler from './Creators/createFetchHandler'; import createFetchHandler from './Creators/createFetchHandler';
import createRemoveItemHandler from './Creators/createRemoveItemHandler'; import createRemoveItemHandler from './Creators/createRemoveItemHandler';
import createHandleActions from './Creators/createHandleActions'; 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 GOTO_LOGS_PAGE = 'system/logs/gotoLogsPage';
export const SET_LOGS_SORT = 'system/logs/setLogsSort'; export const SET_LOGS_SORT = 'system/logs/setLogsSort';
export const SET_LOGS_FILTER = 'system/logs/setLogsFilter'; 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_LOG_FILES = 'system/logFiles/fetchLogFiles';
export const FETCH_UPDATE_LOG_FILES = 'system/updateLogFiles/fetchUpdateLogFiles'; 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 setLogsSort = createThunk(SET_LOGS_SORT);
export const setLogsFilter = createThunk(SET_LOGS_FILTER); export const setLogsFilter = createThunk(SET_LOGS_FILTER);
export const setLogsTableOption = createAction(SET_LOGS_TABLE_OPTION); export const setLogsTableOption = createAction(SET_LOGS_TABLE_OPTION);
export const clearLogsTable = createAction(CLEAR_LOGS_TABLE);
export const fetchLogFiles = createThunk(FETCH_LOG_FILES); export const fetchLogFiles = createThunk(FETCH_LOG_FILES);
export const fetchUpdateLogFiles = createThunk(FETCH_UPDATE_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); }, defaultState, section);

@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import withCurrentPage from 'Components/withCurrentPage';
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import * as systemActions from 'Store/Actions/systemActions'; import * as systemActions from 'Store/Actions/systemActions';
@ -32,7 +33,17 @@ class LogsTableConnector extends Component {
// Lifecycle // Lifecycle
componentDidMount() { componentDidMount() {
this.props.fetchLogs(); const {
useCurrentPage,
fetchLogs,
gotoLogsFirstPage
} = this.props;
if (useCurrentPage) {
fetchLogs();
} else {
gotoLogsFirstPage();
}
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
@ -111,6 +122,7 @@ class LogsTableConnector extends Component {
} }
LogsTableConnector.propTypes = { LogsTableConnector.propTypes = {
useCurrentPage: PropTypes.bool.isRequired,
clearLogExecuting: PropTypes.bool.isRequired, clearLogExecuting: PropTypes.bool.isRequired,
fetchLogs: PropTypes.func.isRequired, fetchLogs: PropTypes.func.isRequired,
gotoLogsFirstPage: PropTypes.func.isRequired, gotoLogsFirstPage: PropTypes.func.isRequired,
@ -124,4 +136,6 @@ LogsTableConnector.propTypes = {
executeCommand: PropTypes.func.isRequired executeCommand: PropTypes.func.isRequired
}; };
export default connect(createMapStateToProps, mapDispatchToProps)(LogsTableConnector); export default withCurrentPage(
connect(createMapStateToProps, mapDispatchToProps)(LogsTableConnector)
);

Loading…
Cancel
Save