@@ -16,7 +16,11 @@ import {
16
16
import { type Theme } from "@mui/material/styles" ;
17
17
import { parse } from "date-fns" ;
18
18
19
- import { formatDate , formatDay , formatDuration } from "../../lib/utils" ;
19
+ import {
20
+ formatDate ,
21
+ formatDuration ,
22
+ getUrl ,
23
+ } from "../../lib/utils" ;
20
24
import IconLink from "../../components/IconLink" ;
21
25
import type {
22
26
Run ,
@@ -27,15 +31,12 @@ import {
27
31
RunResultKeys ,
28
32
RunStatuses ,
29
33
} from "../../lib/paddles.d" ;
34
+ import {
35
+ DEFAULT_PAGE_SIZE
36
+ } from "#src/lib/paddles" ;
30
37
import useDefaultTableOptions from "../../lib/table" ;
31
38
32
39
33
- const DEFAULT_PAGE_SIZE = 25 ;
34
- const NON_FILTER_PARAMS = [
35
- "page" ,
36
- "pageSize" ,
37
- ] ;
38
-
39
40
const _columns : MRT_ColumnDef < Run > [ ] = [
40
41
{
41
42
accessorKey : "name" ,
@@ -191,22 +192,6 @@ type RunListProps = {
191
192
tableOptions ?: Partial < MRT_TableOptions < Run > > ;
192
193
}
193
194
194
- function getUrl ( path : string , filters : MRT_ColumnFiltersState , pagination : MRT_PaginationState ) {
195
- const newUrl = new URL ( path , window . location . origin ) ;
196
- filters . forEach ( item => {
197
- if ( ! item . id ) return ;
198
- if ( item . value instanceof Function ) return ;
199
- if ( item . value instanceof Date ) {
200
- newUrl . searchParams . set ( "date" , formatDay ( item . value ) ) ;
201
- } else {
202
- newUrl . searchParams . set ( String ( item . id ) , String ( item . value ) ) ;
203
- }
204
- } ) ;
205
- if ( pagination . pageIndex ) newUrl . searchParams . set ( "page" , String ( pagination . pageIndex ) ) ;
206
- if ( pagination . pageSize != DEFAULT_PAGE_SIZE ) newUrl . searchParams . set ( "pageSize" , String ( pagination . pageSize ) ) ;
207
- return newUrl ;
208
- }
209
-
210
195
export default function RunList ( props : RunListProps ) {
211
196
const context = usePageContext ( ) ;
212
197
const { params, tableOptions } = props ;
@@ -215,7 +200,7 @@ export default function RunList(props: RunListProps) {
215
200
const columnFilters : MRT_ColumnFiltersState = [ ] ;
216
201
Object . entries ( debouncedParams ) . forEach ( param => {
217
202
const [ id , value ] = param ;
218
- if ( NON_FILTER_PARAMS . includes ( id ) ) return ;
203
+ if ( [ "page" , "pageSize" ] . includes ( id ) ) return ;
219
204
if ( id === "date" && ! ! value ) {
220
205
columnFilters . push ( {
221
206
id : "scheduled" ,
0 commit comments