Fix listing of tables when in alerts view
This commit is contained in:
@@ -121,6 +121,7 @@ export interface ShowInterpretedPageMsg {
|
||||
metadata?: QueryMetadata;
|
||||
pageNumber: number;
|
||||
numPages: number;
|
||||
resultSetNames: string[];
|
||||
}
|
||||
|
||||
/** Advance to the next or previous path no in the path viewer */
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
jumpToLocation,
|
||||
} from './interface-utils';
|
||||
import { getDefaultResultSetName } from './interface-types';
|
||||
import { ResultSetSchema } from './bqrs-cli-types';
|
||||
|
||||
/**
|
||||
* interface.ts
|
||||
@@ -330,19 +331,13 @@ export class InterfaceManager extends DisposableObject {
|
||||
|
||||
const getParsedResultSets = async (): Promise<ParsedResultSets> => {
|
||||
if (EXPERIMENTAL_BQRS_SETTING.getValue()) {
|
||||
const schemas = await this.cliServer.bqrsInfo(
|
||||
results.query.resultsPaths.resultsPath,
|
||||
RAW_RESULTS_PAGE_SIZE
|
||||
);
|
||||
|
||||
const resultSetNames = schemas['result-sets'].map(
|
||||
(resultSet) => resultSet.name
|
||||
);
|
||||
const resultSetSchemas = await this.getResultSetSchemas(results);
|
||||
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
||||
|
||||
// This may not wind up being the page we actually show, if there are interpreted results,
|
||||
// but speculatively send it anyway.
|
||||
const selectedTable = getDefaultResultSetName(resultSetNames);
|
||||
const schema = schemas['result-sets'].find(
|
||||
const schema = resultSetSchemas.find(
|
||||
(resultSet) => resultSet.name == selectedTable
|
||||
)!;
|
||||
if (schema === undefined) {
|
||||
@@ -401,16 +396,29 @@ export class InterfaceManager extends DisposableObject {
|
||||
if (this._interpretation.sarif.runs[0].results === undefined) {
|
||||
throw new Error(`Trying to show interpreted results but results were undefined`);
|
||||
}
|
||||
|
||||
const resultSetSchemas = await this.getResultSetSchemas(this._displayedQuery);
|
||||
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
||||
|
||||
await this.postMessage({
|
||||
t: 'showInterpretedPage',
|
||||
interpretation: this.getPageOfInterpretedResults(pageNumber),
|
||||
database: this._displayedQuery.database,
|
||||
metadata: this._displayedQuery.query.metadata,
|
||||
pageNumber,
|
||||
resultSetNames,
|
||||
numPages: Math.ceil(this._interpretation.sarif.runs[0].results.length / INTERPRETED_RESULTS_PAGE_SIZE),
|
||||
});
|
||||
}
|
||||
|
||||
private async getResultSetSchemas(results: CompletedQuery): Promise<ResultSetSchema[]> {
|
||||
const schemas = await this.cliServer.bqrsInfo(
|
||||
results.query.resultsPaths.resultsPath,
|
||||
RAW_RESULTS_PAGE_SIZE
|
||||
);
|
||||
return schemas['result-sets'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a page of raw results from the chosen table.
|
||||
*/
|
||||
@@ -429,16 +437,10 @@ export class InterfaceManager extends DisposableObject {
|
||||
(sortedResultsMap[k] = this.convertPathPropertiesToWebviewUris(v))
|
||||
);
|
||||
|
||||
const schemas = await this.cliServer.bqrsInfo(
|
||||
results.query.resultsPaths.resultsPath,
|
||||
RAW_RESULTS_PAGE_SIZE
|
||||
);
|
||||
const resultSetSchemas = await this.getResultSetSchemas(results);
|
||||
const resultSetNames = resultSetSchemas.map(schema => schema.name);
|
||||
|
||||
const resultSetNames = schemas['result-sets'].map(
|
||||
(resultSet) => resultSet.name
|
||||
);
|
||||
|
||||
const schema = schemas['result-sets'].find(
|
||||
const schema = resultSetSchemas.find(
|
||||
(resultSet) => resultSet.name == selectedTable
|
||||
)!;
|
||||
if (schema === undefined)
|
||||
|
||||
@@ -198,11 +198,11 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
break;
|
||||
case 'showInterpretedPage':
|
||||
const resultsInfo: ResultsInfo = {
|
||||
resultsPath: '...', // XXX
|
||||
resultsPath: '', // FIXME: Not used for interpreted, refactor so this is not needed
|
||||
parsedResultSets: {
|
||||
t: 'ExtensionParsed',
|
||||
numPages: msg.numPages,
|
||||
resultSetNames: ['alerts'], // XXX get the other result set names from the extension
|
||||
resultSetNames: msg.resultSetNames,
|
||||
pageNumber: msg.pageNumber,
|
||||
resultSet: {
|
||||
t: 'SarifResultSet',
|
||||
@@ -212,8 +212,8 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
},
|
||||
selectedTable: ALERTS_TABLE_NAME,
|
||||
},
|
||||
origResultsPaths: undefined as any,
|
||||
sortedResultsMap: new Map(), // XXX ?
|
||||
origResultsPaths: undefined as any, // FIXME: Not used for interpreted, refactor so this is not needed
|
||||
sortedResultsMap: new Map(), // FIXME: Not used for interpreted, refactor so this is not needed
|
||||
database: msg.database,
|
||||
interpretation: msg.interpretation,
|
||||
shouldKeepOldResultsWhileRendering: true,
|
||||
|
||||
Reference in New Issue
Block a user