Address PR comments from @aeisenberg and @shati-patel

This commit is contained in:
Edoardo Pirovano
2021-08-19 15:58:12 +01:00
committed by Edoardo Pirovano
parent 2561db1721
commit f494988ba6
2 changed files with 27 additions and 35 deletions

View File

@@ -462,15 +462,15 @@
"title": "Show Query Text"
},
{
"command": "codeQLQueryHistory.exportCsvResults",
"title": "Export Results (CSV)"
"command": "codeQLQueryHistory.viewCsvResults",
"title": "View Results (CSV)"
},
{
"command": "codeQLQueryHistory.viewCsvResults",
"command": "codeQLQueryHistory.viewCsvAlerts",
"title": "View Alerts (CSV)"
},
{
"command": "codeQLQueryHistory.viewSarifResults",
"command": "codeQLQueryHistory.viewSarifAlerts",
"title": "View Alerts (SARIF)"
},
{
@@ -648,17 +648,17 @@
"when": "view == codeQLQueryHistory"
},
{
"command": "codeQLQueryHistory.exportCsvResults",
"command": "codeQLQueryHistory.viewCsvResults",
"group": "9_qlCommands",
"when": "view == codeQLQueryHistory && viewItem != interpretedResultsItem"
},
{
"command": "codeQLQueryHistory.viewCsvResults",
"command": "codeQLQueryHistory.viewCsvAlerts",
"group": "9_qlCommands",
"when": "view == codeQLQueryHistory && viewItem == interpretedResultsItem"
},
{
"command": "codeQLQueryHistory.viewSarifResults",
"command": "codeQLQueryHistory.viewSarifAlerts",
"group": "9_qlCommands",
"when": "view == codeQLQueryHistory && viewItem == interpretedResultsItem"
},
@@ -809,16 +809,16 @@
"command": "codeQLQueryHistory.showQueryText",
"when": "false"
},
{
"command": "codeQLQueryHistory.exportCsvResults",
"when": "false"
},
{
"command": "codeQLQueryHistory.viewCsvResults",
"when": "false"
},
{
"command": "codeQLQueryHistory.viewSarifResults",
"command": "codeQLQueryHistory.viewCsvAlerts",
"when": "false"
},
{
"command": "codeQLQueryHistory.viewSarifAlerts",
"when": "false"
},
{

View File

@@ -304,12 +304,6 @@ export class QueryHistoryManager extends DisposableObject {
this.handleShowQueryText.bind(this)
)
);
this.push(
commandRunner(
'codeQLQueryHistory.exportCsvResults',
this.handleExportCsvResults.bind(this)
)
);
this.push(
commandRunner(
'codeQLQueryHistory.viewCsvResults',
@@ -318,8 +312,14 @@ export class QueryHistoryManager extends DisposableObject {
);
this.push(
commandRunner(
'codeQLQueryHistory.viewSarifResults',
this.handleViewSarifResults.bind(this)
'codeQLQueryHistory.viewCsvAlerts',
this.handleViewCsvAlerts.bind(this)
)
);
this.push(
commandRunner(
'codeQLQueryHistory.viewSarifAlerts',
this.handleViewSarifAlerts.bind(this)
)
);
this.push(
@@ -556,7 +556,7 @@ export class QueryHistoryManager extends DisposableObject {
await vscode.window.showTextDocument(doc, { preview: false });
}
async handleViewSarifResults(
async handleViewSarifAlerts(
singleItem: CompletedQuery,
multiSelect: CompletedQuery[]
) {
@@ -577,33 +577,25 @@ export class QueryHistoryManager extends DisposableObject {
}
}
async handleExportCsvResults(
async handleViewCsvResults(
singleItem: CompletedQuery,
multiSelect: CompletedQuery[]
) {
if (!this.assertSingleQuery(multiSelect)) {
return;
}
const saveLocation = await vscode.window.showSaveDialog({
title: 'CSV Results',
saveLabel: 'Export',
filters: {
'Comma-separated values': ['csv'],
}
});
if (!saveLocation) {
void showAndLogErrorMessage('No save location selected for CSV export!');
if (await singleItem.query.hasCsv()) {
void this.tryOpenExternalFile(singleItem.query.csvPath);
return;
}
await singleItem.query.exportCsvResults(this.qs, saveLocation.fsPath, () => {
await singleItem.query.exportCsvResults(this.qs, singleItem.query.csvPath, () => {
void this.tryOpenExternalFile(
saveLocation.fsPath
singleItem.query.csvPath
);
});
}
async handleViewCsvResults(
async handleViewCsvAlerts(
singleItem: CompletedQuery,
multiSelect: CompletedQuery[]
) {