import React from 'react'
import PropTypes from 'prop-types'
import { translate, Interpolate } from 'react-i18next'
import Table from '../../../../common/Table/Table'
import CheckboxCell from '../../../../common/Table/CheckboxCell'
import SortableTh from '../../../../common/Table/SortableTh'
import SourceIndexInfoPopup from './SourceIndexInfoPopup'
import { Button } from 'reactstrap'
import { getTitle } from '../../../../../common/helper'
export class SourceIndexTable extends React.Component {
static propTypes = {
t: PropTypes.func.isRequired,
tableState: PropTypes.object.isRequired,
type: PropTypes.string.isRequired,
onFetch: PropTypes.func.isRequired,
onDeleteIndex: PropTypes.func,
actions: PropTypes.object.isRequired
};
onFetch = (page, pageSize, sorted) => {
const { tableState, onFetch } = this.props
const params = {
page: page + 1,
limit: pageSize,
query: tableState.searchQuery
}
if (sorted.length) {
const sortedField = sorted[0]
const sort = {
field: sortedField.id,
direction: sortedField.desc ? 'desc' : 'asc'
}
params['sort'] = sort
}
onFetch(params)
};
selectAllAction = (event) => {
const { actions } = this.props
actions.toggleAllSourceIndexes()
};
selectRowAction = (itemId) => {
const { actions } = this.props
actions.toggleSourceIndex(itemId) // TODO
};
showUpdateSourcePopup = (source) => (e) => {
e.preventDefault()
this.props.actions.showUpdateSourcePopup(source)
};
deleteSourceIndex = (source) => (e) => {
e.preventDefault()
this.props.onDeleteIndex(source)
};
toggleInfoPopup = (source) => () => {
const { type, actions } = this.props
actions.toggleInfoSourcePopup(type, source)
};
getColumns = () => {
const {t, type, tableState} = this.props
let columns = [
{
id: 'selectCheckbox',
accessor: '',
sortable: false,
width: 45,
className: 'cw-center-cell',
headerClassName: 'cw-center-cell',
Header: () => {
return (