Skip to content

Commit fe4d87d

Browse files
Teach AlertTableResultRow how to render results without codeFlows
1 parent 1794c6b commit fe4d87d

2 files changed

Lines changed: 49 additions & 60 deletions

File tree

extensions/ql-vscode/src/view/results/AlertTable.tsx

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as React from "react";
22
import * as Sarif from "sarif";
33
import * as Keys from "./result-keys";
4-
import { info } from "./octicons";
54
import {
65
className,
76
ResultTableProps,
8-
selectableZebraStripe,
97
jumpToLocation,
108
} from "./result-table-utils";
119
import { onNavigation } from "./ResultsApp";
@@ -133,57 +131,39 @@ export class AlertTable extends React.Component<
133131
<td className="vscode-codeql__location-cell">{location}</td>
134132
);
135133

136-
const selectedItem = this.state.selectedItem;
137-
const resultRowIsSelected =
138-
selectedItem?.resultIndex === resultIndex &&
139-
selectedItem.pathIndex === undefined;
140-
141-
if (result.codeFlows === undefined) {
142-
return (
143-
<tr
144-
ref={this.scroller.ref(resultRowIsSelected)}
145-
key={resultIndex}
146-
{...selectableZebraStripe(resultRowIsSelected, resultIndex)}
147-
>
148-
<td className="vscode-codeql__icon-cell">{info}</td>
149-
<td colSpan={3}>{msg}</td>
150-
{locationCells}
151-
</tr>
152-
);
153-
} else {
154-
return (
155-
<>
156-
<AlertTableResultRow
157-
result={result}
158-
resultIndex={resultIndex}
159-
currentResultExpanded={currentResultExpanded}
160-
selectedItem={selectedItem}
161-
toggler={toggler}
162-
scroller={this.scroller}
163-
msg={msg}
164-
locationCells={locationCells}
165-
/>
166-
{currentResultExpanded &&
167-
Keys.getAllPaths(result).map((path, pathIndex) => (
168-
<AlertTablePathRow
169-
key={`${resultIndex}-${pathIndex}`}
170-
path={path}
171-
pathIndex={pathIndex}
172-
resultIndex={resultIndex}
173-
currentPathExpanded={this.state.expanded.has(
174-
Keys.keyToString({ resultIndex, pathIndex }),
175-
)}
176-
selectedItem={selectedItem}
177-
databaseUri={databaseUri}
178-
sourceLocationPrefix={sourceLocationPrefix}
179-
updateSelectionCallback={updateSelectionCallback}
180-
toggler={toggler}
181-
scroller={this.scroller}
182-
/>
183-
))}
184-
</>
185-
);
186-
}
134+
return (
135+
<>
136+
<AlertTableResultRow
137+
result={result}
138+
resultIndex={resultIndex}
139+
currentResultExpanded={currentResultExpanded}
140+
selectedItem={this.state.selectedItem}
141+
toggler={toggler}
142+
scroller={this.scroller}
143+
msg={msg}
144+
locationCells={locationCells}
145+
/>
146+
{currentResultExpanded &&
147+
result.codeFlows &&
148+
Keys.getAllPaths(result).map((path, pathIndex) => (
149+
<AlertTablePathRow
150+
key={`${resultIndex}-${pathIndex}`}
151+
path={path}
152+
pathIndex={pathIndex}
153+
resultIndex={resultIndex}
154+
currentPathExpanded={this.state.expanded.has(
155+
Keys.keyToString({ resultIndex, pathIndex }),
156+
)}
157+
selectedItem={this.state.selectedItem}
158+
databaseUri={databaseUri}
159+
sourceLocationPrefix={sourceLocationPrefix}
160+
updateSelectionCallback={updateSelectionCallback}
161+
toggler={toggler}
162+
scroller={this.scroller}
163+
/>
164+
))}
165+
</>
166+
);
187167
},
188168
);
189169

extensions/ql-vscode/src/view/results/AlertTableResultRow.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as Sarif from "sarif";
33
import * as Keys from "./result-keys";
4-
import { listUnordered } from "./octicons";
4+
import { info, listUnordered } from "./octicons";
55
import { ScrollIntoViewHelper } from "./scroll-into-view-helper";
66
import { selectableZebraStripe } from "./result-table-utils";
77
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
@@ -51,12 +51,21 @@ export function AlertTableResultRow(props: Props) {
5151
{...selectableZebraStripe(resultRowIsSelected, resultIndex)}
5252
key={resultIndex}
5353
>
54-
<AlertTableDropdownIndicatorCell
55-
expanded={currentResultExpanded}
56-
onClick={handleDropdownClick}
57-
/>
58-
<td className="vscode-codeql__icon-cell">{listUnordered}</td>
59-
<td colSpan={2}>{msg}</td>
54+
{result.codeFlows === undefined ? (
55+
<>
56+
<td className="vscode-codeql__icon-cell">{info}</td>
57+
<td colSpan={3}>{msg}</td>
58+
</>
59+
) : (
60+
<>
61+
<AlertTableDropdownIndicatorCell
62+
expanded={currentResultExpanded}
63+
onClick={handleDropdownClick}
64+
/>
65+
<td className="vscode-codeql__icon-cell">{listUnordered}</td>
66+
<td colSpan={2}>{msg}</td>
67+
</>
68+
)}
6069
{locationCells}
6170
</tr>
6271
);

0 commit comments

Comments
 (0)