Split download actions in remote queries view (#1083)
This commit is contained in:
@@ -377,7 +377,8 @@ export type FromRemoteQueriesMessage =
|
||||
| RemoteQueryErrorMessage
|
||||
| OpenFileMsg
|
||||
| OpenVirtualFileMsg
|
||||
| RemoteQueryDownloadLinkClickedMessage;
|
||||
| RemoteQueryDownloadAnalysisResultsMessage
|
||||
| RemoteQueryDownloadAllAnalysesResultsMessage;
|
||||
|
||||
export type ToRemoteQueriesMessage =
|
||||
| SetRemoteQueryResultMessage;
|
||||
@@ -396,7 +397,13 @@ export interface RemoteQueryErrorMessage {
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface RemoteQueryDownloadLinkClickedMessage {
|
||||
t: 'remoteQueryDownloadLinkClicked';
|
||||
export interface RemoteQueryDownloadAnalysisResultsMessage {
|
||||
t: 'remoteQueryDownloadAnalysisResults';
|
||||
nwo: string
|
||||
downloadLink: DownloadLink;
|
||||
}
|
||||
|
||||
export interface RemoteQueryDownloadAllAnalysesResultsMessage {
|
||||
t: 'remoteQueryDownloadAllAnalysesResults';
|
||||
downloadLink: DownloadLink;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { tmpDir } from '../run-queries';
|
||||
import {
|
||||
ToRemoteQueriesMessage,
|
||||
FromRemoteQueriesMessage,
|
||||
RemoteQueryDownloadLinkClickedMessage,
|
||||
} from '../pure/interface-types';
|
||||
import { Logger } from '../logging';
|
||||
import { getHtmlForWebview } from '../interface-utils';
|
||||
@@ -28,6 +27,7 @@ import { Credentials } from '../authentication';
|
||||
import { showAndLogWarningMessage, showInformationMessageWithAction } from '../helpers';
|
||||
import { URLSearchParams } from 'url';
|
||||
import { SHOW_QUERY_TEXT_MSG } from '../query-history';
|
||||
import { DownloadLink } from './download-link';
|
||||
|
||||
export class RemoteQueriesInterfaceManager {
|
||||
private panel: WebviewPanel | undefined;
|
||||
@@ -189,18 +189,21 @@ export class RemoteQueriesInterfaceManager {
|
||||
case 'openVirtualFile':
|
||||
await this.openVirtualFile(msg.queryText);
|
||||
break;
|
||||
case 'remoteQueryDownloadLinkClicked':
|
||||
await this.handleDownloadLinkClicked(msg);
|
||||
case 'remoteQueryDownloadAnalysisResults':
|
||||
await this.handleDownloadLinkClicked(msg.downloadLink);
|
||||
break;
|
||||
case 'remoteQueryDownloadAllAnalysesResults':
|
||||
await this.handleDownloadLinkClicked(msg.downloadLink);
|
||||
break;
|
||||
default:
|
||||
assertNever(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleDownloadLinkClicked(msg: RemoteQueryDownloadLinkClickedMessage): Promise<void> {
|
||||
private async handleDownloadLinkClicked(downloadLink: DownloadLink): Promise<void> {
|
||||
const credentials = await Credentials.initialize(this.ctx);
|
||||
|
||||
const filePath = await downloadArtifactFromLink(credentials, msg.downloadLink);
|
||||
const filePath = await downloadArtifactFromLink(credentials, downloadLink);
|
||||
const isDir = (await fs.stat(filePath)).isDirectory();
|
||||
const message = `Result file saved at ${filePath}`;
|
||||
if (isDir) {
|
||||
|
||||
@@ -33,9 +33,17 @@ const emptyQueryResult: RemoteQueryResult = {
|
||||
analysisSummaries: []
|
||||
};
|
||||
|
||||
const download = (link: DownloadLink) => {
|
||||
const downloadAnalysisResults = (nwo: string, link: DownloadLink) => {
|
||||
vscode.postMessage({
|
||||
t: 'remoteQueryDownloadLinkClicked',
|
||||
t: 'remoteQueryDownloadAnalysisResults',
|
||||
nwo,
|
||||
downloadLink: link
|
||||
});
|
||||
};
|
||||
|
||||
const downloadAllAnalysesResults = (link: DownloadLink) => {
|
||||
vscode.postMessage({
|
||||
t: 'remoteQueryDownloadAllAnalysesResults',
|
||||
downloadLink: link
|
||||
});
|
||||
};
|
||||
@@ -76,7 +84,9 @@ const QueryInfo = (queryResult: RemoteQueryResult) => (
|
||||
const SummaryTitleWithResults = (queryResult: RemoteQueryResult) => (
|
||||
<div className="vscode-codeql__query-summary-container">
|
||||
<SectionTitle text={`Repositories with results (${queryResult.affectedRepositoryCount}):`} />
|
||||
<DownloadButton text="Download all" onClick={() => download(queryResult.downloadLink)} />
|
||||
<DownloadButton
|
||||
text="Download all"
|
||||
onClick={() => downloadAllAnalysesResults(queryResult.downloadLink)} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -92,7 +102,9 @@ const SummaryItem = (props: AnalysisSummary) => (
|
||||
<span className="vscode-codeql__analysis-item">{props.nwo}</span>
|
||||
<span className="vscode-codeql__analysis-item"><Badge text={props.resultCount.toString()} /></span>
|
||||
<span className="vscode-codeql__analysis-item">
|
||||
<DownloadButton text={props.fileSize} onClick={() => download(props.downloadLink)} />
|
||||
<DownloadButton
|
||||
text={props.fileSize}
|
||||
onClick={() => downloadAnalysisResults(props.nwo, props.downloadLink)} />
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user