Skip to content

Commit 3d9261a

Browse files
fix issues with renaming connection
1 parent c098515 commit 3d9261a

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/commands/dataSourceCommand.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ import { Telemetry } from "../utils/telemetryClient";
4444
import { LocalConnection } from "../classes/localConnection";
4545
import { ConnectionManagementService } from "../services/connectionManagerService";
4646
import { InsightsConnection } from "../classes/insightsConnection";
47-
import { kdbOutputLog, offerConnectAction } from "../utils/core";
47+
import {
48+
kdbOutputLog,
49+
noSelectedConnectionAction,
50+
offerConnectAction,
51+
} from "../utils/core";
4852
import { ServerType } from "../models/connectionsModels";
4953

5054
export async function addDataSource(): Promise<void> {
@@ -118,6 +122,12 @@ export async function runDataSource(
118122
if (DataSourcesPanel.running) {
119123
return;
120124
}
125+
126+
if (connLabel === "") {
127+
noSelectedConnectionAction();
128+
return;
129+
}
130+
121131
DataSourcesPanel.running = true;
122132
const connMngService = new ConnectionManagementService();
123133
const selectedConnection =

src/commands/workspaceCommand.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ export function getServerForUri(uri: Uri) {
173173
"connectionMap",
174174
{},
175175
);
176-
return map[relativePath(uri)];
176+
const server = map[relativePath(uri)];
177+
const servers = getServers();
178+
179+
return server && servers.includes(server) ? server : undefined;
177180
}
178181

179182
/* istanbul ignore next */

src/utils/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ export function offerConnectAction(connLabel: string): void {
357357
});
358358
}
359359

360+
export function noSelectedConnectionAction(): void {
361+
window.showInformationMessage(
362+
`You didn't selected any existing connection to execute this action, please select a connection and try again.`,
363+
);
364+
}
365+
360366
/* istanbul ignore next */
361367
export function offerReconnectionAfterEdit(connLabel: string): void {
362368
window

src/webview/components/kdbDataSourceView.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -914,17 +914,25 @@ export class KdbDataSourceView extends LitElement {
914914
}
915915

916916
renderActions() {
917+
const selectedServerExists = this.servers.includes(this.selectedServer);
918+
if (!selectedServerExists) {
919+
this.selectedServer = "";
920+
}
917921
return html`
918922
<sl-select
919923
label="Connection"
920924
.value="${live(this.selectedServer)}"
921925
@sl-change="${this.requestServerChange}"
922926
?disabled="${this.running}">
923-
<sl-option
924-
.value="${live(this.selectedServer)}"
925-
.selected="${live(true)}"
926-
>${this.selectedServer || "(none)"}</sl-option
927-
>
927+
${!selectedServerExists
928+
? html`<sl-option .value="${live("")}" .selected="${live(true)}"
929+
>(none)</sl-option
930+
>`
931+
: html`<sl-option
932+
.value="${live(this.selectedServer)}"
933+
.selected="${live(true)}"
934+
>${this.selectedServer}</sl-option
935+
>`}
928936
<small>Connections</small>
929937
${this.servers.map(
930938
(server) => html`

0 commit comments

Comments
 (0)