Skip to content

Commit cff7170

Browse files
Move AlertTableTruncatedMessage to a new component in a new file
1 parent ca40963 commit cff7170

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations
2323
import { SarifLocation } from "./locations/SarifLocation";
2424
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
2525
import { AlertTableNoResults } from "./AlertTableNoResults";
26+
import { AlertTableTruncatedMessage } from "./AlertTableTruncatedMessage";
2627

2728
type AlertTableProps = ResultTableProps & {
2829
resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -295,21 +296,15 @@ export class AlertTable extends React.Component<
295296
},
296297
);
297298

298-
if (numTruncatedResults > 0) {
299-
rows.push(
300-
<tr key="truncatd-message">
301-
<td colSpan={5} style={{ textAlign: "center", fontStyle: "italic" }}>
302-
Too many results to show at once. {numTruncatedResults} result(s)
303-
omitted.
304-
</td>
305-
</tr>,
306-
);
307-
}
308-
309299
return (
310300
<table className={className}>
311301
<AlertTableHeader sortState={resultSet.interpretation.data.sortState} />
312-
<tbody>{rows}</tbody>
302+
<tbody>
303+
{rows}
304+
<AlertTableTruncatedMessage
305+
numTruncatedResults={numTruncatedResults}
306+
/>
307+
</tbody>
313308
</table>
314309
);
315310
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from "react";
2+
3+
interface Props {
4+
numTruncatedResults: number;
5+
}
6+
7+
export function AlertTableTruncatedMessage(props: Props): JSX.Element | null {
8+
if (props.numTruncatedResults === 0) {
9+
return null;
10+
}
11+
return (
12+
<tr key="truncatd-message">
13+
<td colSpan={5} style={{ textAlign: "center", fontStyle: "italic" }}>
14+
Too many results to show at once. {props.numTruncatedResults} result(s)
15+
omitted.
16+
</td>
17+
</tr>
18+
);
19+
}

0 commit comments

Comments
 (0)