Close #1778 Squashed commit of the following: commit ba63e147311799b17deaa97d7a12c2e0ec44a2ed Merge: 143ba427705a9d90
Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Aug 13 12:00:10 2020 +0300 Merge branch 'master' into feature/1778 commit 143ba42707da3d7eece9f3e137a8b245f7f7888f Merge: 483d2ff997df1989
Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Aug 13 11:16:46 2020 +0300 Merge branch 'master' into feature/1778 commit 483d2ff9fa3de706d94a647701f1d26a3bcbb217 Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Aug 12 13:34:21 2020 +0300 Always put ipv4 before ipv6 in sort, add invalid input unit tests commit 26eb41b313785fe7ffaf98a7573cc5eef0dca14f Author: ArtemBaskal <a.baskal@adguard.com> Date: Wed Aug 12 11:27:46 2020 +0300 Rewrite tests: replace ipv4-mapped adresses commit 4ecf287fd46945effe9ff11cfc9ae49217b9c796 Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Aug 11 19:05:15 2020 +0300 Minor fix commit 3e5e2a6bb1f2f166619da54e5ade0904fe22a20d Author: ArtemBaskal <a.baskal@adguard.com> Date: Tue Aug 11 19:01:26 2020 +0300 + client: 1778 Add ip sort function, write unit tests
59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import ReactTable from 'react-table';
|
|
import { Trans, withTranslation } from 'react-i18next';
|
|
import { LEASES_TABLE_DEFAULT_PAGE_SIZE } from '../../../helpers/constants';
|
|
import { sortIp } from '../../../helpers/helpers';
|
|
|
|
class Leases extends Component {
|
|
cellWrap = ({ value }) => (
|
|
<div className="logs__row o-hidden">
|
|
<span className="logs__text" title={value}>
|
|
{value}
|
|
</span>
|
|
</div>
|
|
);
|
|
|
|
render() {
|
|
const { leases, t } = this.props;
|
|
return (
|
|
<ReactTable
|
|
data={leases || []}
|
|
columns={[
|
|
{
|
|
Header: 'MAC',
|
|
accessor: 'mac',
|
|
Cell: this.cellWrap,
|
|
}, {
|
|
Header: 'IP',
|
|
accessor: 'ip',
|
|
Cell: this.cellWrap,
|
|
sortMethod: sortIp,
|
|
}, {
|
|
Header: <Trans>dhcp_table_hostname</Trans>,
|
|
accessor: 'hostname',
|
|
Cell: this.cellWrap,
|
|
}, {
|
|
Header: <Trans>dhcp_table_expires</Trans>,
|
|
accessor: 'expires',
|
|
Cell: this.cellWrap,
|
|
},
|
|
]}
|
|
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,
|
|
};
|
|
|
|
export default withTranslation()(Leases);
|