Skip to content

Commit

Permalink
simplify pagination buttons
Browse files Browse the repository at this point in the history
- no custom css
- put click events on buttons instead of labels
- use standard disabled state instead of custom cursor, grey text
  • Loading branch information
minrk committed Sep 13, 2024
1 parent 6ccb809 commit 86e4f42
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 43 deletions.
54 changes: 32 additions & 22 deletions jsx/src/components/PaginationFooter/PaginationFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from "react";
import PropTypes from "prop-types";
import { Button, FormControl } from "react-bootstrap";

import "./pagination-footer.css";

const PaginationFooter = (props) => {
const { offset, limit, visible, total, next, prev, handleLimit } = props;
return (
Expand All @@ -13,33 +11,45 @@ const PaginationFooter = (props) => {
{total ? `of ${total}` : ""}
<br />
{offset >= 1 ? (
<Button variant="light" size="sm">
<span
className="active-pagination"
data-testid="paginate-prev"
onClick={prev}
>
Previous
</span>
<Button
variant="light"
size="sm"
onClick={prev}
className="me-2"
data-testid="paginate-prev"
>
Previous
</Button>
) : (
<Button variant="light" size="sm">
<span className="inactive-pagination">Previous</span>
<Button
variant="light"
size="sm"
className="me-2"
disabled
aria-disabled="true"
>
Previous
</Button>
)}
{offset + visible < total ? (
<Button variant="light" size="sm">
<span
className="active-pagination"
data-testid="paginate-next"
onClick={next}
>
Next
</span>
<Button
variant="light"
size="sm"
className="me-2"
onClick={next}
data-testid="paginate-next"
>
Next
</Button>
) : (
<Button variant="light" size="sm">
<span className="inactive-pagination">Next</span>
<Button
variant="light"
size="sm"
className="me-2"
disabled
aria-disabled="true"
>
Next
</Button>
)}
<label>
Expand Down
14 changes: 0 additions & 14 deletions jsx/src/components/PaginationFooter/pagination-footer.css

This file was deleted.

12 changes: 5 additions & 7 deletions jupyterhub/tests/browser/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ async def test_paging_on_admin_page(
re.compile(".*" + f"1-{min(users_count_db, 50)}" + ".*")
)
if users_count_db > 50:
await expect(btn_next.locator("//span")).to_have_class("active-pagination")
await expect(btn_next).to_be_enabled()
# click on Next button
await btn_next.click()
if users_count_db <= 100:
Expand All @@ -1195,15 +1195,13 @@ async def test_paging_on_admin_page(
)
else:
await expect(displaying).to_have_text(re.compile(".*" + "51-100" + ".*"))
await expect(btn_next.locator("//span")).to_have_class("active-pagination")
await expect(btn_previous.locator("//span")).to_have_class("active-pagination")
await expect(btn_next).to_be_enabled()
await expect(btn_previous).to_be_enabled()
# click on Previous button
await btn_previous.click()
else:
await expect(btn_next.locator("//span")).to_have_class("inactive-pagination")
await expect(btn_previous.locator("//span")).to_have_class(
"inactive-pagination"
)
await expect(btn_next).to_be_disabled()
await expect(btn_previous).to_be_disabled()


@pytest.mark.parametrize(
Expand Down

0 comments on commit 86e4f42

Please sign in to comment.