(treeNode: any)
| 11 | |
| 12 | export class editConnectionCommand extends BaseCommand { |
| 13 | async run(treeNode: any) { |
| 14 | // let selectedConnection: IConnection = null; |
| 15 | let selectedConnId: any = null; |
| 16 | |
| 17 | let connections = Global.context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateKey); |
| 18 | if (!connections) { |
| 19 | vscode.window.showWarningMessage('There are no connections available to rename'); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | if (treeNode && treeNode.connection) { |
| 24 | selectedConnId = treeNode.id; |
| 25 | } else { |
| 26 | let hosts: ConnectionQuickPickItem[] = []; |
| 27 | for (const k in connections) { |
| 28 | if (connections.hasOwnProperty(k)) |
| 29 | hosts.push({ label: connections[k].label || connections[k].host, connection_key: k }); |
| 30 | } |
| 31 | |
| 32 | const hostToSelect = await vscode.window.showQuickPick(hosts, {placeHolder: 'Select a connection', matchOnDetail: false}); |
| 33 | if (!hostToSelect) return; |
| 34 | |
| 35 | selectedConnId = hostToSelect.connection_key; |
| 36 | } |
| 37 | |
| 38 | const configDocument = await vscode.workspace.openTextDocument(vscode.Uri.parse(`postgres-config:/${selectedConnId}.json`)); |
| 39 | await vscode.window.showTextDocument(configDocument); |
| 40 | // const label = await vscode.window.showInputBox({ prompt: "The display name of the database connection", placeHolder: "label", ignoreFocusOut: true }); |
| 41 | // selectedConnection.label = label; |
| 42 | |
| 43 | // connections[selectedConnId] = selectedConnection; |
| 44 | |
| 45 | // const tree = PostgreSQLTreeDataProvider.getInstance(); |
| 46 | // await tree.context.globalState.update(Constants.GlobalStateKey, connections); |
| 47 | // tree.refresh(); |
| 48 | } |
| 49 | } |
nothing calls this directly
no test coverage detected