From 6e6ae024e5236964ccda089c5b1252f7b8019302 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 07:41:58 +0100 Subject: [PATCH 1/8] allow user to disable installl kdb popup --- package.json | 4 ++++ src/extension.ts | 2 +- src/utils/core.ts | 25 ++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4fea13e9..b209bd55 100644 --- a/package.json +++ b/package.json @@ -165,6 +165,10 @@ "type": "string", "description": "QHOME directory for q runtime" }, + "kdb.neverShowQInstallAgain": { + "type": "boolean", + "description": "Never show q install walkthrough again" + }, "kdb.hideSubscribeRegistrationNotification": { "type": "boolean", "description": "Hide subscribe for registration notification", diff --git a/src/extension.ts b/src/extension.ts index 0a1688a2..7218d9f8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -181,7 +181,7 @@ export async function activate(context: ExtensionContext) { try { // check for installed q runtime - await checkLocalInstall(); + await checkLocalInstall(true); } catch (err) { window.showErrorMessage(`${err}`); } diff --git a/src/utils/core.ts b/src/utils/core.ts index a60a0b3b..90cef80d 100644 --- a/src/utils/core.ts +++ b/src/utils/core.ts @@ -405,8 +405,18 @@ export function delay(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -export async function checkLocalInstall(): Promise { +export async function checkLocalInstall( + isExtensionStartCheck?: boolean, +): Promise { const QHOME = workspace.getConfiguration().get("kdb.qHomeDirectory"); + if (isExtensionStartCheck) { + const notShow = workspace + .getConfiguration() + .get("kdb.neverShowQInstallAgain"); + if (notShow) { + return; + } + } if (QHOME || env.QHOME) { env.QHOME = QHOME || env.QHOME; if (!pathExists(env.QHOME!)) { @@ -454,12 +464,21 @@ export async function checkLocalInstall(): Promise { .showInformationMessage( "Local q installation not found!", "Install new instance", - "Cancel", + "No", + "Never show again", ) .then(async (installResult) => { if (installResult === "Install new instance") { await installTools(); - } else if (installResult === "Cancel") { + } else if (installResult === "Never show again") { + await workspace + .getConfiguration() + .update( + "kdb.neverShowQInstallAgain", + true, + ConfigurationTarget.Global, + ); + } else { showRegistrationNotification(); } }); From 367378b4196ad557754a11d814d504273dcae40a Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 08:24:29 +0100 Subject: [PATCH 2/8] add tests --- test/suite/utils.test.ts | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index 5e55684a..46eeb336 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -36,6 +36,7 @@ import { openUrl } from "../../src/utils/openUrl"; import * as queryUtils from "../../src/utils/queryUtils"; import { showRegistrationNotification } from "../../src/utils/registration"; import { killPid } from "../../src/utils/shell"; +import { env } from "node:process"; import { showInputBox, showOpenFolderDialog, @@ -1834,4 +1835,45 @@ describe("Utils", () => { assert.strictEqual(result, false); }); }); + + describe("checkLocalInstall", () => { + let getConfigurationStub: sinon.SinonStub; + let updateConfigurationStub: sinon.SinonStub; + let showInformationMessageStub: sinon.SinonStub; + let executeCommandStub: sinon.SinonStub; + let envStub: sinon.SinonStub; + + beforeEach(() => { + getConfigurationStub = sinon + .stub(vscode.workspace, "getConfiguration") + .returns({ + get: sinon.stub().returns(false), + update: sinon.stub().resolves(), + } as any); + updateConfigurationStub = getConfigurationStub() + .update as sinon.SinonStub; + showInformationMessageStub = sinon + .stub(vscode.window, "showInformationMessage") + .resolves(); + executeCommandStub = sinon + .stub(vscode.commands, "executeCommand") + .resolves(); + envStub = sinon.stub(env, "QHOME").value(undefined); + }); + + afterEach(() => { + sinon.restore(); + }); + + it("should return if 'neverShowQInstallAgain' is true", async () => { + getConfigurationStub() + .get.withArgs("kdb.neverShowQInstallAgain") + .returns(true); + + await coreUtils.checkLocalInstall(true); + + assert.strictEqual(showInformationMessageStub.called, false); + assert.strictEqual(executeCommandStub.called, false); + }); + }); }); From 746b67c2d0e05b555ffdf4c5ce1c0b96e777fc64 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 08:27:29 +0100 Subject: [PATCH 3/8] remove obsolete vars --- test/suite/utils.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index 46eeb336..1e947628 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -36,7 +36,6 @@ import { openUrl } from "../../src/utils/openUrl"; import * as queryUtils from "../../src/utils/queryUtils"; import { showRegistrationNotification } from "../../src/utils/registration"; import { killPid } from "../../src/utils/shell"; -import { env } from "node:process"; import { showInputBox, showOpenFolderDialog, @@ -1841,7 +1840,6 @@ describe("Utils", () => { let updateConfigurationStub: sinon.SinonStub; let showInformationMessageStub: sinon.SinonStub; let executeCommandStub: sinon.SinonStub; - let envStub: sinon.SinonStub; beforeEach(() => { getConfigurationStub = sinon @@ -1858,7 +1856,6 @@ describe("Utils", () => { executeCommandStub = sinon .stub(vscode.commands, "executeCommand") .resolves(); - envStub = sinon.stub(env, "QHOME").value(undefined); }); afterEach(() => { From b95f6eb30152eac7703d781701a5971d50e27a5a Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 08:47:01 +0100 Subject: [PATCH 4/8] add more tests --- test/suite/utils.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index 1e947628..035812e5 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -1872,5 +1872,15 @@ describe("Utils", () => { assert.strictEqual(showInformationMessageStub.called, false); assert.strictEqual(executeCommandStub.called, false); }); + it("should continue if 'neverShowQInstallAgain' is false", async () => { + getConfigurationStub() + .get.withArgs("kdb.neverShowQInstallAgain") + .returns(false); + + await coreUtils.checkLocalInstall(true); + + assert.strictEqual(showInformationMessageStub.called, true); + assert.strictEqual(executeCommandStub.called, false); + }); }); }); From e82910b592f4de8213b183cf5617d41aafd6c303 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 08:56:53 +0100 Subject: [PATCH 5/8] add tests --- test/suite/utils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index 035812e5..d90001bf 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -1880,7 +1880,7 @@ describe("Utils", () => { await coreUtils.checkLocalInstall(true); assert.strictEqual(showInformationMessageStub.called, true); - assert.strictEqual(executeCommandStub.called, false); + assert.strictEqual(executeCommandStub.called, true); }); }); }); From 25810fc9d0e80eb979ca0126fbd89084ed126c12 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 09:00:49 +0100 Subject: [PATCH 6/8] add more tests --- test/suite/utils.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index d90001bf..d6fc43d9 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -1882,5 +1882,26 @@ describe("Utils", () => { assert.strictEqual(showInformationMessageStub.called, true); assert.strictEqual(executeCommandStub.called, true); }); + + it("should handle 'Never show again' response", async () => { + getConfigurationStub() + .get.withArgs("kdb.qHomeDirectory") + .returns(undefined); + getConfigurationStub() + .get.withArgs("kdb.neverShowQInstallAgain") + .returns(false); + showInformationMessageStub.resolves("Never show again"); + + await coreUtils.checkLocalInstall(true); + + assert.strictEqual( + updateConfigurationStub.calledWith( + "kdb.neverShowQInstallAgain", + true, + vscode.ConfigurationTarget.Global, + ), + true, + ); + }); }); }); From c8f5fe3987385c0d25f5d53c9bd3a9a74d5c0ed0 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 09:05:58 +0100 Subject: [PATCH 7/8] improve code coverage --- test/suite/utils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index d6fc43d9..26c339eb 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -1892,7 +1892,7 @@ describe("Utils", () => { .returns(false); showInformationMessageStub.resolves("Never show again"); - await coreUtils.checkLocalInstall(true); + await coreUtils.checkLocalInstall(); assert.strictEqual( updateConfigurationStub.calledWith( From 5f38dde954e84952668115f144c362ad8701824c Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Mon, 2 Sep 2024 09:10:12 +0100 Subject: [PATCH 8/8] [KXI-34231] results tab not changing when connected --- src/commands/serverCommand.ts | 1 - src/extension.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/serverCommand.ts b/src/commands/serverCommand.ts index 0837fcca..76c740b5 100644 --- a/src/commands/serverCommand.ts +++ b/src/commands/serverCommand.ts @@ -545,7 +545,6 @@ export async function removeConnection(viewItem: KdbNode | InsightsNode) { export async function connect(connLabel: string): Promise { const connMngService = new ConnectionManagementService(); - commands.executeCommand("kdb-results.focus"); ExecutionConsole.start(); const viewItem = connMngService.retrieveConnection(connLabel); if (viewItem === undefined) { diff --git a/src/extension.ts b/src/extension.ts index 7218d9f8..21f973a2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -177,6 +177,8 @@ export async function activate(context: ExtensionContext) { AuthSettings.init(context); ext.secretSettings = AuthSettings.instance; + commands.executeCommand("kdb-results.focus"); + kdbOutputLog("kdb extension is now active!", "INFO"); try {