@ -4,34 +4,34 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect' ;
import * as commandNames from 'Commands/commandNames' ;
import withCurrentPage from 'Components/withCurrentPage' ;
import * as bl acklistActions from 'Store/Actions/bla cklistActions';
import * as bl ocklistActions from 'Store/Actions/blo cklistActions';
import { executeCommand } from 'Store/Actions/commandActions' ;
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector' ;
import { registerPagePopulator , unregisterPagePopulator } from 'Utilities/pagePopulator' ;
import Bl acklist from './Bla cklist';
import Bl ocklist from './Blo cklist';
function createMapStateToProps ( ) {
return createSelector (
( state ) => state . bl a cklist,
( state ) => state . bl o cklist,
( state ) => state . artist ,
createCommandExecutingSelector ( commandNames . CLEAR _BL A CKLIST) ,
( bl acklist, artist , isClearingBla cklistExecuting) => {
createCommandExecutingSelector ( commandNames . CLEAR _BL O CKLIST) ,
( bl ocklist, artist , isClearingBlo cklistExecuting) => {
return {
isArtistFetching : artist . isFetching ,
isArtistPopulated : artist . isPopulated ,
isClearingBl a cklistExecuting,
... bl a cklist
isClearingBl o cklistExecuting,
... bl o cklist
} ;
}
) ;
}
const mapDispatchToProps = {
... bl a cklistActions,
... bl o cklistActions,
executeCommand
} ;
class Bl a cklistConnector extends Component {
class Bl o cklistConnector extends Component {
//
// Lifecycle
@ -39,27 +39,27 @@ class BlacklistConnector extends Component {
componentDidMount ( ) {
const {
useCurrentPage ,
fetchBl a cklist,
gotoBl a cklistFirstPage
fetchBl o cklist,
gotoBl o cklistFirstPage
} = this . props ;
registerPagePopulator ( this . repopulate ) ;
if ( useCurrentPage ) {
fetchBl a cklist( ) ;
fetchBl o cklist( ) ;
} else {
gotoBl a cklistFirstPage( ) ;
gotoBl o cklistFirstPage( ) ;
}
}
componentDidUpdate ( prevProps ) {
if ( prevProps . isClearingBl a cklistExecuting && ! this . props . isClearingBl a cklistExecuting) {
this . props . gotoBl a cklistFirstPage( ) ;
if ( prevProps . isClearingBl o cklistExecuting && ! this . props . isClearingBl o cklistExecuting) {
this . props . gotoBl o cklistFirstPage( ) ;
}
}
componentWillUnmount ( ) {
this . props . clearBl a cklist( ) ;
this . props . clearBl o cklist( ) ;
unregisterPagePopulator ( this . repopulate ) ;
}
@ -67,49 +67,49 @@ class BlacklistConnector extends Component {
// Control
repopulate = ( ) => {
this . props . fetchBl a cklist( ) ;
this . props . fetchBl o cklist( ) ;
}
//
// Listeners
onFirstPagePress = ( ) => {
this . props . gotoBl a cklistFirstPage( ) ;
this . props . gotoBl o cklistFirstPage( ) ;
}
onPreviousPagePress = ( ) => {
this . props . gotoBl a cklistPreviousPage( ) ;
this . props . gotoBl o cklistPreviousPage( ) ;
}
onNextPagePress = ( ) => {
this . props . gotoBl a cklistNextPage( ) ;
this . props . gotoBl o cklistNextPage( ) ;
}
onLastPagePress = ( ) => {
this . props . gotoBl a cklistLastPage( ) ;
this . props . gotoBl o cklistLastPage( ) ;
}
onPageSelect = ( page ) => {
this . props . gotoBl a cklistPage( { page } ) ;
this . props . gotoBl o cklistPage( { page } ) ;
}
onRemoveSelected = ( ids ) => {
this . props . removeBl a cklistItems( { ids } ) ;
this . props . removeBl o cklistItems( { ids } ) ;
}
onSortPress = ( sortKey ) => {
this . props . setBl a cklistSort( { sortKey } ) ;
this . props . setBl o cklistSort( { sortKey } ) ;
}
onTableOptionChange = ( payload ) => {
this . props . setBl a cklistTableOption( payload ) ;
this . props . setBl o cklistTableOption( payload ) ;
if ( payload . pageSize ) {
this . props . gotoBl a cklistFirstPage( ) ;
this . props . gotoBl o cklistFirstPage( ) ;
}
}
onClearBl a cklistPress = ( ) => {
this . props . executeCommand ( { name : commandNames . CLEAR _BL A CKLIST } ) ;
onClearBl o cklistPress = ( ) => {
this . props . executeCommand ( { name : commandNames . CLEAR _BL O CKLIST } ) ;
}
//
@ -117,7 +117,7 @@ class BlacklistConnector extends Component {
render ( ) {
return (
< Bl a cklist
< Bl o cklist
onFirstPagePress = { this . onFirstPagePress }
onPreviousPagePress = { this . onPreviousPagePress }
onNextPagePress = { this . onNextPagePress }
@ -126,30 +126,30 @@ class BlacklistConnector extends Component {
onRemoveSelected = { this . onRemoveSelected }
onSortPress = { this . onSortPress }
onTableOptionChange = { this . onTableOptionChange }
onClearBl acklistPress= { this . onClearBla cklistPress}
onClearBl ocklistPress= { this . onClearBlo cklistPress}
{ ... this . props }
/ >
) ;
}
}
Bl a cklistConnector. propTypes = {
Bl o cklistConnector. propTypes = {
useCurrentPage : PropTypes . bool . isRequired ,
isClearingBl a cklistExecuting: PropTypes . bool . isRequired ,
isClearingBl o cklistExecuting: PropTypes . bool . isRequired ,
items : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
fetchBl a cklist: PropTypes . func . isRequired ,
gotoBl a cklistFirstPage: PropTypes . func . isRequired ,
gotoBl a cklistPreviousPage: PropTypes . func . isRequired ,
gotoBl a cklistNextPage: PropTypes . func . isRequired ,
gotoBl a cklistLastPage: PropTypes . func . isRequired ,
gotoBl a cklistPage: PropTypes . func . isRequired ,
removeBl a cklistItems: PropTypes . func . isRequired ,
setBl a cklistSort: PropTypes . func . isRequired ,
setBl a cklistTableOption: PropTypes . func . isRequired ,
clearBl a cklist: PropTypes . func . isRequired ,
fetchBl o cklist: PropTypes . func . isRequired ,
gotoBl o cklistFirstPage: PropTypes . func . isRequired ,
gotoBl o cklistPreviousPage: PropTypes . func . isRequired ,
gotoBl o cklistNextPage: PropTypes . func . isRequired ,
gotoBl o cklistLastPage: PropTypes . func . isRequired ,
gotoBl o cklistPage: PropTypes . func . isRequired ,
removeBl o cklistItems: PropTypes . func . isRequired ,
setBl o cklistSort: PropTypes . func . isRequired ,
setBl o cklistTableOption: PropTypes . func . isRequired ,
clearBl o cklist: PropTypes . func . isRequired ,
executeCommand : PropTypes . func . isRequired
} ;
export default withCurrentPage (
connect ( createMapStateToProps , mapDispatchToProps ) ( Bl a cklistConnector)
connect ( createMapStateToProps , mapDispatchToProps ) ( Bl o cklistConnector)
) ;