import React, { Component } from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ReactTable from 'react-table'; import { Trans, withTranslation } from 'react-i18next'; import { LEASES_TABLE_DEFAULT_PAGE_SIZE, MODAL_TYPE } from '../../../helpers/constants'; import { sortIp } from '../../../helpers/helpers'; import { toggleLeaseModal } from '../../../actions'; class Leases extends Component { cellWrap = ({ value }) => (
{value}
); convertToStatic = (data) => () => { const { dispatch } = this.props; dispatch(toggleLeaseModal({ type: MODAL_TYPE.ADD_LEASE, config: data, })); } makeStatic = ({ row }) => { const { t, disabledLeasesButton } = this.props; return (
); } render() { const { leases, t } = this.props; return ( dhcp_table_hostname, accessor: 'hostname', minWidth: 230, Cell: this.cellWrap, }, { Header: dhcp_table_expires, accessor: 'expires', minWidth: 220, Cell: this.cellWrap, }, { Header: actions_table_header, Cell: this.makeStatic, }, ]} pageSize={LEASES_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={leases.length > LEASES_TABLE_DEFAULT_PAGE_SIZE} noDataText={t('dhcp_leases_not_found')} minRows={6} className="-striped -highlight card-table-overflow" /> ); } } Leases.propTypes = { leases: PropTypes.array, t: PropTypes.func, dispatch: PropTypes.func, disabledLeasesButton: PropTypes.bool, }; export default withTranslation()(connect(() => ({}), (dispatch) => ({ dispatch }))(Leases));