Make EmptyQueryResultsMessage into a component

This commit is contained in:
Robert
2023-08-15 16:42:10 +01:00
parent 57262446fb
commit d3d96a1dbe
4 changed files with 29 additions and 32 deletions

View File

@@ -0,0 +1,24 @@
import * as React from "react";
import { sendTelemetry } from "../common/telemetry";
function sendCodeQLLanguageGuidesTelemetry() {
sendTelemetry("codeql-language-guides-link");
}
export function EmptyQueryResultsMessage(): JSX.Element {
return (
<div className="vscode-codeql__empty-query-message">
<span>
This query returned no results. If this isn&apos;t what you were
expecting, and for effective query-writing tips, check out the{" "}
<a
href="https://codeql.github.com/docs/codeql-language-guides/"
onClick={sendCodeQLLanguageGuidesTelemetry}
>
CodeQL language guides
</a>
.
</span>
</div>
);
}

View File

@@ -7,7 +7,6 @@ import {
ResultTableProps,
selectableZebraStripe,
jumpToLocation,
emptyQueryResultsMessage,
} from "./result-table-utils";
import { onNavigation } from "./results";
import {
@@ -22,6 +21,7 @@ import { sendTelemetry } from "../common/telemetry";
import { AlertTableHeader } from "./alert-table-header";
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
import { SarifLocation } from "./locations/SarifLocation";
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
type AlertTableProps = ResultTableProps & {
resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -84,7 +84,7 @@ export class AlertTable extends React.Component<
</span>
);
} else {
return emptyQueryResultsMessage();
return <EmptyQueryResultsMessage />;
}
}

View File

@@ -1,10 +1,6 @@
import * as React from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
className,
emptyQueryResultsMessage,
jumpToLocation,
} from "./result-table-utils";
import { className, jumpToLocation } from "./result-table-utils";
import {
RAW_RESULTS_LIMIT,
RawResultsSortState,
@@ -20,6 +16,7 @@ import { tryGetResolvableLocation } from "../../common/bqrs-utils";
import { ScrollIntoViewHelper } from "./scroll-into-view-helper";
import { sendTelemetry } from "../common/telemetry";
import { assertNever } from "../../common/helpers-pure";
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
type RawTableProps = {
databaseUri: string;
@@ -130,7 +127,7 @@ export function RawTable({
}, [resultSet]);
if (dataRows.length === 0) {
return emptyQueryResultsMessage();
return <EmptyQueryResultsMessage />;
}
const tableRows = dataRows.map((row: ResultRow, rowIndex: number) => (

View File

@@ -1,4 +1,3 @@
import * as React from "react";
import { ResolvableLocationValue } from "../../common/bqrs-cli-types";
import {
RawResultsSortState,
@@ -8,7 +7,6 @@ import {
} from "../../common/interface-types";
import { assertNever } from "../../common/helpers-pure";
import { vscode } from "../vscode-api";
import { sendTelemetry } from "../common/telemetry";
export interface ResultTableProps {
resultSet: ResultSet;
@@ -107,25 +105,3 @@ export function nextSortDirection(
return assertNever(direction);
}
}
function sendCodeQLLanguageGuidesTelemetry() {
sendTelemetry("codeql-language-guides-link");
}
export function emptyQueryResultsMessage(): JSX.Element {
return (
<div className="vscode-codeql__empty-query-message">
<span>
This query returned no results. If this isn&apos;t what you were
expecting, and for effective query-writing tips, check out the{" "}
<a
href="https://codeql.github.com/docs/codeql-language-guides/"
onClick={sendCodeQLLanguageGuidesTelemetry}
>
CodeQL language guides
</a>
.
</span>
</div>
);
}