diff --git a/package.json b/package.json index 315108e..d537777 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "servermanager", "displayName": "InterSystems Server Manager", - "version": "2.0.0-SNAPSHOT.3", + "version": "2.0.0-SNAPSHOT.4", "publisher": "intersystems-community", "description": "Helper extension for defining connections to InterSystems servers.", "repository": { @@ -246,7 +246,7 @@ }, { "command": "intersystems-community.servermanager.retryServer", - "title": "Reconnect", + "title": "Refresh", "icon": "$(refresh)" }, { @@ -427,6 +427,11 @@ "when": "view == intersystems-community_servermanager && viewItem =~ /\\.server\\./", "group": "inline@90" }, + { + "command": "intersystems-community.servermanager.retryServer", + "when": "view == intersystems-community_servermanager && viewItem =~ /\\.server\\./", + "group": "0_refresh@10" + }, { "submenu": "intersystems-community.servermanager.iconColor", "when": "view == intersystems-community_servermanager && viewItem =~ /\\.server\\./", diff --git a/src/extension.ts b/src/extension.ts index 74e32cf..99a6bda 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,7 +7,7 @@ import { getServerNames } from './api/getServerNames'; import { getServerSpec } from './api/getServerSpec'; import { storePassword, clearPassword } from './commands/managePasswords'; import { importFromRegistry } from './commands/importFromRegistry'; -import { ServerManagerView, ServerTreeItem } from './ui/serverManagerView'; +import { ServerManagerView, ServerTreeItem, SMTreeItem } from './ui/serverManagerView'; import { addServer } from './api/addServer'; import { getPortalUriWithCredentials } from './api/getPortalUriWithCredentials'; import { getServerSummary } from './api/getServerSummary'; @@ -188,8 +188,17 @@ export function activate(context: vscode.ExtensionContext) { ); context.subscriptions.push( - vscode.commands.registerCommand(`${extensionId}.retryServer`, () => { - view.refreshTree(); + vscode.commands.registerCommand(`${extensionId}.retryServer`, (treeItem: SMTreeItem) => { + const depth = treeItem.id?.split(':').length; + if (depth === 2) { + view.refreshTree(treeItem); + } + else if (depth === 3) { + view.refreshTree(treeItem.parent); + } + else if (depth === 4) { + view.refreshTree(treeItem.parent?.parent); + } }) ); diff --git a/src/ui/serverManagerView.ts b/src/ui/serverManagerView.ts index 4de8d9d..45e8ca3 100644 --- a/src/ui/serverManagerView.ts +++ b/src/ui/serverManagerView.ts @@ -23,8 +23,6 @@ export class ServerManagerView { private _globalState: vscode.Memento; - private _treeView: vscode.TreeView; - private _treeDataProvider: SMNodeProvider; constructor(context: vscode.ExtensionContext) { @@ -33,7 +31,6 @@ export class ServerManagerView { this._treeDataProvider = treeDataProvider; const treeView = vscode.window.createTreeView('intersystems-community_servermanager', { treeDataProvider, showCollapseAll: true }) - this._treeView = treeView; context.subscriptions.push(treeView); treeDataProvider.view = treeView; @@ -91,8 +88,8 @@ export class ServerManagerView { } }; - refreshTree() { - this._treeDataProvider.refresh(); + refreshTree(item?: SMTreeItem | undefined) { + this._treeDataProvider.refresh(item); } } @@ -109,8 +106,8 @@ class SMNodeProvider implements vscode.TreeDataProvider { constructor() { } - refresh(): void { - this._onDidChangeTreeData.fire(); + refresh(item: SMTreeItem | undefined): void { + this._onDidChangeTreeData.fire(item); } getTreeItem(element:SMTreeItem): vscode.TreeItem { @@ -183,7 +180,7 @@ interface SMItem { params?: any, } -class SMTreeItem extends vscode.TreeItem { +export class SMTreeItem extends vscode.TreeItem { private readonly _getChildren?: Function; private readonly _params?: any;