@@ -16,52 +16,25 @@ import {
1616import { Switch } from "@stacklok/ui-kit" ;
1717import { AlertConversation } from "@/api/generated" ;
1818import { Tooltip , TooltipTrigger } from "@stacklok/ui-kit" ;
19- import { getMaliciousPackage } from "@/lib/utils" ;
19+ import { sanitizeQuestionPrompt , parsingPromptText } from "@/lib/utils" ;
2020import { Search } from "lucide-react" ;
2121import { useAlertSearch } from "@/hooks/useAlertSearch" ;
2222import { useCallback } from "react" ;
2323import { useSearchParams } from "react-router-dom" ;
2424import { useFilteredAlerts } from "@/hooks/useAlertsData" ;
2525import { useClientSidePagination } from "@/hooks/useClientSidePagination" ;
2626
27- const wrapObjectOutput = ( input : AlertConversation [ "trigger_string" ] ) => {
28- const data = getMaliciousPackage ( input ) ;
29- if ( data === null ) return "N/A" ;
30- if ( typeof data === "string" ) {
31- return (
32- < div className = "p-4 line-clamp-1 text-clip" >
33- { data . split ( "\n" ) [ 0 ] ?? "" }
34- </ div >
35- ) ;
36- }
37- if ( ! data . type || ! data . name ) return "N/A" ;
38-
39- return (
40- < div className = "max-h-40 w-fit overflow-y-auto whitespace-pre-wrap p-2" >
41- < label className = "font-medium" > Package:</ label >
42-
43- < a
44- href = { `https://www.insight.stacklok.com/report/${ data . type } /${ data . name } ` }
45- target = "_blank"
46- rel = "noopener noreferrer"
47- className = "text-brand-500 hover:underline"
48- >
49- { data . type } /{ data . name }
50- </ a >
51- { data . status && (
52- < >
53- < br />
54- < label className = "font-medium" > Status:</ label > { data . status }
55- </ >
56- ) }
57- { data . description && (
58- < >
59- < br />
60- < label className = "font-medium" > Description:</ label > { data . description }
61- </ >
62- ) }
63- </ div >
27+ const getTitle = ( alert : AlertConversation ) => {
28+ const prompt = alert . conversation ;
29+ const title = parsingPromptText (
30+ sanitizeQuestionPrompt ( {
31+ question : prompt . question_answers ?. [ 0 ] ?. question . message ?? "" ,
32+ answer : prompt . question_answers ?. [ 0 ] ?. answer ?. message ?? "" ,
33+ } ) ,
34+ prompt . conversation_timestamp ,
6435 ) ;
36+
37+ return title ;
6538} ;
6639
6740export function AlertsTable ( ) {
@@ -184,9 +157,7 @@ export function AlertsTable() {
184157 } ) }
185158 </ Cell >
186159 < Cell className = "truncate" > { alert . trigger_type } </ Cell >
187- < Cell className = "overflow-auto whitespace-nowrap max-w-80" >
188- { wrapObjectOutput ( alert . trigger_string ) }
189- </ Cell >
160+ < Cell className = "truncate" > { getTitle ( alert ) } </ Cell >
190161 </ Row >
191162 ) ) }
192163 </ TableBody >
0 commit comments