Skip to content

Commit 3e60a11

Browse files
committed
Address review comments.
- Decrease line limit - Adjust constant doc - Add button to show log when database upgrade list is truncated
1 parent d56f51b commit 3e60a11

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

extensions/ql-vscode/src/queries.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { QueryHistoryItemOptions } from './query-history';
1616
import { isQuickQueryPath } from './quick-query';
1717

1818
/**
19-
* Maximum number of lines to put in a binary choice dialog message,
19+
* Maximum number of lines to include from database upgrade message,
2020
* to work around the fact that we can't guarantee a scrollable text
21-
* box for it.
21+
* box for it when displaying in dialog boxes.
2222
*/
23-
const MAX_MESSAGE_LINES = 20;
23+
const MAX_UPGRADE_MESSAGE_LINES = 10;
2424

2525
/**
2626
* queries.ts
@@ -281,12 +281,26 @@ async function checkAndConfirmDatabaseUpgrade(qs: qsClient.QueryServerClient, db
281281
logger.log(descriptionMessage);
282282
// Ask the user to confirm the upgrade.
283283

284+
const showLogItem: vscode.MessageItem = { title: 'No, Show Changes', isCloseAffordance: true };
285+
const yesItem = { title: 'Yes', isCloseAffordance: false };
286+
const noItem = { title: 'No', isCloseAffordance: true }
287+
let dialogOptions: vscode.MessageItem[] = [yesItem, noItem];
288+
284289
let messageLines = descriptionMessage.split('\n');
285-
if (messageLines.length > MAX_MESSAGE_LINES) {
286-
messageLines = messageLines.slice(0, MAX_MESSAGE_LINES);
287-
messageLines.push("... [full list of changes can be found in Output > CodeQL Extension Log]");
290+
if (messageLines.length > MAX_UPGRADE_MESSAGE_LINES) {
291+
messageLines = messageLines.slice(0, MAX_UPGRADE_MESSAGE_LINES);
292+
messageLines.push("... [truncating list of upgrades, click 'No, Show Changes' see full list]");
293+
dialogOptions.push(showLogItem);
288294
}
289-
const shouldUpgrade = await helpers.showBinaryChoiceDialog(`Should the database ${db.databaseUri.fsPath} be upgraded?\n\n${messageLines.join("\n")}`);
295+
296+
const message = `Should the database ${db.databaseUri.fsPath} be upgraded?\n\n${messageLines.join("\n")}`;
297+
const chosenItem = await vscode.window.showInformationMessage(message, { modal: true }, ...dialogOptions);
298+
299+
if (chosenItem === showLogItem) {
300+
logger.outputChannel.show();
301+
}
302+
303+
const shouldUpgrade = chosenItem === yesItem;
290304
if (shouldUpgrade) {
291305
return params;
292306
}

0 commit comments

Comments
 (0)