Skip to content

Commit 1794c6b

Browse files
Simplify rendering in AlertTable
1 parent 23d815f commit 1794c6b

1 file changed

Lines changed: 25 additions & 34 deletions

File tree

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

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,45 +151,36 @@ export class AlertTable extends React.Component<
151151
</tr>
152152
);
153153
} else {
154-
const paths: Sarif.ThreadFlow[] = Keys.getAllPaths(result);
155-
156-
const resultRow = (
157-
<AlertTableResultRow
158-
result={result}
159-
resultIndex={resultIndex}
160-
currentResultExpanded={currentResultExpanded}
161-
selectedItem={selectedItem}
162-
toggler={toggler}
163-
scroller={this.scroller}
164-
msg={msg}
165-
locationCells={locationCells}
166-
/>
167-
);
168-
169-
const pathRows =
170-
currentResultExpanded &&
171-
paths.map((path, pathIndex) => (
172-
<AlertTablePathRow
173-
key={`${resultIndex}-${pathIndex}`}
174-
path={path}
175-
pathIndex={pathIndex}
154+
return (
155+
<>
156+
<AlertTableResultRow
157+
result={result}
176158
resultIndex={resultIndex}
177-
currentPathExpanded={this.state.expanded.has(
178-
Keys.keyToString({ resultIndex, pathIndex }),
179-
)}
159+
currentResultExpanded={currentResultExpanded}
180160
selectedItem={selectedItem}
181-
databaseUri={databaseUri}
182-
sourceLocationPrefix={sourceLocationPrefix}
183-
updateSelectionCallback={updateSelectionCallback}
184161
toggler={toggler}
185162
scroller={this.scroller}
163+
msg={msg}
164+
locationCells={locationCells}
186165
/>
187-
));
188-
189-
return (
190-
<>
191-
{resultRow}
192-
{pathRows}
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+
))}
193184
</>
194185
);
195186
}

0 commit comments

Comments
 (0)