Skip to content

cleanup: Remove "inline" pagination #2458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions app/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import {

const Tunnel = tunnel('pagination')

interface PaginationProps extends UIPaginationProps {
/** If true pagination will be rendered wherever `Pagination.Target` is included */
inline?: boolean
}
export function Pagination({ inline = false, ...props }: PaginationProps) {
if (inline) return <UIPagination {...props} />

export function Pagination(props: UIPaginationProps) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline was never true here. The only callsite is in QueryTable, which defaults to page and was never overridden.

return (
<Tunnel.In>
<UIPagination className="gutter h-14 py-5" {...props} />
Expand Down
2 changes: 1 addition & 1 deletion app/layouts/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ContentPane() {
<Outlet />
</main>
</div>
<div className="sticky bottom-0 shrink-0 justify-between overflow-hidden border-t bg-default border-secondary empty:border-t-0">
<div className="sticky bottom-0 z-topBar shrink-0 justify-between overflow-hidden border-t bg-default border-secondary empty:border-t-0">
<Pagination.Target />
<PageActionsTarget />
</div>
Expand Down
4 changes: 0 additions & 4 deletions app/table/QueryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export const useQueryTable = <A extends ApiListMethods, M extends keyof A>(
type QueryTableProps<Item> = {
/** Prints table data in the console when enabled */
debug?: boolean
/** Function that produces a list of actions from a row item */
pagination?: 'inline' | 'page'
pageSize?: number
rowHeight?: 'small' | 'large'
emptyState: React.ReactElement
Expand All @@ -71,7 +69,6 @@ const makeQueryTable = <Item extends Record<string, unknown>>(
): ComponentType<QueryTableProps<Item>> =>
function QueryTable({
debug,
pagination = 'page',
pageSize = PAGE_SIZE,
rowHeight = 'small',
emptyState,
Expand Down Expand Up @@ -115,7 +112,6 @@ const makeQueryTable = <Item extends Record<string, unknown>>(
<>
<Table table={table} rowHeight={rowHeight} />
<Pagination
inline={pagination === 'inline'}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always false because pagination defaults to "page" and we never set the prop explicitly.

pageSize={pageSize}
hasNext={tableData.length === pageSize}
hasPrev={hasPrev}
Expand Down
3 changes: 0 additions & 3 deletions app/ui/lib/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const PageInput = ({ number, className }: PageInputProps) => {
}

export interface PaginationProps {
type?: 'inline' | 'page'
pageSize: number
hasNext: boolean
hasPrev: boolean
Expand All @@ -37,7 +36,6 @@ export interface PaginationProps {
className?: string
}
export const Pagination = ({
type = 'inline',
pageSize,
hasNext,
hasPrev,
Expand All @@ -50,7 +48,6 @@ export const Pagination = ({
<>
<div
className={cn(
type === 'page' && 'py-5',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the weird bit. In all the calling code above this, we were always page, never inline, but because this defaults to inline, we take this bit out.

'flex items-center justify-between text-mono-sm text-default bg-default',
className
)}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/snapshots.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ test('Confirm delete snapshot', async ({ page }) => {

const row = page.getByRole('row', { name: 'disk-1-snapshot-6' })

// scroll a little so the dropdown menu isn't behind the pagination bar
await page.getByRole('table').click() // focus the content pane
await page.mouse.wheel(0, 200)

async function clickDelete() {
await row.getByRole('button', { name: 'Row actions' }).click()
await page.getByRole('menuitem', { name: 'Delete' }).click()
Expand Down
Loading