diff --git a/extensions/positron-connections/package.json b/extensions/positron-connections/package.json index f3f8aeaff5d..815904adfb5 100644 --- a/extensions/positron-connections/package.json +++ b/extensions/positron-connections/package.json @@ -53,6 +53,11 @@ "command": "positron.connections.closeConnection", "title": "%commands.closeConnection.title%", "icon": "$(debug-disconnect)" + }, + { + "command": "positron.connections.refresh", + "title": "%commands.refresh.title%", + "icon": "$(refresh)" } ], "menus": { @@ -62,6 +67,11 @@ "group": "inline", "when": "viewItem == database" }, + { + "command": "positron.connections.refresh", + "group": "inline", + "when": "viewItem == database" + }, { "command": "positron.connections.previewTable", "group": "inline", diff --git a/extensions/positron-connections/package.nls.json b/extensions/positron-connections/package.nls.json index 838422a134f..3c6eb4c1937 100644 --- a/extensions/positron-connections/package.nls.json +++ b/extensions/positron-connections/package.nls.json @@ -5,5 +5,6 @@ "view.welcome": "No database connections are currently active.", "commands.previewTable.title": "Preview Table", "commands.previewTable.category": "Connections", - "commands.closeConnection.title": "Close Connection" + "commands.closeConnection.title": "Close Connection", + "commands.refresh.title": "Refresh connection" } diff --git a/extensions/positron-connections/src/connection.ts b/extensions/positron-connections/src/connection.ts index f7308209864..c46b31d5bc5 100644 --- a/extensions/positron-connections/src/connection.ts +++ b/extensions/positron-connections/src/connection.ts @@ -38,7 +38,7 @@ export class ConnectionItem { return ''; } - async contains_data(): Promise { + async contains_data(): Promise { return false; } } @@ -74,6 +74,10 @@ export class ConnectionItemNode extends ConnectionItem { const response = await this.client.performRpc({ msg_type: 'icon_request', path: this.path }) as any; + if (response.error) { + vscode.window.showErrorMessage(`Error getting icon for '${this.name}': ${response.error.message}`); + } + if (response.icon) { this.iconPath = vscode.Uri.file(response.icon); return this.iconPath; @@ -84,13 +88,19 @@ export class ConnectionItemNode extends ConnectionItem { } override async contains_data() { - if (this.containsData) { + if (this.containsData !== undefined) { return this.containsData; } const response = await this.client.performRpc({ msg_type: 'contains_data_request', path: this.path }) as any; - this.containsData = response.contains_data as boolean; + // on error we return 'undefined', a falsy value. Users can decide if that should fail or + // if the it can continue. + if (response.error) { + vscode.window.showErrorMessage(`Error checking if '${this.name}' contains data: ${response.error.message}`); + } + + this.containsData = response.contains_data; return this.containsData; } @@ -100,7 +110,12 @@ export class ConnectionItemNode extends ConnectionItem { // does not contain data. throw new Error('This item does not contain data'); } - await this.client.performRpc({ msg_type: 'preview_table', table: this.name, path: this.path }); + + const response = await this.client.performRpc({ msg_type: 'preview_table', table: this.name, path: this.path }) as any; + + if (response.error) { + vscode.window.showErrorMessage(`Error previewing '${this.name}': ${response.error.message}`); + } } } @@ -179,7 +194,15 @@ export class ConnectionItemsProvider implements vscode.TreeDataProvider; return fields.map((field) => { return new ConnectionItemField(field.name, field.dtype, element.client); @@ -266,6 +312,13 @@ export class ConnectionItemsProvider implements vscode.TreeDataProvider; return children.map((obj) => { const path = [...element.path, { name: obj.name, kind: obj.kind }]; diff --git a/extensions/positron-connections/src/extension.ts b/extensions/positron-connections/src/extension.ts index dba5e0d792d..1e3dd305d1c 100644 --- a/extensions/positron-connections/src/extension.ts +++ b/extensions/positron-connections/src/extension.ts @@ -41,4 +41,10 @@ export function activate(context: vscode.ExtensionContext) { (item: ConnectionItemDatabase) => { item.close(); })); + + context.subscriptions.push( + vscode.commands.registerCommand('positron.connections.refresh', + () => { + connectionProvider.refresh(); + })); }