Skip to content

Commit

Permalink
Merge pull request #345 from KxSystems/KXI-47787
Browse files Browse the repository at this point in the history
[KXI-47787] Get Meta refresh
  • Loading branch information
Philip-Carneiro-KX authored Jun 7, 2024
2 parents 7336742 + 9088879 commit 9947d88
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -183,7 +183,7 @@
{
"category": "KX",
"command": "kdb.refreshServerObjects",
"title": "Refresh server objects",
"title": "Refresh server objects & insights meta",
"icon": "$(refresh)"
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -524,6 +529,10 @@
"command": "kdb.insightsRemove",
"when": "false"
},
{
"command": "kdb.insights.refreshMeta",
"when": "false"
},
{
"command": "kdb.startLocalProcess",
"when": "false"
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/commands/serverCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ export async function resetScratchPad(): Promise<void> {
await connMngService.resetScratchpad();
}

export async function refreshGetMeta(connLabel?: string): Promise<void> {
const connMngService = new ConnectionManagementService();
if (connLabel) {
await connMngService.refreshGetMeta(connLabel);
} else {
await connMngService.refreshAllGetMetas();
}
}

export async function disconnect(connLabel: string): Promise<void> {
const connMngService = new ConnectionManagementService();
connMngService.disconnect(connLabel);
Expand Down
10 changes: 9 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
connect,
disconnect,
enableTLS,
refreshGetMeta,
removeConnection,
rerunQuery,
} from "./commands/serverCommand";
Expand Down Expand Up @@ -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) => {
Expand Down
8 changes: 4 additions & 4 deletions src/services/kdbTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class KdbTreeProvider implements TreeDataProvider<TreeItem> {

constructor(
private serverList: Server,
private insightList: Insights,
private insightsList: Insights,
) {}

reload(): void {
Expand All @@ -64,7 +64,7 @@ export class KdbTreeProvider implements TreeDataProvider<TreeItem> {
}

refreshInsights(insightsList: Insights): void {
this.insightList = insightsList;
this.insightsList = insightsList;
this._onDidChangeTreeData.fire();
}

Expand All @@ -83,7 +83,7 @@ export class KdbTreeProvider implements TreeDataProvider<TreeItem> {
if (!this.serverList) {
return Promise.resolve([]);
}
if (!this.insightList) {
if (!this.insightsList) {
return Promise.resolve([]);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ export class KdbTreeProvider implements TreeDataProvider<TreeItem> {

// 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<QNamespaceNode[]> {
Expand Down
33 changes: 33 additions & 0 deletions test/suite/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 9947d88

Please sign in to comment.