diff --git a/src/commands/serverCommand.ts b/src/commands/serverCommand.ts
index 6c53cb1b..0837fcca 100644
--- a/src/commands/serverCommand.ts
+++ b/src/commands/serverCommand.ts
@@ -137,7 +137,9 @@ export async function addInsightsConnection(
await updateInsights(insights);
const newInsights = getInsights();
if (newInsights != undefined) {
+ ext.latestLblsChanged.length = 0;
if (labels && labels.length > 0) {
+ ext.latestLblsChanged.push(...labels);
await handleLabelsConnMap(labels, insightsData.alias);
}
ext.serverProvider.refreshInsights(newInsights);
@@ -224,7 +226,9 @@ export async function editInsightsConnection(
const newInsights = getInsights();
if (newInsights != undefined) {
+ ext.latestLblsChanged.length = 0;
if (labels && labels.length > 0) {
+ ext.latestLblsChanged.push(...labels);
await handleLabelsConnMap(labels, insightsData.alias);
} else {
removeConnFromLabels(insightsData.alias);
@@ -386,7 +390,9 @@ export async function addKdbConnection(
await updateServers(servers);
const newServers = getServers();
if (newServers != undefined) {
+ ext.latestLblsChanged.length = 0;
if (labels && labels.length > 0) {
+ ext.latestLblsChanged.push(...labels);
await handleLabelsConnMap(labels, kdbData.serverAlias);
}
Telemetry.sendEvent("Connection.Created.QProcess");
@@ -489,7 +495,9 @@ export async function editKdbConnection(
}
const newServers = getServers();
if (newServers != undefined) {
+ ext.latestLblsChanged.length = 0;
if (labels && labels.length > 0) {
+ ext.latestLblsChanged.push(...labels);
await handleLabelsConnMap(labels, kdbData.serverAlias);
} else {
removeConnFromLabels(kdbData.serverAlias);
diff --git a/src/extensionVariables.ts b/src/extensionVariables.ts
index 3a923739..bac7d95e 100644
--- a/src/extensionVariables.ts
+++ b/src/extensionVariables.ts
@@ -87,6 +87,7 @@ export namespace ext {
export const kdbConnectionAliasList: string[] = [];
export const connLabelList: Labels[] = [];
export const labelConnMapList: ConnectionLabel[] = [];
+ export const latestLblsChanged: string[] = [];
export const maxRetryCount = 5;
export let secretSettings: AuthSettings;
diff --git a/src/panels/newConnection.ts b/src/panels/newConnection.ts
index b6df569f..b20fb989 100644
--- a/src/panels/newConnection.ts
+++ b/src/panels/newConnection.ts
@@ -72,6 +72,16 @@ export class NewConnectionPannel {
}
}
+ public static refreshLabels() {
+ if (NewConnectionPannel.currentPanel) {
+ NewConnectionPannel.currentPanel._panel.webview.postMessage({
+ command: "refreshLabels",
+ data: ext.connLabelList,
+ colors: ext.labelColors,
+ });
+ }
+ }
+
private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
this._extensionUri = extensionUri;
this._panel = panel;
diff --git a/src/services/kdbTreeProvider.ts b/src/services/kdbTreeProvider.ts
index 10cc8b3e..15638986 100644
--- a/src/services/kdbTreeProvider.ts
+++ b/src/services/kdbTreeProvider.ts
@@ -44,6 +44,7 @@ import { InsightsConnection } from "../classes/insightsConnection";
import {
getWorkspaceLabels,
getWorkspaceLabelsConnMap,
+ isLabelContentChanged,
isLabelEmpty,
retrieveConnLabelsNames,
} from "../utils/connLabel";
@@ -820,12 +821,8 @@ export class LabelNode extends TreeItem {
readonly children: TreeItem[] = [];
constructor(public readonly source: Labels) {
- super(
- source.name,
- isLabelEmpty(source.name)
- ? TreeItemCollapsibleState.None
- : TreeItemCollapsibleState.Collapsed,
- );
+ super(source.name);
+ this.collapsibleState = this.getCollapsibleState(source.name);
this.contextValue = "label";
}
@@ -849,4 +846,14 @@ export class LabelNode extends TreeItem {
`label-${this.source.color.name.toLowerCase()}.svg`,
),
};
+
+ getCollapsibleState(labelName: string): TreeItemCollapsibleState {
+ if (isLabelEmpty(labelName)) {
+ return TreeItemCollapsibleState.None;
+ }
+ if (isLabelContentChanged(labelName)) {
+ return TreeItemCollapsibleState.Expanded;
+ }
+ return TreeItemCollapsibleState.Collapsed;
+ }
}
diff --git a/src/utils/connLabel.ts b/src/utils/connLabel.ts
index 61599384..f2c9f4c9 100644
--- a/src/utils/connLabel.ts
+++ b/src/utils/connLabel.ts
@@ -16,6 +16,7 @@ import { workspace } from "vscode";
import { ext } from "../extensionVariables";
import { kdbOutputLog } from "./core";
import { InsightsNode, KdbNode } from "../services/kdbTreeProvider";
+import { NewConnectionPannel } from "../panels/newConnection";
export function getWorkspaceLabels() {
const existingConnLbls = workspace
@@ -144,6 +145,7 @@ export function renameLabel(name: string, newName: string) {
.getConfiguration()
.update("kdb.connectionLabels", ext.connLabelList, true),
);
+ NewConnectionPannel.refreshLabels();
}
export function setLabelColor(name: string, color: string) {
@@ -158,6 +160,7 @@ export function setLabelColor(name: string, color: string) {
workspace
.getConfiguration()
.update("kdb.connectionLabels", ext.connLabelList, true);
+ NewConnectionPannel.refreshLabels();
}
export function deleteLabel(name: string) {
@@ -169,6 +172,8 @@ export function deleteLabel(name: string) {
workspace
.getConfiguration()
.update("kdb.connectionLabels", ext.connLabelList, true);
+
+ NewConnectionPannel.refreshLabels();
}
export function isLabelEmpty(name: string) {
@@ -178,3 +183,11 @@ export function isLabelEmpty(name: string) {
}
return true;
}
+
+export function isLabelContentChanged(name: string) {
+ const found = ext.latestLblsChanged.find((item) => item === name);
+ if (found) {
+ return true;
+ }
+ return false;
+}
diff --git a/src/webview/components/kdbNewConnectionView.ts b/src/webview/components/kdbNewConnectionView.ts
index 5d26fbbd..cc1d551f 100644
--- a/src/webview/components/kdbNewConnectionView.ts
+++ b/src/webview/components/kdbNewConnectionView.ts
@@ -330,7 +330,7 @@ export class KdbNewConnectionView extends LitElement {
renderLblDropdownOptions() {
return html`
-