@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React , { Component } from 'react' ;
import LoadingIndicator from 'Components/Loading/LoadingIndicator' ;
import FilterMenu from 'Components/Menu/FilterMenu' ;
import ConfirmModal from 'Components/Modal/ConfirmModal' ;
import PageContent from 'Components/Page/PageContent' ;
import PageContentBody from 'Components/Page/PageContentBody' ;
import PageToolbar from 'Components/Page/Toolbar/PageToolbar' ;
@ -11,13 +12,40 @@ import Table from 'Components/Table/Table';
import TableBody from 'Components/Table/TableBody' ;
import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper' ;
import TablePager from 'Components/Table/TablePager' ;
import { align , icons } from 'Helpers/Props' ;
import { align , icons , kinds } from 'Helpers/Props' ;
import translate from 'Utilities/String/translate' ;
import HistoryOptionsConnector from './HistoryOptionsConnector' ;
import HistoryRowConnector from './HistoryRowConnector' ;
class History extends Component {
//
// Lifecycle
constructor ( props , context ) {
super ( props , context ) ;
this . state = {
isClearHistoryModalOpen : false
} ;
}
//
// Listeners
onClearHistoryPress = ( ) => {
this . setState ( { isClearHistoryModalOpen : true } ) ;
}
onClearHistoryModalClose = ( ) => {
this . setState ( { isClearHistoryModalOpen : false } ) ;
}
onConfirmClearHistory = ( ) => {
this . setState ( { isClearHistoryModalOpen : false } ) ;
this . props . onClearHistoryPress ( ) ;
}
//
// Render
@ -25,9 +53,10 @@ class History extends Component {
const {
isFetching ,
isPopulated ,
isHistoryClearing ,
error ,
is Movie sFetching,
is Movie sPopulated,
is Indexer sFetching,
is Indexer sPopulated,
indexersError ,
items ,
columns ,
@ -36,11 +65,12 @@ class History extends Component {
totalRecords ,
onFilterSelect ,
onFirstPagePress ,
onClearHistoryPress ,
... otherProps
} = this . props ;
const isFetchingAny = isFetching || is Movie sFetching;
const isAllPopulated = isPopulated && ( is Movie sPopulated || ! items . length ) ;
const isFetchingAny = isFetching || is Indexer sFetching;
const isAllPopulated = isPopulated && ( is Indexer sPopulated || ! items . length ) ;
const hasError = error || indexersError ;
return (
@ -53,6 +83,12 @@ class History extends Component {
isSpinning = { isFetching }
onPress = { onFirstPagePress }
/ >
< PageToolbarButton
label = { translate ( 'Clear' ) }
iconName = { icons . DELETE }
isSpinning = { isHistoryClearing }
onPress = { this . onClearHistoryPress }
/ >
< / P a g e T o o l b a r S e c t i o n >
< PageToolbarSection alignContent = { align . RIGHT } >
@ -131,6 +167,16 @@ class History extends Component {
< / d i v >
}
< / P a g e C o n t e n t B o d y >
< ConfirmModal
isOpen = { this . state . isClearHistoryModalOpen }
kind = { kinds . DANGER }
title = { translate ( 'ClearHistory' ) }
message = { translate ( 'ClearHistoryMessageText' ) }
confirmLabel = { translate ( 'Delete' ) }
onConfirm = { this . onConfirmClearHistory }
onCancel = { this . onClearHistoryModalClose }
/ >
< / P a g e C o n t e n t >
) ;
}
@ -139,9 +185,10 @@ class History extends Component {
History . propTypes = {
isFetching : PropTypes . bool . isRequired ,
isPopulated : PropTypes . bool . isRequired ,
isHistoryClearing : PropTypes . bool . isRequired ,
error : PropTypes . object ,
is Movie sFetching: PropTypes . bool . isRequired ,
is Movie sPopulated: PropTypes . bool . isRequired ,
is Indexer sFetching: PropTypes . bool . isRequired ,
is Indexer sPopulated: PropTypes . bool . isRequired ,
indexersError : PropTypes . object ,
items : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
columns : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
@ -149,7 +196,8 @@ History.propTypes = {
filters : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
totalRecords : PropTypes . number ,
onFilterSelect : PropTypes . func . isRequired ,
onFirstPagePress : PropTypes . func . isRequired
onFirstPagePress : PropTypes . func . isRequired ,
onClearHistoryPress : PropTypes . func . isRequired
} ;
export default History ;