Do all rendering in AlertTablePathRow in one place

This commit is contained in:
Robert
2023-08-16 14:36:08 +01:00
parent 3e7577c984
commit a576dace04

View File

@@ -49,45 +49,39 @@ export function AlertTablePathRow(props: Props) {
pathKey,
selectedItem,
);
const pathRow = (
<tr
ref={scroller.ref(isPathSpecificallySelected)}
{...selectableZebraStripe(isPathSpecificallySelected, resultIndex)}
>
<td className="vscode-codeql__icon-cell">
<span className="vscode-codeql__vertical-rule"></span>
</td>
<AlertTableDropdownIndicatorCell
expanded={currentPathExpanded}
onClick={handleDropdownClick}
/>
<td className="vscode-codeql__text-center" colSpan={3}>
Path
</td>
</tr>
);
const pathNodeRows =
currentPathExpanded &&
path.locations.map((step, pathNodeIndex) => (
<AlertTablePathNodeRow
key={`${resultIndex}-${pathIndex}-${pathNodeIndex}`}
step={step}
pathNodeIndex={pathNodeIndex}
pathIndex={pathIndex}
resultIndex={resultIndex}
selectedItem={selectedItem}
databaseUri={databaseUri}
sourceLocationPrefix={sourceLocationPrefix}
updateSelectionCallback={updateSelectionCallback}
scroller={scroller}
/>
));
return (
<>
{pathRow}
{pathNodeRows}
<tr
ref={scroller.ref(isPathSpecificallySelected)}
{...selectableZebraStripe(isPathSpecificallySelected, resultIndex)}
>
<td className="vscode-codeql__icon-cell">
<span className="vscode-codeql__vertical-rule"></span>
</td>
<AlertTableDropdownIndicatorCell
expanded={currentPathExpanded}
onClick={handleDropdownClick}
/>
<td className="vscode-codeql__text-center" colSpan={3}>
Path
</td>
</tr>
{currentPathExpanded &&
path.locations.map((step, pathNodeIndex) => (
<AlertTablePathNodeRow
key={`${resultIndex}-${pathIndex}-${pathNodeIndex}`}
step={step}
pathNodeIndex={pathNodeIndex}
pathIndex={pathIndex}
resultIndex={resultIndex}
selectedItem={selectedItem}
databaseUri={databaseUri}
sourceLocationPrefix={sourceLocationPrefix}
updateSelectionCallback={updateSelectionCallback}
scroller={scroller}
/>
))}
</>
);
}