Skip to content

Commit

Permalink
feat: copy connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhiter committed Nov 7, 2024
1 parent 37b9198 commit 6659db0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions extensions/ide/vscode/devbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
{
"command": "devbox.openExternalLink",
"title": "Devbox:Open in Browser"
},
{
"command": "devbox.copy",
"title": "Copy Connection String"
}
],
"views": {
Expand Down
8 changes: 8 additions & 0 deletions extensions/ide/vscode/devbox/src/commands/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export class ToolCommands extends Disposable {
vscode.env.openExternal(vscode.Uri.parse(args))
})
)
this._register(
vscode.commands.registerCommand('devbox.copy', (connection: string) => {
vscode.env.clipboard.writeText(connection)
vscode.window.showInformationMessage(
'Connection string copied to clipboard!'
)
})
)
}
}
}
13 changes: 11 additions & 2 deletions extensions/ide/vscode/devbox/src/providers/DBViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class DBViewProvider implements vscode.TreeDataProvider<DatabaseItem> {
)}${database.password.padEnd(15)}${database.host.padEnd(
20
)}${database.port.toString().padEnd(10)}${database.connection}`
items.push(new DatabaseItem(label, 'database'))
items.push(new DatabaseItem(label, 'database', database.connection))
})

return items
Expand All @@ -83,8 +83,17 @@ export class DBViewProvider implements vscode.TreeDataProvider<DatabaseItem> {
class DatabaseItem extends vscode.TreeItem {
constructor(
public override readonly label: string,
public override readonly contextValue: string
public override readonly contextValue: string,
public readonly connection?: string
) {
super(label, vscode.TreeItemCollapsibleState.None)

if (connection) {
this.command = {
title: 'Copy Connection String',
command: 'devbox.copy',
arguments: [connection],
}
}
}
}

0 comments on commit 6659db0

Please sign in to comment.