Skip to content

Commit 9ecf971

Browse files
Move rendering of msg to inside AlertTableResuiltRow
1 parent 3983087 commit 9ecf971

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { parseSarifLocation, isNoLocation } from "../../common/sarif-utils";
1717
import { ScrollIntoViewHelper } from "./scroll-into-view-helper";
1818
import { sendTelemetry } from "../common/telemetry";
1919
import { AlertTableHeader } from "./AlertTableHeader";
20-
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
2120
import { AlertTableNoResults } from "./AlertTableNoResults";
2221
import { AlertTableTruncatedMessage } from "./AlertTableTruncatedMessage";
2322
import { AlertTablePathRow } from "./AlertTablePathRow";
@@ -100,20 +99,6 @@ export class AlertTable extends React.Component<
10099
resultSet.interpretation.data.runs[0].results.map(
101100
(result, resultIndex) => {
102101
const resultKey: Keys.Result = { resultIndex };
103-
const text = result.message.text || "[no text]";
104-
const msg =
105-
result.relatedLocations === undefined ? (
106-
<span key="0">{text}</span>
107-
) : (
108-
<SarifMessageWithLocations
109-
msg={text}
110-
relatedLocations={result.relatedLocations}
111-
sourceLocationPrefix={sourceLocationPrefix}
112-
databaseUri={databaseUri}
113-
onClick={updateSelectionCallback(resultKey)}
114-
/>
115-
);
116-
117102
const currentResultExpanded = this.state.expanded.has(
118103
Keys.keyToString(resultKey),
119104
);
@@ -130,7 +115,6 @@ export class AlertTable extends React.Component<
130115
updateSelectionCallback={updateSelectionCallback}
131116
toggler={toggler}
132117
scroller={this.scroller}
133-
msg={msg}
134118
/>
135119
{currentResultExpanded &&
136120
result.codeFlows &&

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { selectableZebraStripe } from "./result-table-utils";
77
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
88
import { useMemo } from "react";
99
import { SarifLocation } from "./locations/SarifLocation";
10+
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
1011

1112
interface Props {
1213
result: Sarif.Result;
@@ -20,7 +21,6 @@ interface Props {
2021
) => () => void;
2122
toggler: (keys: Keys.ResultKey[]) => (e: React.MouseEvent) => void;
2223
scroller: ScrollIntoViewHelper;
23-
msg: JSX.Element;
2424
}
2525

2626
export function AlertTableResultRow(props: Props) {
@@ -34,7 +34,6 @@ export function AlertTableResultRow(props: Props) {
3434
updateSelectionCallback,
3535
toggler,
3636
scroller,
37-
msg,
3837
} = props;
3938

4039
const resultKey: Keys.Result = useMemo(
@@ -60,6 +59,20 @@ export function AlertTableResultRow(props: Props) {
6059
selectedItem?.resultIndex === resultIndex &&
6160
selectedItem.pathIndex === undefined;
6261

62+
const text = result.message.text || "[no text]";
63+
const msg =
64+
result.relatedLocations === undefined ? (
65+
<span key="0">{text}</span>
66+
) : (
67+
<SarifMessageWithLocations
68+
msg={text}
69+
relatedLocations={result.relatedLocations}
70+
sourceLocationPrefix={sourceLocationPrefix}
71+
databaseUri={databaseUri}
72+
onClick={handleSarifLocationClicked}
73+
/>
74+
);
75+
6376
return (
6477
<tr
6578
ref={scroller.ref(resultRowIsSelected)}

0 commit comments

Comments
 (0)