From 86a0f2d4a705a7467049e4b303f71d837d87ba1f Mon Sep 17 00:00:00 2001 From: AlexFsmn Date: Mon, 27 Aug 2018 23:30:41 +0200 Subject: [PATCH] Connnection string will now automatically copy to clipboard on command. (#2331) * Connnection string will now automatically copy to clipboard on command. #2175 * Reverted information message to show connection string only --- src/sql/parts/connection/common/connectionActions.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sql/parts/connection/common/connectionActions.ts b/src/sql/parts/connection/common/connectionActions.ts index 2164e9a130..dd4287a308 100644 --- a/src/sql/parts/connection/common/connectionActions.ts +++ b/src/sql/parts/connection/common/connectionActions.ts @@ -18,6 +18,7 @@ import { IObjectExplorerService } from '../../objectExplorer/common/objectExplor import { QueryInput } from 'sql/parts/query/common/queryInput'; import { EditDataInput } from 'sql/parts/editData/common/editDataInput'; import { DashboardInput } from 'sql/parts/dashboard/dashboardInput'; +import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; /** * Workbench action to clear the recent connnections list @@ -147,7 +148,8 @@ export class GetCurrentConnectionStringAction extends Action { @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IWorkbenchEditorService private _editorService: IWorkbenchEditorService, @IObjectExplorerService private _objectExplorerService: IObjectExplorerService, - @INotificationService private readonly _notificationService: INotificationService + @INotificationService private readonly _notificationService: INotificationService, + @IClipboardService private _clipboardService: IClipboardService, ) { super(GetCurrentConnectionStringAction.ID, GetCurrentConnectionStringAction.LABEL); this.enabled = true; @@ -161,6 +163,10 @@ export class GetCurrentConnectionStringAction extends Action { let includePassword = false; let connectionProfile = this._connectionManagementService.getConnectionProfile(activeInput.uri); this._connectionManagementService.getConnectionString(connectionProfile.id, includePassword).then(result => { + + //Copy to clipboard + this._clipboardService.writeText(result); + let message = result ? result : nls.localize('connectionAction.connectionString', "Connection string not available");