AdGuardHome/client/src/components/Settings/Dhcp/Leases.js
Vladislav Abdulmyanov 1daabb97e5 Pull request 1775: 5581-leases-table-mobile
Updates .

Squashed commit of the following:

commit 2034c2f9c369f5e2a6e9826090fffa356fc16624
Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com>
Date:   Mon Mar 20 17:44:40 2023 +0200

    client: fix static leases

commit be509f0037af58a0e0e8c82d283b14910c20110b
Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com>
Date:   Mon Mar 20 17:23:34 2023 +0200

    client: fix leases table on mobile
2023-03-20 18:51:52 +03:00

62 lines
2 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',
minWidth: 160,
Cell: this.cellWrap,
}, {
Header: 'IP',
accessor: 'ip',
minWidth: 230,
Cell: this.cellWrap,
sortMethod: sortIp,
}, {
Header: <Trans>dhcp_table_hostname</Trans>,
accessor: 'hostname',
minWidth: 230,
Cell: this.cellWrap,
}, {
Header: <Trans>dhcp_table_expires</Trans>,
accessor: 'expires',
minWidth: 130,
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);