@@ -6,16 +6,21 @@ import { ScrollIntoViewHelper } from "./scroll-into-view-helper";
66import { selectableZebraStripe } from "./result-table-utils" ;
77import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell" ;
88import { useMemo } from "react" ;
9+ import { SarifLocation } from "./locations/SarifLocation" ;
910
1011interface Props {
1112 result : Sarif . Result ;
1213 resultIndex : number ;
1314 currentResultExpanded : boolean ;
1415 selectedItem : undefined | Keys . ResultKey ;
16+ databaseUri : string ;
17+ sourceLocationPrefix : string ;
18+ updateSelectionCallback : (
19+ resultKey : Keys . PathNode | Keys . Result | undefined ,
20+ ) => ( ) => void ;
1521 toggler : ( keys : Keys . ResultKey [ ] ) => ( e : React . MouseEvent ) => void ;
1622 scroller : ScrollIntoViewHelper ;
1723 msg : JSX . Element ;
18- locationCells : JSX . Element ;
1924}
2025
2126export function AlertTableResultRow ( props : Props ) {
@@ -24,22 +29,28 @@ export function AlertTableResultRow(props: Props) {
2429 resultIndex,
2530 currentResultExpanded,
2631 selectedItem,
32+ databaseUri,
33+ sourceLocationPrefix,
34+ updateSelectionCallback,
2735 toggler,
2836 scroller,
2937 msg,
30- locationCells,
3138 } = props ;
3239
40+ const resultKey : Keys . Result = useMemo (
41+ ( ) => ( { resultIndex } ) ,
42+ [ resultIndex ] ,
43+ ) ;
44+
3345 const handleDropdownClick = useMemo ( ( ) => {
34- const resultKey : Keys . Result = { resultIndex } ;
3546 const indices =
3647 Keys . getAllPaths ( result ) . length === 1
3748 ? [ resultKey , { ...resultKey , pathIndex : 0 } ]
3849 : /* if there's exactly one path, auto-expand
3950 * the path when expanding the result */
4051 [ resultKey ] ;
4152 return toggler ( indices ) ;
42- } , [ result , resultIndex , toggler ] ) ;
53+ } , [ result , resultKey , toggler ] ) ;
4354
4455 const resultRowIsSelected =
4556 selectedItem ?. resultIndex === resultIndex &&
@@ -66,7 +77,16 @@ export function AlertTableResultRow(props: Props) {
6677 < td colSpan = { 2 } > { msg } </ td >
6778 </ >
6879 ) }
69- { locationCells }
80+ < td className = "vscode-codeql__location-cell" >
81+ { result . locations && result . locations . length > 0 && (
82+ < SarifLocation
83+ loc = { result . locations [ 0 ] }
84+ sourceLocationPrefix = { sourceLocationPrefix }
85+ databaseUri = { databaseUri }
86+ onClick = { updateSelectionCallback ( resultKey ) }
87+ />
88+ ) }
89+ </ td >
7090 </ tr >
7191 ) ;
7292}
0 commit comments