Skip to content

Commit ca40963

Browse files
Move AlertTableNoResults to a new component in a new file
1 parent e5ab111 commit ca40963

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import { sendTelemetry } from "../common/telemetry";
2121
import { AlertTableHeader } from "./AlertTableHeader";
2222
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
2323
import { SarifLocation } from "./locations/SarifLocation";
24-
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
25-
import TextButton from "../common/TextButton";
2624
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
25+
import { AlertTableNoResults } from "./AlertTableNoResults";
2726

2827
type AlertTableProps = ResultTableProps & {
2928
resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -70,22 +69,6 @@ export class AlertTable extends React.Component<
7069
e.preventDefault();
7170
}
7271

73-
renderNoResults(): JSX.Element {
74-
if (this.props.nonemptyRawResults) {
75-
return (
76-
<span>
77-
No Alerts. See{" "}
78-
<TextButton onClick={this.props.showRawResults}>
79-
raw results
80-
</TextButton>
81-
.
82-
</span>
83-
);
84-
} else {
85-
return <EmptyQueryResultsMessage />;
86-
}
87-
}
88-
8972
render(): JSX.Element {
9073
const { databaseUri, resultSet } = this.props;
9174

@@ -112,7 +95,7 @@ export class AlertTable extends React.Component<
11295
};
11396

11497
if (!resultSet.interpretation.data.runs?.[0]?.results?.length) {
115-
return this.renderNoResults();
98+
return <AlertTableNoResults {...this.props} />;
11699
}
117100

118101
resultSet.interpretation.data.runs[0].results.forEach(
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from "react";
2+
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
3+
import TextButton from "../common/TextButton";
4+
5+
interface Props {
6+
nonemptyRawResults: boolean;
7+
showRawResults: () => void;
8+
}
9+
10+
export function AlertTableNoResults(props: Props): JSX.Element {
11+
if (props.nonemptyRawResults) {
12+
return (
13+
<span>
14+
No Alerts. See{" "}
15+
<TextButton onClick={props.showRawResults}>raw results</TextButton>.
16+
</span>
17+
);
18+
} else {
19+
return <EmptyQueryResultsMessage />;
20+
}
21+
}

0 commit comments

Comments
 (0)