import React from 'react' import PropTypes from 'prop-types' import { translate } from 'react-i18next' import SourceIndexTable from './SourceIndexTable' import SourceIndexUpdatePopup from './SourceIndexUpdatePopup' import FiltersTable from '../../../../common/FiltersTable/FiltersTable' import { withRouter } from 'react-router-dom' import reduxConnect from '../../../../../redux/utils/connect' import { compose } from 'redux' import { Button, ButtonGroup, Input, InputGroup, InputGroupAddon } from 'reactstrap' import { setDocumentData } from '../../../../../common/helper' class SourceIndexSubTab extends React.Component { static propTypes = { sourcesState: PropTypes.object.isRequired, actions: PropTypes.object.isRequired, t: PropTypes.func.isRequired }; componentDidMount() { setDocumentData('title', 'Source Index | Search') } componentWillUnmount() { setDocumentData('title') } _sourceIndexesState = () => this.props.sourcesState.sourceIndexesState; _sourceLists = () => this.props.sourcesState.sourceListsState.data; loadSourceIndexes = (params) => { this.props.actions.getSourceIndexes(params || null) }; onSearchSources = () => { this.loadSourceIndexes() }; onEnterSearchInput = (e) => { if (e.keyCode === 13) this.loadSourceIndexes() }; onChangeSearchInput = (e) => { this.props.actions.setSourceIndexSearchQuery(e.target.value) }; onFetchData = (params) => { this.loadSourceIndexes(params) }; showAddToListPopup = () => { const { actions } = this.props const sourceIndexesState = this._sourceIndexesState() if (sourceIndexesState.selectedIds.length === 0) { actions.addAlert({ type: 'notice', transKey: 'noListsSelected', id: 'noListsSelected' }) return false } actions.toggleAddSourceToListPopup() }; onSelectFilter = (groupName, filterValue) => { this.props.actions.selectSourcesFilter(groupName, filterValue) }; onClearFilters = (groupName) => { this.props.actions.clearSourcesFilters(groupName) }; onClearAllFilters = () => { this.props.actions.clearAllSourcesFilters() }; onMoreFilters = (groupName) => { this.props.actions.loadMoreSourcesFilters(groupName) }; onLessFilters = (groupName) => { this.props.actions.loadLessSourcesFilters(groupName) }; render () { const { t, actions } = this.props const sourceIndexesState = this._sourceIndexesState() const sourceLists = this._sourceLists() const { searchQuery, selectedIds, chosenListsToAddSources, chosenSourceToUpdate, advancedFilters } = sourceIndexesState return (
{sourceIndexesState.isAddPopupVisible && ( )} {sourceIndexesState.isUpdatePopupVisible && ( )}
) } } const applyDecorators = compose( withRouter, reduxConnect('sourcesState', ['appState', 'sourcesState']), translate(['tabsContent'], { wait: true }) ) export default applyDecorators(SourceIndexSubTab)