import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { align, icons } from 'Helpers/Props'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TablePager from 'Components/Table/TablePager'; import PageContent from 'Components/Page/PageContent'; import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; import FilterMenu from 'Components/Menu/FilterMenu'; import MenuContent from 'Components/Menu/MenuContent'; import FilterMenuItem from 'Components/Menu/FilterMenuItem'; import HistoryRowConnector from './HistoryRowConnector'; class History extends Component { // // Render render() { const { isFetching, isPopulated, error, items, columns, filterKey, filterValue, totalRecords, isEpisodesFetching, isEpisodesPopulated, episodesError, onFilterSelect, onFirstPagePress, ...otherProps } = this.props; const isFetchingAny = isFetching || isEpisodesFetching; const isAllPopulated = isPopulated && (isEpisodesPopulated || !items.length); const hasError = error || episodesError; return ( All Grabbed Imported Failed Deleted Renamed { isFetchingAny && !isAllPopulated && } { !isFetchingAny && hasError &&
Unable to load history
} { // If history isPopulated and it's empty show no history found and don't // wait for the episodes to populate because they are never coming. isPopulated && !hasError && !items.length &&
No history found
} { isAllPopulated && !hasError && !!items.length &&
{ items.map((item) => { return ( ); }) }
}
); } } History.propTypes = { isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, filterKey: PropTypes.string, filterValue: PropTypes.string, totalRecords: PropTypes.number, isEpisodesFetching: PropTypes.bool.isRequired, isEpisodesPopulated: PropTypes.bool.isRequired, episodesError: PropTypes.object, onFilterSelect: PropTypes.func.isRequired, onFirstPagePress: PropTypes.func.isRequired }; export default History;