Move AlertTableTruncatedMessage to a new component in a new file

This commit is contained in:
Robert
2023-08-16 10:52:26 +01:00
parent ca40963238
commit cff7170fdc
2 changed files with 26 additions and 12 deletions

View File

@@ -23,6 +23,7 @@ import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations
import { SarifLocation } from "./locations/SarifLocation";
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
import { AlertTableNoResults } from "./AlertTableNoResults";
import { AlertTableTruncatedMessage } from "./AlertTableTruncatedMessage";
type AlertTableProps = ResultTableProps & {
resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -295,21 +296,15 @@ export class AlertTable extends React.Component<
},
);
if (numTruncatedResults > 0) {
rows.push(
<tr key="truncatd-message">
<td colSpan={5} style={{ textAlign: "center", fontStyle: "italic" }}>
Too many results to show at once. {numTruncatedResults} result(s)
omitted.
</td>
</tr>,
);
}
return (
<table className={className}>
<AlertTableHeader sortState={resultSet.interpretation.data.sortState} />
<tbody>{rows}</tbody>
<tbody>
{rows}
<AlertTableTruncatedMessage
numTruncatedResults={numTruncatedResults}
/>
</tbody>
</table>
);
}

View File

@@ -0,0 +1,19 @@
import * as React from "react";
interface Props {
numTruncatedResults: number;
}
export function AlertTableTruncatedMessage(props: Props): JSX.Element | null {
if (props.numTruncatedResults === 0) {
return null;
}
return (
<tr key="truncatd-message">
<td colSpan={5} style={{ textAlign: "center", fontStyle: "italic" }}>
Too many results to show at once. {props.numTruncatedResults} result(s)
omitted.
</td>
</tr>
);
}