Skip to content

Commit 4476955

Browse files
Address PR comments from @aeisenberg and @shati-patel
1 parent 8c1e8a4 commit 4476955

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

extensions/ql-vscode/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,15 @@
462462
"title": "Show Query Text"
463463
},
464464
{
465-
"command": "codeQLQueryHistory.exportCsvResults",
466-
"title": "Export Results (CSV)"
465+
"command": "codeQLQueryHistory.viewCsvResults",
466+
"title": "View Results (CSV)"
467467
},
468468
{
469-
"command": "codeQLQueryHistory.viewCsvResults",
469+
"command": "codeQLQueryHistory.viewCsvAlerts",
470470
"title": "View Alerts (CSV)"
471471
},
472472
{
473-
"command": "codeQLQueryHistory.viewSarifResults",
473+
"command": "codeQLQueryHistory.viewSarifAlerts",
474474
"title": "View Alerts (SARIF)"
475475
},
476476
{
@@ -648,17 +648,17 @@
648648
"when": "view == codeQLQueryHistory"
649649
},
650650
{
651-
"command": "codeQLQueryHistory.exportCsvResults",
651+
"command": "codeQLQueryHistory.viewCsvResults",
652652
"group": "9_qlCommands",
653653
"when": "view == codeQLQueryHistory && viewItem != interpretedResultsItem"
654654
},
655655
{
656-
"command": "codeQLQueryHistory.viewCsvResults",
656+
"command": "codeQLQueryHistory.viewCsvAlerts",
657657
"group": "9_qlCommands",
658658
"when": "view == codeQLQueryHistory && viewItem == interpretedResultsItem"
659659
},
660660
{
661-
"command": "codeQLQueryHistory.viewSarifResults",
661+
"command": "codeQLQueryHistory.viewSarifAlerts",
662662
"group": "9_qlCommands",
663663
"when": "view == codeQLQueryHistory && viewItem == interpretedResultsItem"
664664
},
@@ -810,15 +810,15 @@
810810
"when": "false"
811811
},
812812
{
813-
"command": "codeQLQueryHistory.exportCsvResults",
813+
"command": "codeQLQueryHistory.viewCsvResults",
814814
"when": "false"
815815
},
816816
{
817-
"command": "codeQLQueryHistory.viewCsvResults",
817+
"command": "codeQLQueryHistory.viewCsvAlerts",
818818
"when": "false"
819819
},
820820
{
821-
"command": "codeQLQueryHistory.viewSarifResults",
821+
"command": "codeQLQueryHistory.viewSarifAlerts",
822822
"when": "false"
823823
},
824824
{

extensions/ql-vscode/src/query-history.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path';
2+
import * as fs from 'fs-extra';
23
import * as vscode from 'vscode';
34
import { window as Window, env } from 'vscode';
45
import { CompletedQuery } from './query-results';
@@ -306,20 +307,20 @@ export class QueryHistoryManager extends DisposableObject {
306307
);
307308
this.push(
308309
commandRunner(
309-
'codeQLQueryHistory.exportCsvResults',
310-
this.handleExportCsvResults.bind(this)
310+
'codeQLQueryHistory.viewCsvResults',
311+
this.handleViewCsvResults.bind(this)
311312
)
312313
);
313314
this.push(
314315
commandRunner(
315-
'codeQLQueryHistory.viewCsvResults',
316-
this.handleViewCsvResults.bind(this)
316+
'codeQLQueryHistory.viewCsvAlerts',
317+
this.handleViewCsvAlerts.bind(this)
317318
)
318319
);
319320
this.push(
320321
commandRunner(
321-
'codeQLQueryHistory.viewSarifResults',
322-
this.handleViewSarifResults.bind(this)
322+
'codeQLQueryHistory.viewSarifAlerts',
323+
this.handleViewSarifAlerts.bind(this)
323324
)
324325
);
325326
this.push(
@@ -556,7 +557,7 @@ export class QueryHistoryManager extends DisposableObject {
556557
await vscode.window.showTextDocument(doc, { preview: false });
557558
}
558559

559-
async handleViewSarifResults(
560+
async handleViewSarifAlerts(
560561
singleItem: CompletedQuery,
561562
multiSelect: CompletedQuery[]
562563
) {
@@ -577,33 +578,25 @@ export class QueryHistoryManager extends DisposableObject {
577578
}
578579
}
579580

580-
async handleExportCsvResults(
581+
async handleViewCsvResults(
581582
singleItem: CompletedQuery,
582583
multiSelect: CompletedQuery[]
583584
) {
584585
if (!this.assertSingleQuery(multiSelect)) {
585586
return;
586587
}
587-
588-
const saveLocation = await vscode.window.showSaveDialog({
589-
title: 'CSV Results',
590-
saveLabel: 'Export',
591-
filters: {
592-
'Comma-separated values': ['csv'],
593-
}
594-
});
595-
if (!saveLocation) {
596-
void showAndLogErrorMessage('No save location selected for CSV export!');
588+
if (await singleItem.query.hasCsv()) {
589+
void this.tryOpenExternalFile(singleItem.query.csvPath);
597590
return;
598591
}
599-
await singleItem.query.exportCsvResults(this.qs, saveLocation.fsPath, () => {
592+
await singleItem.query.exportCsvResults(this.qs, singleItem.query.csvPath, () => {
600593
void this.tryOpenExternalFile(
601-
saveLocation.fsPath
594+
singleItem.query.csvPath
602595
);
603596
});
604597
}
605598

606-
async handleViewCsvResults(
599+
async handleViewCsvAlerts(
607600
singleItem: CompletedQuery,
608601
multiSelect: CompletedQuery[]
609602
) {

0 commit comments

Comments
 (0)