File tree Expand file tree Collapse file tree 3 files changed +27
-21
lines changed
static/app/views/detectors
components/detectorListTable Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 1
1
import type { ComponentProps } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
4
- import LoadingError from 'sentry/components/loadingError' ;
5
4
import { SimpleTable } from 'sentry/components/tables/simpleTable' ;
6
5
import { t } from 'sentry/locale' ;
7
6
import { space } from 'sentry/styles/space' ;
@@ -83,7 +82,12 @@ function DetectorListTable({
83
82
< HeaderCell data-column-name = "type" divider sortKey = "type" sort = { sort } >
84
83
{ t ( 'Type' ) }
85
84
</ HeaderCell >
86
- < HeaderCell data-column-name = "last-issue" divider sort = { sort } >
85
+ < HeaderCell
86
+ data-column-name = "last-issue"
87
+ divider
88
+ sortKey = "latestGroup"
89
+ sort = { sort }
90
+ >
87
91
{ t ( 'Last Issue' ) }
88
92
</ HeaderCell >
89
93
< HeaderCell data-column-name = "assignee" divider sort = { sort } >
@@ -98,15 +102,14 @@ function DetectorListTable({
98
102
{ t ( 'Automations' ) }
99
103
</ HeaderCell >
100
104
</ SimpleTable . Header >
101
- { isError && < LoadingError message = { t ( 'Error loading monitors' ) } / >}
105
+ { isError && < SimpleTable . Empty > { t ( 'Error loading monitors' ) } </ SimpleTable . Empty > }
102
106
{ isPending && < LoadingSkeletons /> }
103
- { isSuccess && detectors . length > 0 ? (
104
- detectors . map ( detector => (
105
- < DetectorListRow key = { detector . id } detector = { detector } />
106
- ) )
107
- ) : (
107
+ { isSuccess && detectors . length === 0 && (
108
108
< SimpleTable . Empty > { t ( 'No monitors found' ) } </ SimpleTable . Empty >
109
109
) }
110
+ { detectors . map ( detector => (
111
+ < DetectorListRow key = { detector . id } detector = { detector } />
112
+ ) ) }
110
113
</ DetectorListSimpleTable >
111
114
</ Container >
112
115
) ;
Original file line number Diff line number Diff line change @@ -208,12 +208,12 @@ describe('DetectorsList', function () {
208
208
const { router} = render ( < DetectorsList /> , { organization} ) ;
209
209
await screen . findByText ( 'Detector 1' ) ;
210
210
211
- // Default sort is connectedWorkflows descending
211
+ // Default sort is latestGroup descending
212
212
expect ( mockDetectorsRequest ) . toHaveBeenCalledWith (
213
213
expect . anything ( ) ,
214
214
expect . objectContaining ( {
215
215
query : expect . objectContaining ( {
216
- sortBy : '-connectedWorkflows ' ,
216
+ sortBy : '-latestGroup ' ,
217
217
} ) ,
218
218
} )
219
219
) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function DetectorsList() {
28
28
29
29
const location = useLocation ( ) ;
30
30
const navigate = useNavigate ( ) ;
31
- const { selection} = usePageFilters ( ) ;
31
+ const { selection, isReady } = usePageFilters ( ) ;
32
32
33
33
const {
34
34
sort : sorts ,
@@ -41,21 +41,24 @@ export default function DetectorsList() {
41
41
cursor : decodeScalar ,
42
42
} ,
43
43
} ) ;
44
- const sort = sorts [ 0 ] ?? { kind : 'desc' , field : 'connectedWorkflows ' } ;
44
+ const sort = sorts [ 0 ] ?? { kind : 'desc' , field : 'latestGroup ' } ;
45
45
46
46
const {
47
47
data : detectors ,
48
- isPending ,
48
+ isLoading ,
49
49
isError,
50
50
isSuccess,
51
51
getResponseHeader,
52
- } = useDetectorsQuery ( {
53
- cursor,
54
- query,
55
- sortBy : sort ? `${ sort ?. kind === 'asc' ? '' : '-' } ${ sort ?. field } ` : undefined ,
56
- projects : selection . projects ,
57
- limit : DETECTOR_LIST_PAGE_LIMIT ,
58
- } ) ;
52
+ } = useDetectorsQuery (
53
+ {
54
+ cursor,
55
+ query,
56
+ sortBy : sort ? `${ sort ?. kind === 'asc' ? '' : '-' } ${ sort ?. field } ` : undefined ,
57
+ projects : selection . projects ,
58
+ limit : DETECTOR_LIST_PAGE_LIMIT ,
59
+ } ,
60
+ { enabled : isReady }
61
+ ) ;
59
62
60
63
return (
61
64
< SentryDocumentTitle title = { t ( 'Monitors' ) } noSuffix >
@@ -65,7 +68,7 @@ export default function DetectorsList() {
65
68
< div >
66
69
< DetectorListTable
67
70
detectors = { detectors ?? [ ] }
68
- isPending = { isPending }
71
+ isPending = { isLoading }
69
72
isError = { isError }
70
73
isSuccess = { isSuccess }
71
74
sort = { sort }
You can’t perform that action at this time.
0 commit comments