@@ -4,11 +4,7 @@ import {
4
4
filterNonNullItems ,
5
5
transformSorterToOrderString ,
6
6
} from '../helper' ;
7
- import {
8
- useSuspendedBackendaiClient ,
9
- useUpdatableState ,
10
- useWebUINavigate ,
11
- } from '../hooks' ;
7
+ import { useSuspendedBackendaiClient , useWebUINavigate } from '../hooks' ;
12
8
import { useCurrentUserInfo , useCurrentUserRole } from '../hooks/backendai' ;
13
9
import { useBAIPaginationOptionState } from '../hooks/reactPaginationQueryOptions' ;
14
10
// import { getSortOrderByName } from '../hooks/reactPaginationQueryOptions';
@@ -29,23 +25,16 @@ import {
29
25
CheckOutlined ,
30
26
CloseOutlined ,
31
27
DeleteOutlined ,
32
- LoadingOutlined ,
33
- ReloadOutlined ,
34
28
SettingOutlined ,
35
29
} from '@ant-design/icons' ;
36
- import { useRafInterval , useToggle } from 'ahooks' ;
30
+ import { useToggle } from 'ahooks' ;
37
31
import { Button , Typography , theme , Radio , App , Tooltip } from 'antd' ;
38
32
import { ColumnType } from 'antd/lib/table' ;
39
33
import graphql from 'babel-plugin-relay/macro' ;
40
34
import { default as dayjs } from 'dayjs' ;
41
35
import _ from 'lodash' ;
42
36
import { InfoIcon } from 'lucide-react' ;
43
- import React , {
44
- PropsWithChildren ,
45
- useState ,
46
- useTransition ,
47
- startTransition as startTransitionWithoutPendingState ,
48
- } from 'react' ;
37
+ import React , { PropsWithChildren , useState , useTransition } from 'react' ;
49
38
import { useTranslation } from 'react-i18next' ;
50
39
import { useLazyLoadQuery } from 'react-relay' ;
51
40
import { Link } from 'react-router-dom' ;
@@ -75,8 +64,15 @@ type LifecycleStage = 'created&destroying' | 'destroyed';
75
64
76
65
interface EndpointListProps extends PropsWithChildren {
77
66
style ?: React . CSSProperties ;
67
+ fetchKey ?: string ;
68
+ onDeleted ?: ( endpoint : Endpoint ) => void ;
78
69
}
79
- const EndpointList : React . FC < EndpointListProps > = ( { style, children } ) => {
70
+ const EndpointList : React . FC < EndpointListProps > = ( {
71
+ style,
72
+ fetchKey,
73
+ onDeleted,
74
+ children,
75
+ } ) => {
80
76
const { t } = useTranslation ( ) ;
81
77
const { token } = theme . useToken ( ) ;
82
78
const { message, modal } = App . useApp ( ) ;
@@ -98,11 +94,8 @@ const EndpointList: React.FC<EndpointListProps> = ({ style, children }) => {
98
94
? `lifecycle_stage == "created" | lifecycle_stage == "destroying"`
99
95
: `lifecycle_stage == "${ selectedLifecycleStage } "` ;
100
96
101
- const [ isRefetchPending , startRefetchTransition ] = useTransition ( ) ;
102
97
const [ isFilterPending , startFilterTransition ] = useTransition ( ) ;
103
98
const [ isPendingPageChange , startPageChangeTransition ] = useTransition ( ) ;
104
- const [ servicesFetchKey , updateServicesFetchKey ] =
105
- useUpdatableState ( 'initial-fetch' ) ;
106
99
const [ optimisticDeletingId , setOptimisticDeletingId ] = useState <
107
100
string | null
108
101
> ( ) ;
@@ -212,9 +205,7 @@ const EndpointList: React.FC<EndpointListProps> = ({ style, children }) => {
212
205
row . endpoint_id &&
213
206
terminateModelServiceMutation . mutate ( row ?. endpoint_id , {
214
207
onSuccess : ( res ) => {
215
- startRefetchTransition ( ( ) => {
216
- updateServicesFetchKey ( ) ;
217
- } ) ;
208
+ onDeleted ?.( row ) ;
218
209
// FIXME: temporally refer to mutate input to message
219
210
if ( res . success ) {
220
211
message . success (
@@ -318,12 +309,6 @@ const EndpointList: React.FC<EndpointListProps> = ({ style, children }) => {
318
309
const [ hiddenColumnKeys , setHiddenColumnKeys ] =
319
310
useHiddenColumnKeysSetting ( 'EndpointListPage' ) ;
320
311
321
- useRafInterval ( ( ) => {
322
- startTransitionWithoutPendingState ( ( ) => {
323
- updateServicesFetchKey ( ) ;
324
- } ) ;
325
- } , 7000 ) ;
326
-
327
312
const { endpoint_list : modelServiceList } =
328
313
useLazyLoadQuery < EndpointListQuery > (
329
314
graphql `
@@ -388,7 +373,7 @@ const EndpointList: React.FC<EndpointListProps> = ({ style, children }) => {
388
373
} ,
389
374
{
390
375
fetchPolicy : 'network-only' ,
391
- fetchKey : servicesFetchKey ,
376
+ fetchKey,
392
377
} ,
393
378
) ;
394
379
@@ -506,34 +491,12 @@ const EndpointList: React.FC<EndpointListProps> = ({ style, children }) => {
506
491
</ >
507
492
) }
508
493
</ Flex >
509
- < Flex direction = "row" gap = { 'xs' } >
510
- < Flex gap = { 'xs' } >
511
- < Button
512
- icon = { < ReloadOutlined /> }
513
- loading = { isRefetchPending }
514
- onClick = { ( ) => {
515
- startRefetchTransition ( ( ) => updateServicesFetchKey ( ) ) ;
516
- } }
517
- />
518
- < Button
519
- type = "primary"
520
- onClick = { ( ) => {
521
- webuiNavigate ( '/service/start' ) ;
522
- } }
523
- >
524
- { t ( 'modelService.StartService' ) }
525
- </ Button >
526
- </ Flex >
527
- </ Flex >
528
494
</ Flex >
529
495
< Flex direction = "column" align = "stretch" >
530
496
< BAITable
531
497
neoStyle
532
498
size = "small"
533
- loading = { {
534
- spinning : isFilterPending || isPendingPageChange ,
535
- indicator : < LoadingOutlined /> ,
536
- } }
499
+ loading = { isFilterPending || isPendingPageChange }
537
500
scroll = { { x : 'max-content' } }
538
501
rowKey = { 'endpoint_id' }
539
502
dataSource = { filterNonNullItems ( modelServiceList ?. items ) }
0 commit comments