Rename properties and handle missing files
This commit is contained in:
@@ -20,6 +20,7 @@ import { AnalysisResult, RemoteQueryResult } from './remote-query-result';
|
||||
import { RemoteQuery } from './remote-query';
|
||||
import { RemoteQueryResult as RemoteQueryResultViewModel } from './shared/remote-query-result';
|
||||
import { AnalysisResult as AnalysisResultViewModel } from './shared/remote-query-result';
|
||||
import { showAndLogWarningMessage } from '../helpers';
|
||||
|
||||
export class RemoteQueriesInterfaceManager {
|
||||
private panel: WebviewPanel | undefined;
|
||||
@@ -54,7 +55,7 @@ export class RemoteQueriesInterfaceManager {
|
||||
* @returns A fully created view model.
|
||||
*/
|
||||
private buildViewModel(query: RemoteQuery, queryResult: RemoteQueryResult): RemoteQueryResultViewModel {
|
||||
const queryFile = path.basename(query.queryFilePath);
|
||||
const queryFileName = path.basename(query.queryFilePath);
|
||||
const totalResultCount = queryResult.analysisResults.reduce((acc, cur) => acc + cur.resultCount, 0);
|
||||
const executionDuration = this.getDuration(queryResult.executionEndTime, query.executionStartTime);
|
||||
const analysisResults = this.buildAnalysisResults(queryResult.analysisResults);
|
||||
@@ -62,9 +63,9 @@ export class RemoteQueriesInterfaceManager {
|
||||
|
||||
return {
|
||||
queryTitle: query.queryName,
|
||||
queryFile: queryFile,
|
||||
queryPath: query.queryFilePath,
|
||||
queryTextTmpFile: query.queryTextTmpFile,
|
||||
queryFileName: queryFileName,
|
||||
queryFilePath: query.queryFilePath,
|
||||
queryTextTmpFilePath: query.queryTextTmpFilePath,
|
||||
totalRepositoryCount: query.repositories.length,
|
||||
affectedRepositoryCount: affectedRepositories.length,
|
||||
totalResultCount: totalResultCount,
|
||||
@@ -132,9 +133,13 @@ export class RemoteQueriesInterfaceManager {
|
||||
});
|
||||
}
|
||||
|
||||
public async openFile(filePath: string) {
|
||||
const textDocument = await workspace.openTextDocument(filePath);
|
||||
await Window.showTextDocument(textDocument, ViewColumn.One);
|
||||
private async openFile(filePath: string) {
|
||||
try {
|
||||
const textDocument = await workspace.openTextDocument(filePath);
|
||||
await Window.showTextDocument(textDocument, ViewColumn.One);
|
||||
} catch (error) {
|
||||
void showAndLogWarningMessage(`Could not open file: ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleMsgFromView(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Repository } from './repository';
|
||||
export interface RemoteQuery {
|
||||
queryName: string;
|
||||
queryFilePath: string;
|
||||
queryTextTmpFile: string;
|
||||
queryTextTmpFilePath: string;
|
||||
controllerRepository: Repository;
|
||||
repositories: Repository[];
|
||||
executionStartTime: Date;
|
||||
|
||||
@@ -468,12 +468,12 @@ function buildRemoteQueryEntity(
|
||||
});
|
||||
|
||||
// TODO: Get query text from query file and save it in a temporary .ql file.
|
||||
const queryTextTmpFile = '';
|
||||
const queryTextTmpFilePath = '';
|
||||
|
||||
return {
|
||||
queryName,
|
||||
queryFilePath,
|
||||
queryTextTmpFile,
|
||||
queryTextTmpFilePath,
|
||||
controllerRepository: {
|
||||
owner: controllerRepoOwner,
|
||||
name: controllerRepoName,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export interface RemoteQueryResult {
|
||||
queryTitle: string;
|
||||
queryFile: string;
|
||||
queryPath: string;
|
||||
queryTextTmpFile: string;
|
||||
queryFileName: string;
|
||||
queryFilePath: string;
|
||||
queryTextTmpFilePath: string;
|
||||
totalRepositoryCount: number;
|
||||
affectedRepositoryCount: number;
|
||||
totalResultCount: number;
|
||||
|
||||
@@ -11,9 +11,9 @@ const numOfReposInContractedMode = 10;
|
||||
|
||||
const emptyQueryResult: RemoteQueryResult = {
|
||||
queryTitle: '',
|
||||
queryFile: '',
|
||||
queryPath: '',
|
||||
queryTextTmpFile: '',
|
||||
queryFileName: '',
|
||||
queryFilePath: '',
|
||||
queryTextTmpFilePath: '',
|
||||
totalRepositoryCount: 0,
|
||||
affectedRepositoryCount: 0,
|
||||
totalResultCount: 0,
|
||||
@@ -74,11 +74,11 @@ export function RemoteQueries(): JSX.Element {
|
||||
|
||||
try {
|
||||
const openQueryFile = () => {
|
||||
openFile(queryResult.queryPath);
|
||||
openFile(queryResult.queryFilePath);
|
||||
};
|
||||
|
||||
const openQueryTextTmpFile = () => {
|
||||
openFile(queryResult.queryTextTmpFile);
|
||||
openFile(queryResult.queryTextTmpFilePath);
|
||||
};
|
||||
|
||||
return <div className="vscode-codeql__remote-queries-view">
|
||||
@@ -91,7 +91,7 @@ export function RemoteQueries(): JSX.Element {
|
||||
<p className="vscode-codeql__paragraph">
|
||||
<span className="vscode-codeql__query-file">{octicons.file}
|
||||
<a className="vscode-codeql__query-file-link" href="#" onClick={openQueryFile}>
|
||||
{queryResult.queryFile}
|
||||
{queryResult.queryFileName}
|
||||
</a>
|
||||
</span>
|
||||
<span>{octicons.codeSquare}
|
||||
|
||||
Reference in New Issue
Block a user