Skip to content

Commit 3eb7e17

Browse files
authored
feat(aci): Add latest group sorting to frontend (#97312)
1 parent 5a78cbf commit 3eb7e17

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

static/app/views/detectors/components/detectorListTable/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {ComponentProps} from 'react';
22
import styled from '@emotion/styled';
33

4-
import LoadingError from 'sentry/components/loadingError';
54
import {SimpleTable} from 'sentry/components/tables/simpleTable';
65
import {t} from 'sentry/locale';
76
import {space} from 'sentry/styles/space';
@@ -83,7 +82,12 @@ function DetectorListTable({
8382
<HeaderCell data-column-name="type" divider sortKey="type" sort={sort}>
8483
{t('Type')}
8584
</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+
>
8791
{t('Last Issue')}
8892
</HeaderCell>
8993
<HeaderCell data-column-name="assignee" divider sort={sort}>
@@ -98,15 +102,14 @@ function DetectorListTable({
98102
{t('Automations')}
99103
</HeaderCell>
100104
</SimpleTable.Header>
101-
{isError && <LoadingError message={t('Error loading monitors')} />}
105+
{isError && <SimpleTable.Empty>{t('Error loading monitors')}</SimpleTable.Empty>}
102106
{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 && (
108108
<SimpleTable.Empty>{t('No monitors found')}</SimpleTable.Empty>
109109
)}
110+
{detectors.map(detector => (
111+
<DetectorListRow key={detector.id} detector={detector} />
112+
))}
110113
</DetectorListSimpleTable>
111114
</Container>
112115
);

static/app/views/detectors/list.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ describe('DetectorsList', function () {
208208
const {router} = render(<DetectorsList />, {organization});
209209
await screen.findByText('Detector 1');
210210

211-
// Default sort is connectedWorkflows descending
211+
// Default sort is latestGroup descending
212212
expect(mockDetectorsRequest).toHaveBeenCalledWith(
213213
expect.anything(),
214214
expect.objectContaining({
215215
query: expect.objectContaining({
216-
sortBy: '-connectedWorkflows',
216+
sortBy: '-latestGroup',
217217
}),
218218
})
219219
);

static/app/views/detectors/list.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function DetectorsList() {
2828

2929
const location = useLocation();
3030
const navigate = useNavigate();
31-
const {selection} = usePageFilters();
31+
const {selection, isReady} = usePageFilters();
3232

3333
const {
3434
sort: sorts,
@@ -41,21 +41,24 @@ export default function DetectorsList() {
4141
cursor: decodeScalar,
4242
},
4343
});
44-
const sort = sorts[0] ?? {kind: 'desc', field: 'connectedWorkflows'};
44+
const sort = sorts[0] ?? {kind: 'desc', field: 'latestGroup'};
4545

4646
const {
4747
data: detectors,
48-
isPending,
48+
isLoading,
4949
isError,
5050
isSuccess,
5151
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+
);
5962

6063
return (
6164
<SentryDocumentTitle title={t('Monitors')} noSuffix>
@@ -65,7 +68,7 @@ export default function DetectorsList() {
6568
<div>
6669
<DetectorListTable
6770
detectors={detectors ?? []}
68-
isPending={isPending}
71+
isPending={isLoading}
6972
isError={isError}
7073
isSuccess={isSuccess}
7174
sort={sort}

0 commit comments

Comments
 (0)