From 19e812db406cb38efe1650e7a824aa5334404740 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 7 Jun 2024 09:23:57 +0100 Subject: [PATCH 1/4] update to version 1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 936555cf..e899e892 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "kdb", "description": "IDE support for kdb product suite", "publisher": "KX", - "version": "1.5.1", + "version": "1.6.0", "engines": { "vscode": "^1.86.0" }, From f3df60f2dce80679ea74fa76bae2a6f632b78436 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 7 Jun 2024 09:54:04 +0100 Subject: [PATCH 2/4] fix misstyping of insights name --- src/services/kdbTreeProvider.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/kdbTreeProvider.ts b/src/services/kdbTreeProvider.ts index c2e15097..571e31a7 100644 --- a/src/services/kdbTreeProvider.ts +++ b/src/services/kdbTreeProvider.ts @@ -50,7 +50,7 @@ export class KdbTreeProvider implements TreeDataProvider { constructor( private serverList: Server, - private insightList: Insights, + private insightsList: Insights, ) {} reload(): void { @@ -64,7 +64,7 @@ export class KdbTreeProvider implements TreeDataProvider { } refreshInsights(insightsList: Insights): void { - this.insightList = insightsList; + this.insightsList = insightsList; this._onDidChangeTreeData.fire(); } @@ -83,7 +83,7 @@ export class KdbTreeProvider implements TreeDataProvider { if (!this.serverList) { return Promise.resolve([]); } - if (!this.insightList) { + if (!this.insightsList) { return Promise.resolve([]); } @@ -124,7 +124,7 @@ export class KdbTreeProvider implements TreeDataProvider { // eslint-disable-next-line @typescript-eslint/no-unused-vars private getInsightsChildElements(_element?: InsightsNode): InsightsNode[] { - return this.createInsightLeafItems(this.insightList); + return this.createInsightLeafItems(this.insightsList); } private async getNamespaces(): Promise { From 2f4be5804004ce321f463b4fda27b09ebe114aed Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 7 Jun 2024 10:01:23 +0100 Subject: [PATCH 3/4] add refresh meta commands --- package.json | 16 +++++++++++++++- src/commands/serverCommand.ts | 9 +++++++++ src/extension.ts | 10 +++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e899e892..f0380902 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,7 @@ { "category": "KX", "command": "kdb.refreshServerObjects", - "title": "Refresh server objects", + "title": "Refresh server objects & insights meta", "icon": "$(refresh)" }, { @@ -263,6 +263,11 @@ "command": "kdb.connect", "title": "Connect server" }, + { + "category": "KX", + "command": "kdb.insights.refreshMeta", + "title": "Refresh get meta" + }, { "category": "KX", "command": "kdb.connect.via.dialog", @@ -524,6 +529,10 @@ "command": "kdb.insightsRemove", "when": "false" }, + { + "command": "kdb.insights.refreshMeta", + "when": "false" + }, { "command": "kdb.startLocalProcess", "when": "false" @@ -651,6 +660,11 @@ "when": "view == kdb-servers && viewItem not in kdb.insightsNodes && viewItem in kdb.kdbNodesWithoutTls && viewItem not in kdb.local", "group": "connection@4" }, + { + "command": "kdb.insights.refreshMeta", + "when": "view == kdb-servers && viewItem in kdb.connected && viewItem in kdb.insightsNodes", + "group": "connection@3" + }, { "command": "kdb.insightsRemove", "when": "view == kdb-servers && viewItem in kdb.insightsNodes", diff --git a/src/commands/serverCommand.ts b/src/commands/serverCommand.ts index 2f6ad1fa..1eeffad5 100644 --- a/src/commands/serverCommand.ts +++ b/src/commands/serverCommand.ts @@ -313,6 +313,15 @@ export async function resetScratchPad(): Promise { await connMngService.resetScratchpad(); } +export async function refreshGetMeta(connLabel?: string): Promise { + const connMngService = new ConnectionManagementService(); + if (connLabel) { + await connMngService.refreshGetMeta(connLabel); + } else { + await connMngService.refreshAllGetMetas(); + } +} + export async function disconnect(connLabel: string): Promise { const connMngService = new ConnectionManagementService(); connMngService.disconnect(connLabel); diff --git a/src/extension.ts b/src/extension.ts index 32cface3..929157b9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -50,6 +50,7 @@ import { connect, disconnect, enableTLS, + refreshGetMeta, removeConnection, rerunQuery, } from "./commands/serverCommand"; @@ -251,9 +252,16 @@ export async function activate(context: ExtensionContext) { await removeConnection(viewItem); }, ), - commands.registerCommand("kdb.refreshServerObjects", () => { + commands.registerCommand("kdb.refreshServerObjects", async () => { ext.serverProvider.reload(); + await refreshGetMeta(); }), + commands.registerCommand( + "kdb.insights.refreshMeta", + async (viewItem: InsightsNode) => { + await refreshGetMeta(viewItem.label); + }, + ), commands.registerCommand( "kdb.queryHistory.rerun", (viewItem: QueryHistoryTreeItem) => { From 908887916d28d2de58c39e0d3f2528a22bef142e Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 7 Jun 2024 10:08:54 +0100 Subject: [PATCH 4/4] add test for it --- test/suite/commands.test.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/suite/commands.test.ts b/test/suite/commands.test.ts index 41ed35de..005d47a0 100644 --- a/test/suite/commands.test.ts +++ b/test/suite/commands.test.ts @@ -1787,6 +1787,39 @@ describe("serverCommand", () => { windowErrorStub.calledOnce; }); }); + + describe("refreshGetMeta", () => { + let refreshGetMetaStub, refreshAllGetMetasStub: sinon.SinonStub; + beforeEach(() => { + refreshGetMetaStub = sinon.stub( + ConnectionManagementService.prototype, + "refreshGetMeta", + ); + refreshAllGetMetasStub = sinon.stub( + ConnectionManagementService.prototype, + "refreshAllGetMetas", + ); + }); + + afterEach(() => { + sinon.restore(); + }); + + it("should call refreshGetMeta if connLabel is provided", async () => { + await serverCommand.refreshGetMeta("test"); + + sinon.assert.calledOnce(refreshGetMetaStub); + sinon.assert.calledWith(refreshGetMetaStub, "test"); + sinon.assert.notCalled(refreshAllGetMetasStub); + }); + + it("should call refreshAllGetMetas if connLabel is not provided", async () => { + await serverCommand.refreshGetMeta(); + + sinon.assert.notCalled(refreshGetMetaStub); + sinon.assert.calledOnce(refreshAllGetMetasStub); + }); + }); }); describe("walkthroughCommand", () => {