Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit d844610

Browse files
authored
fix: sort filtered alerts before pagination (#190)
1 parent 2524344 commit d844610

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

src/components/AlertsTable.tsx

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,34 @@ export function AlertsTable() {
173173
</Row>
174174
</TableHeader>
175175
<TableBody>
176-
{dataView
177-
.sort(
178-
(a, b) =>
179-
new Date(b.timestamp).getTime() -
180-
new Date(a.timestamp).getTime(),
181-
)
182-
.map((alert) => (
183-
<Row key={alert.alert_id} className="h-20">
184-
<Cell className="truncate">{alert.trigger_type}</Cell>
185-
<Cell className="overflow-auto whitespace-nowrap max-w-80">
186-
{wrapObjectOutput(alert.trigger_string)}
187-
</Cell>
188-
<Cell className="truncate">
189-
{alert.code_snippet?.filepath || "N/A"}
190-
</Cell>
191-
<Cell className="overflow-auto whitespace-nowrap max-w-80">
192-
{alert.code_snippet?.code ? (
193-
<pre className="max-h-40 overflow-auto bg-gray-100 p-2 whitespace-pre-wrap">
194-
<code>{alert.code_snippet.code}</code>
195-
</pre>
196-
) : (
197-
"N/A"
198-
)}
199-
</Cell>
200-
<Cell className="truncate">
201-
<div data-testid="date">
202-
{format(new Date(alert.timestamp ?? ""), "y/MM/dd")}
203-
</div>
204-
<div data-testid="time">
205-
{format(new Date(alert.timestamp ?? ""), "hh:mm:ss a")}
206-
</div>
207-
</Cell>
208-
</Row>
209-
))}
176+
{dataView.map((alert) => (
177+
<Row key={alert.alert_id} className="h-20">
178+
<Cell className="truncate">{alert.trigger_type}</Cell>
179+
<Cell className="overflow-auto whitespace-nowrap max-w-80">
180+
{wrapObjectOutput(alert.trigger_string)}
181+
</Cell>
182+
<Cell className="truncate">
183+
{alert.code_snippet?.filepath || "N/A"}
184+
</Cell>
185+
<Cell className="overflow-auto whitespace-nowrap max-w-80">
186+
{alert.code_snippet?.code ? (
187+
<pre className="max-h-40 overflow-auto bg-gray-100 p-2 whitespace-pre-wrap">
188+
<code>{alert.code_snippet.code}</code>
189+
</pre>
190+
) : (
191+
"N/A"
192+
)}
193+
</Cell>
194+
<Cell className="truncate">
195+
<div data-testid="date">
196+
{format(new Date(alert.timestamp ?? ""), "y/MM/dd")}
197+
</div>
198+
<div data-testid="time">
199+
{format(new Date(alert.timestamp ?? ""), "hh:mm:ss a")}
200+
</div>
201+
</Cell>
202+
</Row>
203+
))}
210204
</TableBody>
211205
</Table>
212206
</div>

src/hooks/useAlertsData.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export const useFilteredAlerts = () => {
8282
typeof alert.trigger_string === "object" &&
8383
(alert.trigger_type as TriggerType) === "codegate-context-retriever"
8484
);
85-
});
85+
})
86+
.sort(
87+
(a, b) =>
88+
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
89+
);
8690
},
8791
});
8892
};

0 commit comments

Comments
 (0)