Skip to content

Commit 2f41c30

Browse files
authored
Merge pull request #220 from jcreedcmu/jcreed/long-dbupgrade-msg
Truncate long database upgrade messages in native dialog box
2 parents 40e7657 + e5b0117 commit 2f41c30

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ jobs:
1414
with:
1515
fetch-depth: 1
1616

17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: '10.18.1'
20+
1721
- name: Build
1822
run: |
1923
cd build
@@ -46,6 +50,10 @@ jobs:
4650
with:
4751
fetch-depth: 1
4852

53+
- uses: actions/setup-node@v1
54+
with:
55+
node-version: '10.18.1'
56+
4957
# We have to build the dependencies in `lib` before running any tests.
5058
- name: Build
5159
run: |
@@ -86,4 +94,4 @@ jobs:
8694
if: matrix.os == 'windows-latest'
8795
run: |
8896
cd extensions/ql-vscode
89-
npm run integration
97+
npm run integration

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ jobs:
2929
- name: Checkout
3030
uses: actions/checkout@master
3131

32+
- uses: actions/setup-node@v1
33+
with:
34+
node-version: '10.18.1'
35+
3236
# The checkout action does not fetch the master branch.
3337
# Fetch the master branch so that we can base the version bump PR against master.
3438
- name: Fetch master branch

extensions/ql-vscode/src/queries.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import { promisify } from 'util';
1515
import { QueryHistoryItemOptions } from './query-history';
1616
import { isQuickQueryPath } from './quick-query';
1717

18+
/**
19+
* Maximum number of lines to include from database upgrade message,
20+
* to work around the fact that we can't guarantee a scrollable text
21+
* box for it when displaying in dialog boxes.
22+
*/
23+
const MAX_UPGRADE_MESSAGE_LINES = 10;
24+
1825
/**
1926
* queries.ts
2027
* -------------
@@ -273,8 +280,27 @@ async function checkAndConfirmDatabaseUpgrade(qs: qsClient.QueryServerClient, db
273280

274281
logger.log(descriptionMessage);
275282
// Ask the user to confirm the upgrade.
276-
const shouldUpgrade = await helpers.showBinaryChoiceDialog(`Should the database ${db.databaseUri.fsPath} be upgraded?\n\n${descriptionMessage}`);
277-
if (shouldUpgrade) {
283+
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+
289+
let messageLines = descriptionMessage.split('\n');
290+
if (messageLines.length > MAX_UPGRADE_MESSAGE_LINES) {
291+
messageLines = messageLines.slice(0, MAX_UPGRADE_MESSAGE_LINES);
292+
messageLines.push(`The list of upgrades was truncated, click "No, Show Changes" to see the full list.`);
293+
dialogOptions.push(showLogItem);
294+
}
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+
if (chosenItem === yesItem) {
278304
return params;
279305
}
280306
else {

0 commit comments

Comments
 (0)