17
17
* License-Filename: LICENSE
18
18
*/
19
19
20
- import { useQueryClient } from '@tanstack/react-query' ;
20
+ import {
21
+ useMutation ,
22
+ useQuery ,
23
+ useQueryClient ,
24
+ useSuspenseQuery ,
25
+ } from '@tanstack/react-query' ;
21
26
import { Link } from '@tanstack/react-router' ;
22
27
import {
23
28
createColumnHelper ,
@@ -26,13 +31,7 @@ import {
26
31
} from '@tanstack/react-table' ;
27
32
import { Repeat , View } from 'lucide-react' ;
28
33
29
- import {
30
- useRepositoriesServiceDeleteApiV1RepositoriesByRepositoryIdRunsByOrtRunIndex ,
31
- useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdRuns ,
32
- useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdRunsKey ,
33
- } from '@/api/queries' ;
34
- import { useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdSuspense } from '@/api/queries/suspense' ;
35
- import { ApiError , OrtRunSummary } from '@/api/requests' ;
34
+ import { ApiError } from '@/api/requests' ;
36
35
import { DataTable } from '@/components/data-table/data-table' ;
37
36
import { DeleteDialog } from '@/components/delete-dialog' ;
38
37
import { DeleteIconButton } from '@/components/delete-icon-button' ;
@@ -50,6 +49,13 @@ import {
50
49
} from '@/components/ui/tooltip' ;
51
50
import { config } from '@/config' ;
52
51
import { getStatusBackgroundColor } from '@/helpers/get-status-class' ;
52
+ import { OrtRunSummary } from '@/hey-api' ;
53
+ import {
54
+ deleteOrtRunByIndexMutation ,
55
+ getOrtRunsByRepositoryIdOptions ,
56
+ getOrtRunsByRepositoryIdQueryKey ,
57
+ getRepositoryByIdOptions ,
58
+ } from '@/hey-api/@tanstack/react-query.gen' ;
53
59
import { toast } from '@/lib/toast' ;
54
60
import { useTablePrefsStore } from '@/store/table-prefs.store' ;
55
61
@@ -158,41 +164,46 @@ const columns = [
158
164
cell : function Row ( { row } ) {
159
165
const queryClient = useQueryClient ( ) ;
160
166
161
- const repository =
162
- useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdSuspense ( {
163
- repositoryId : row . original . repositoryId ,
164
- } ) ;
167
+ const repository = useSuspenseQuery ( {
168
+ ...getRepositoryByIdOptions ( {
169
+ path : {
170
+ repositoryId : row . original . repositoryId ,
171
+ } ,
172
+ } ) ,
173
+ } ) ;
165
174
166
- const { mutateAsync : deleteRun } =
167
- useRepositoriesServiceDeleteApiV1RepositoriesByRepositoryIdRunsByOrtRunIndex (
168
- {
169
- onSuccess ( ) {
170
- toast . info ( 'Delete Run' , {
171
- description : `Run "${ row . original . index } " deleted successfully.` ,
172
- } ) ;
173
- queryClient . invalidateQueries ( {
174
- queryKey : [
175
- useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdRunsKey ,
176
- ] ,
177
- } ) ;
178
- } ,
179
- onError ( error : ApiError ) {
180
- toast . error ( error . message , {
181
- description : < ToastError error = { error } /> ,
182
- duration : Infinity ,
183
- cancel : {
184
- label : 'Dismiss' ,
185
- onClick : ( ) => { } ,
186
- } ,
187
- } ) ;
175
+ const { mutateAsync : deleteRun } = useMutation ( {
176
+ ...deleteOrtRunByIndexMutation ( ) ,
177
+ onSuccess ( ) {
178
+ toast . info ( 'Delete Run' , {
179
+ description : `Run "${ row . original . index } " deleted successfully.` ,
180
+ } ) ;
181
+ queryClient . invalidateQueries ( {
182
+ queryKey : getOrtRunsByRepositoryIdQueryKey ( {
183
+ path : {
184
+ repositoryId : row . original . repositoryId ,
185
+ } ,
186
+ } ) ,
187
+ } ) ;
188
+ } ,
189
+ onError ( error : ApiError ) {
190
+ toast . error ( error . message , {
191
+ description : < ToastError error = { error } /> ,
192
+ duration : Infinity ,
193
+ cancel : {
194
+ label : 'Dismiss' ,
195
+ onClick : ( ) => { } ,
188
196
} ,
189
- }
190
- ) ;
197
+ } ) ;
198
+ } ,
199
+ } ) ;
191
200
192
201
async function handleDelete ( ) {
193
202
await deleteRun ( {
194
- ortRunIndex : row . original . index ,
195
- repositoryId : row . original . repositoryId ,
203
+ path : {
204
+ ortRunIndex : row . original . index ,
205
+ repositoryId : row . original . repositoryId ,
206
+ } ,
196
207
} ) ;
197
208
}
198
209
@@ -264,23 +275,21 @@ export const RepositoryRunsTable = ({
264
275
search,
265
276
} : RepositoryTableProps ) => {
266
277
const setRunPageSize = useTablePrefsStore ( ( state ) => state . setRunPageSize ) ;
278
+
267
279
const {
268
280
data : runs ,
269
281
error : runsError ,
270
282
isPending : runsIsPending ,
271
283
isError : runsIsError ,
272
- } = useRepositoriesServiceGetApiV1RepositoriesByRepositoryIdRuns (
273
- {
274
- repositoryId : Number . parseInt ( repoId ) ,
275
- limit : pageSize ,
276
- offset : pageIndex * pageSize ,
277
- sort : '-index' ,
278
- } ,
279
- undefined ,
280
- {
281
- refetchInterval : pollInterval ,
282
- }
283
- ) ;
284
+ } = useQuery ( {
285
+ ...getOrtRunsByRepositoryIdOptions ( {
286
+ path : {
287
+ repositoryId : Number . parseInt ( repoId ) ,
288
+ } ,
289
+ query : { limit : pageSize , offset : pageIndex * pageSize , sort : '-index' } ,
290
+ } ) ,
291
+ refetchInterval : pollInterval ,
292
+ } ) ;
284
293
285
294
const table = useReactTable ( {
286
295
data : runs ?. data || [ ] ,
0 commit comments