Skip to content

Commit

Permalink
Merge pull request #439 from KxSystems/KXI-54216
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro-KX authored Oct 13, 2024
2 parents 0c222ac + d3fd871 commit 88cda4c
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 32 deletions.
55 changes: 27 additions & 28 deletions src/classes/insightsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class InsightsConnection {
isTableView: false,
params: queryParams,
};
window.withProgress(
await window.withProgress(
{
location: ProgressLocation.Notification,
cancellable: false,
Expand All @@ -358,33 +358,32 @@ export class InsightsConnection {

progress.report({ message: "Populating scratchpad..." });

const scratchpadResponse = await axios.post(
scratchpadURL.toString(),
body,
headers,
);

kdbOutputLog(
`Executed successfully, stored in ${variableName}.`,
"INFO",
);
kdbOutputLog(
`[SCRATCHPAD] Status: ${scratchpadResponse.status}`,
"INFO",
);
kdbOutputLog(
`[SCRATCHPAD] Populated scratchpad with the following params: ${JSON.stringify(body.params)}`,
"INFO",
);
window.showInformationMessage(
`Executed successfully, stored in ${variableName}.`,
);
Telemetry.sendEvent(
"Datasource." + dsTypeString + ".Scratchpad.Populated",
);

const p = new Promise<void>((resolve) => resolve());
return p;
return await axios
.post(scratchpadURL.toString(), body, headers)
.then((response: any) => {
if (response.data.error) {
kdbOutputLog(
`[SCRATCHPAD] Error occured while populating scratchpad: ${response.data.errorMsg}`,
"ERROR",
);
} else {
kdbOutputLog(
`Executed successfully, stored in ${variableName}.`,
"INFO",
);
kdbOutputLog(`[SCRATCHPAD] Status: ${response.status}`, "INFO");
kdbOutputLog(
`[SCRATCHPAD] Populated scratchpad with the following params: ${JSON.stringify(body.params)}`,
"INFO",
);
window.showInformationMessage(
`Executed successfully, stored in ${variableName}.`,
);
Telemetry.sendEvent(
"Datasource." + dsTypeString + ".Scratchpad.Populated",
);
}
});
},
);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/connLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export function removeConnFromLabels(connName: string) {
);
}
});
workspace
.getConfiguration()
.update("kdb.labelsConnectionMap", ext.labelConnMapList, true);
}

export async function handleLabelsConnMap(labels: string[], connName: string) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export async function checkOpenSslInstalled(): Promise<string | null> {
return semver.clean(installedVersion ? installedVersion[1] : "");
}
} catch (err) {
kdbOutputLog(`Error in checking OpenSSL version: ${err}`, "ERROR");
// Disabled the error, as it is not critical
// kdbOutputLog(`Error in checking OpenSSL version: ${err}`, "ERROR");
Telemetry.sendException(err as Error);
}
return null;
Expand Down
3 changes: 1 addition & 2 deletions src/webview/components/kdbDataSourceView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,7 @@ export class KdbDataSourceView extends LitElement {
).value;
this.requestChange();
}}"
>Start Time
${this.selectedServerVersion}</vscode-text-field
>Start Time</vscode-text-field
>
<vscode-text-field
Expand Down
2 changes: 1 addition & 1 deletion src/webview/components/kdbNewConnectionView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ export class KdbNewConnectionView extends LitElement {
},
});
setTimeout(() => {
this.labels[0] = this.newLblName;
this.labels.unshift(this.newLblName);
this.closeModal();
}, 500);
}
Expand Down
4 changes: 4 additions & 0 deletions test/suite/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,10 @@ describe("Utils", () => {
labelName: "label1",
connections: ["conn1", "conn2"],
});
getConfigurationStub.returns({
get: sinon.stub(),
update: sinon.stub(),
});

LabelsUtils.removeConnFromLabels("conn1");

Expand Down
36 changes: 36 additions & 0 deletions test/suite/webview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,40 @@ describe("KdbNewConnectionView", () => {
});
});

describe("createLabel", () => {
let clock: sinon.SinonFakeTimers;

beforeEach(() => {
clock = sinon.useFakeTimers();
});

afterEach(() => {
clock.restore();
});

it("should post a message and update labels after timeout", () => {
const api = acquireVsCodeApi();
const postMessageStub = sinon.stub(api, "postMessage");
const closeModalStub = sinon.stub(view, "closeModal");

view.newLblName = "Test Label";
view.newLblColorName = "Test Color";
view.labels = [];

view.createLabel();

sinon.assert.calledOnce(postMessageStub);

// Avança o tempo em 500ms
clock.tick(500);

assert.equal(view.labels[0], "Test Label");
sinon.assert.calledOnce(closeModalStub);

sinon.restore();
});
});

describe("edit", () => {
const editConn: EditConnectionMessage = {
connType: 0,
Expand Down Expand Up @@ -931,4 +965,6 @@ describe("KdbNewConnectionView", () => {
sinon.restore();
});
});

describe("createLabel", () => {});
});

0 comments on commit 88cda4c

Please sign in to comment.