mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
* add prettier and have it format all js code except website: : * trying running prettier check in CI * fix runs on in CI * change CI job name * fix prettier erros and fix CI
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import React, { PureComponent } from "react";
|
|
import PropTypes from "prop-types";
|
|
|
|
import Button from "components/buttons/Button";
|
|
import KolideIcon from "components/icons/KolideIcon";
|
|
|
|
const baseClass = "pagination";
|
|
|
|
class Pagination extends PureComponent {
|
|
static propTypes = {
|
|
currentPage: PropTypes.number,
|
|
resultsPerPage: PropTypes.number,
|
|
onPaginationChange: PropTypes.func,
|
|
resultsOnCurrentPage: PropTypes.number,
|
|
};
|
|
|
|
disablePrev = () => {
|
|
return this.props.currentPage === 0;
|
|
};
|
|
|
|
disableNext = () => {
|
|
// NOTE: not sure why resultsOnCurrentPage is getting assigned undefined.
|
|
// but this seems to work when there is no data in the table.
|
|
return (
|
|
this.props.resultsOnCurrentPage === undefined ||
|
|
this.props.resultsOnCurrentPage < this.props.resultsPerPage
|
|
);
|
|
};
|
|
|
|
render() {
|
|
const { currentPage, onPaginationChange } = this.props;
|
|
|
|
return (
|
|
<div className={`${baseClass}__pager-wrap`}>
|
|
<Button
|
|
variant="unstyled"
|
|
disabled={this.disablePrev()}
|
|
onClick={() => onPaginationChange(currentPage - 1)}
|
|
>
|
|
<KolideIcon name="chevronleft" /> Prev
|
|
</Button>
|
|
<Button
|
|
variant="unstyled"
|
|
disabled={this.disableNext()}
|
|
onClick={() => onPaginationChange(currentPage + 1)}
|
|
>
|
|
Next <KolideIcon name="chevronright" />
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Pagination;
|