Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: add '100' pagination option (#2208)
Kyle Mendellbfc13d9e7ada
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-pagination.svelte b/frontend/src/lib/components/arcane-table/arcane-table-pagination.svelteindex 8e94d961e..0a21829ee 100644--- a/frontend/src/lib/components/arcane-table/arcane-table-pagination.svelte+++ b/frontend/src/lib/components/arcane-table/arcane-table-pagination.svelte@@ -4,6 +4,7 @@import * as Select from '$lib/components/ui/select/index.js';import { m } from '$lib/paraglide/messages';import { ArrowRightIcon, ArrowLeftIcon, DoubleArrowRightIcon, DoubleArrowLeftIcon } from '$lib/icons';+ import { TABLE_PAGE_SIZE_ALL, TABLE_PAGE_SIZE_OPTIONS } from '$lib/constants/table-pagination';import type { Paginated } from '$lib/types/pagination.type';let {@@ -29,14 +30,13 @@setPageSize: (limit: number) => void;} = $props();- const pageSizeOptions = [10, 20, 30, 40, 50];- const isAllSelected = $derived(pageSize === -1);+ const isAllSelected = $derived(pageSize === TABLE_PAGE_SIZE_ALL);const displayValue = $derived(isAllSelected ? m.common_all() : String(pageSize));const selectValue = $derived(isAllSelected ? 'all' : String(pageSize));function handlePageSizeChange(value: string) {if (value === 'all') {- setPageSize(-1);+ setPageSize(TABLE_PAGE_SIZE_ALL);} else {setPageSize(Number(value));}@@ -55,7 +55,7 @@{displayValue}</Select.Trigger><Select.Content side="top">- {#each pageSizeOptions as size (size)}+ {#each TABLE_PAGE_SIZE_OPTIONS as size (size)}<Select.Item value={`${size}`}>{size}</Select.Item>diff --git a/frontend/src/lib/constants/table-pagination.ts b/frontend/src/lib/constants/table-pagination.tsnew file mode 100644index 000000000..dc633cdd2--- /dev/null+++ b/frontend/src/lib/constants/table-pagination.ts@@ -0,0 +1,2 @@+export const TABLE_PAGE_SIZE_ALL = -1;+export const TABLE_PAGE_SIZE_OPTIONS = [10, 20, 30, 40, 50, 100] as const;diff --git a/frontend/src/lib/utils/table-pagination.util.ts b/frontend/src/lib/utils/table-pagination.util.tsnew file mode 100644index 000000000..6c85eccf0--- /dev/null+++ b/frontend/src/lib/utils/table-pagination.util.ts@@ -0,0 +1,9 @@+import { TABLE_PAGE_SIZE_ALL, TABLE_PAGE_SIZE_OPTIONS } from '$lib/constants/table-pagination';++export function normalizeTablePageSize(limit: unknown): number | undefined {+ const parsed = typeof limit === 'number' ? limit : Number.parseInt(String(limit), 10);++ if (!Number.isFinite(parsed)) return undefined;+ if (parsed === TABLE_PAGE_SIZE_ALL) return parsed;+ return TABLE_PAGE_SIZE_OPTIONS.includes(parsed as (typeof TABLE_PAGE_SIZE_OPTIONS)[number]) ? parsed : undefined;+}diff --git a/frontend/src/lib/utils/table-persistence.util.ts b/frontend/src/lib/utils/table-persistence.util.tsindex 46065c426..a7cbe1e1d 100644--- a/frontend/src/lib/utils/table-persistence.util.ts+++ b/frontend/src/lib/utils/table-persistence.util.ts@@ -2,6 +2,7 @@ import { browser } from '$app/environment';import { PersistedState } from 'runed';import { decodeSort, type CompactTablePrefs } from '$lib/components/arcane-table/arcane-table.types.svelte';import type { FilterMap, FilterValue, SearchPaginationSortRequest } from '$lib/types/pagination.type';+import { normalizeTablePageSize } from '$lib/utils/table-pagination.util';const DEFAULT_LIMIT = 20;@@ -46,15 +47,6 @@ function buildFilterMap(pairs?: [string, unknown][]): FilterMap {return filters;}-function normalizeLimit(limit: unknown): number | undefined {- if (typeof limit === 'number' && Number.isFinite(limit) && limit > 0) return limit;- if (typeof limit === 'string') {- const parsed = Number.parseInt(limit, 10);- if (Number.isFinite(parsed) && parsed > 0) return parsed;- }- return undefined;-}-function normalizeSearch(value: unknown): string | undefined {if (typeof value !== 'string') return undefined;const trimmed = value.trim();@@ -99,7 +91,7 @@ export function resolveInitialTableRequest(base.pagination = { ...base.pagination!, page: 1 };}- const limit = normalizeLimit(current.l);+ const limit = normalizeTablePageSize(current.l);if (limit !== undefined && base.pagination?.limit !== limit) {base.pagination = { page: 1, limit };}