Add link to language guides for empty query results

This commit is contained in:
Eric Kim
2021-05-17 14:04:30 -07:00
committed by Andrew Eisenberg
parent d9ff5bdca4
commit ca93f0e84b
3 changed files with 13 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ import * as React from 'react';
import * as Sarif from 'sarif';
import * as Keys from '../pure/result-keys';
import * as octicons from './octicons';
import { className, renderLocation, ResultTableProps, zebraStripe, selectableZebraStripe, jumpToLocation, nextSortDirection } from './result-table-utils';
import { className, renderLocation, ResultTableProps, zebraStripe, selectableZebraStripe, jumpToLocation, nextSortDirection, emptyQueryResultsMessage } from './result-table-utils';
import { onNavigation, NavigationEvent } from './results';
import { PathTableResultSet } from '../pure/interface-types';
import {
@@ -79,7 +79,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
if (this.props.nonemptyRawResults) {
return <span>No Alerts. See <a href='#' onClick={this.props.showRawResults}>raw results</a>.</span>;
} else {
return <span>No Alerts</span>;
return emptyQueryResultsMessage();
}
}

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { ResultTableProps, className } from './result-table-utils';
import { ResultTableProps, className, emptyQueryResultsMessage } from './result-table-utils';
import { RAW_RESULTS_LIMIT, RawResultsSortState } from '../pure/interface-types';
import { RawTableResultSet } from '../pure/interface-types';
import RawTableHeader from './RawTableHeader';
@@ -21,6 +21,10 @@ export class RawTable extends React.Component<RawTableProps, {}> {
const { resultSet, databaseUri } = this.props;
let dataRows = resultSet.rows;
if (dataRows.length === 0) {
return emptyQueryResultsMessage();
}
let numTruncatedResults = 0;
if (dataRows.length > RAW_RESULTS_LIMIT) {
numTruncatedResults = dataRows.length - RAW_RESULTS_LIMIT;

View File

@@ -140,3 +140,9 @@ export function nextSortDirection(direction: SortDirection | undefined, includeU
return assertNever(direction);
}
}
export function emptyQueryResultsMessage(): JSX.Element {
return <span>
This query returned no results. If this isn&apos;t what you&apos;re expecting, and for effective query-writing tips, check out the <a href="https://codeql.github.com/docs/codeql-language-guides/">CodeQL language guides</a>.
</span>;
}