diff --git a/src/extension.ts b/src/extension.ts index ff3e8538b..779ac5d50 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -97,18 +97,21 @@ export function activate(context: vscode.ExtensionContext) { initCommand(context, 'cosmosDB.openInPortal', (node: IAzureNode) => node.openInPortal()); initAsyncCommand(context, 'cosmosDB.copyConnectionString', (node: IAzureNode) => copyConnectionString(node)); - vscode.window.setStatusBarMessage('Mongo: Not connected'); initAsyncCommand(context, 'cosmosDB.connectMongoDB', async (node: IAzureParentNode) => { + if (connectedDb) { + connectedDb.treeItem.isConnected = false; + connectedDb.refresh(); + } connectedDb = node; await languageClient.connect(connectedDb.treeItem.connectionString); - vscode.window.setStatusBarMessage('Mongo: ' + node.parent.treeItem.label + '/' + connectedDb.treeItem.label); + connectedDb.treeItem.isConnected = true; + node.refresh(); }); initAsyncCommand(context, 'cosmosDB.deleteMongoDB', async (node: IAzureNode) => { await node.deleteNode(); if (connectedDb && connectedDb.treeItem.id === node.treeItem.id) { connectedDb = null; languageClient.disconnect(); - vscode.window.setStatusBarMessage('Mongo: Not connected'); } }); initAsyncCommand(context, 'cosmosDB.deleteMongoCollection', (node: IAzureNode) => node.deleteNode()); diff --git a/src/mongo/tree/MongoDatabaseTreeItem.ts b/src/mongo/tree/MongoDatabaseTreeItem.ts index ba5651bb2..0e17f828e 100644 --- a/src/mongo/tree/MongoDatabaseTreeItem.ts +++ b/src/mongo/tree/MongoDatabaseTreeItem.ts @@ -21,6 +21,7 @@ export class MongoDatabaseTreeItem implements IAzureParentTreeItem { private readonly _databaseName: string; private readonly _accountConnectionString: string; private readonly _parentId: string; + public isConnected: boolean = false; constructor(databaseName: string, accountConnectionString: string, parentId: string) { this._databaseName = databaseName; @@ -31,6 +32,9 @@ export class MongoDatabaseTreeItem implements IAzureParentTreeItem { } public get label(): string { + if (this.isConnected) { + return this._databaseName + " (Connected)"; + } return this._databaseName; }