mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Adds "Get Connection String" command (#2108)
* Initial connection string changes * Add Get Connection String methods * Add IncludePassword parameter * Update Data Protocol and Tools Service versions * Update dataprotocol to 0.2.2 * Try to update the dataprotocol component again * Fix a few bugs related to getting the current editor connection uri
This commit is contained in:
@@ -658,7 +658,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.2.0",
|
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.2.3",
|
||||||
"opener": "^1.4.3",
|
"opener": "^1.4.3",
|
||||||
"service-downloader": "github:anthonydresser/service-downloader#0.1.4",
|
"service-downloader": "github:anthonydresser/service-downloader#0.1.4",
|
||||||
"vscode-extension-telemetry": "^0.0.15"
|
"vscode-extension-telemetry": "^0.0.15"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||||
"version": "1.5.0-alpha.18",
|
"version": "1.5.0-alpha.19",
|
||||||
"downloadFileNames": {
|
"downloadFileNames": {
|
||||||
"Windows_86": "win-x86-netcoreapp2.1.zip",
|
"Windows_86": "win-x86-netcoreapp2.1.zip",
|
||||||
"Windows_64": "win-x64-netcoreapp2.1.zip",
|
"Windows_64": "win-x64-netcoreapp2.1.zip",
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ core-util-is@~1.0.0:
|
|||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||||
|
|
||||||
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#0.2.0":
|
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#0.2.3":
|
||||||
version "0.2.0"
|
version "0.2.3"
|
||||||
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/c7a691c7fc5ad54a147090784a7f11efda301f4b"
|
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/4dd3c6ae27aa0aa10361336c19e15f183ea13c47"
|
||||||
dependencies:
|
dependencies:
|
||||||
vscode-languageclient "3.5.0"
|
vscode-languageclient "3.5.0"
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { IExtensionGalleryService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
import { IExtensionGalleryService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||||
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
|
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
|
||||||
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||||
@@ -13,10 +13,9 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||||||
import { DashboardEditor } from 'sql/parts/dashboard/dashboardEditor';
|
import { DashboardEditor } from 'sql/parts/dashboard/dashboardEditor';
|
||||||
import { DashboardInput } from 'sql/parts/dashboard/dashboardInput';
|
import { DashboardInput } from 'sql/parts/dashboard/dashboardInput';
|
||||||
import { AddServerGroupAction, AddServerAction } from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
|
import { AddServerGroupAction, AddServerAction } from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
|
||||||
import { ClearRecentConnectionsAction } from 'sql/parts/connection/common/connectionActions';
|
import { ClearRecentConnectionsAction, GetCurrentConnectionStringAction } from 'sql/parts/connection/common/connectionActions';
|
||||||
|
|
||||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||||
import { EditorDescriptor } from 'vs/workbench/browser/editor';
|
|
||||||
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
|
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
|
||||||
import { ExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/node/extensionsWorkbenchService';
|
import { ExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/node/extensionsWorkbenchService';
|
||||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||||
@@ -49,6 +48,7 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
),
|
),
|
||||||
ClearRecentConnectionsAction.LABEL
|
ClearRecentConnectionsAction.LABEL
|
||||||
);
|
);
|
||||||
|
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
new SyncActionDescriptor(
|
new SyncActionDescriptor(
|
||||||
AddServerGroupAction,
|
AddServerGroupAction,
|
||||||
@@ -67,6 +67,15 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
AddServerAction.LABEL
|
AddServerAction.LABEL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
actionRegistry.registerWorkbenchAction(
|
||||||
|
new SyncActionDescriptor(
|
||||||
|
GetCurrentConnectionStringAction,
|
||||||
|
GetCurrentConnectionStringAction.ID,
|
||||||
|
GetCurrentConnectionStringAction.LABEL
|
||||||
|
),
|
||||||
|
GetCurrentConnectionStringAction.LABEL
|
||||||
|
);
|
||||||
|
|
||||||
let configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
|
let configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
|
||||||
configurationRegistry.registerConfiguration({
|
configurationRegistry.registerConfiguration({
|
||||||
'id': 'connection',
|
'id': 'connection',
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ import { IConnectionManagementService } from 'sql/parts/connection/common/connec
|
|||||||
import { INotificationService, INotificationActions } from 'vs/platform/notification/common/notification';
|
import { INotificationService, INotificationActions } from 'vs/platform/notification/common/notification';
|
||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
|
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
|
||||||
|
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
|
import { IObjectExplorerService } from '../../objectExplorer/common/objectExplorerService';
|
||||||
|
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||||
|
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
||||||
|
import { DashboardInput } from 'sql/parts/dashboard/dashboardInput';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workbench action to clear the recent connnections list
|
* Workbench action to clear the recent connnections list
|
||||||
@@ -126,4 +131,44 @@ export class ClearSingleRecentConnectionAction extends Action {
|
|||||||
this._onRecentConnectionRemoved.fire();
|
this._onRecentConnectionRemoved.fire();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to retrieve the current connection string
|
||||||
|
*/
|
||||||
|
export class GetCurrentConnectionStringAction extends Action {
|
||||||
|
|
||||||
|
public static ID = 'getCurrentConnectionStringAction';
|
||||||
|
public static LABEL = nls.localize('connectionAction.GetCurrentConnectionString', "Get Current Connection String");
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||||
|
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||||
|
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
||||||
|
@INotificationService private readonly _notificationService: INotificationService
|
||||||
|
) {
|
||||||
|
super(GetCurrentConnectionStringAction.ID, GetCurrentConnectionStringAction.LABEL);
|
||||||
|
this.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public run(): TPromise<void> {
|
||||||
|
return new TPromise<void>((resolve, reject) => {
|
||||||
|
let activeInput = this._editorService.getActiveEditorInput();
|
||||||
|
if (activeInput && (activeInput instanceof QueryInput || activeInput instanceof EditDataInput || activeInput instanceof DashboardInput)
|
||||||
|
&& this._connectionManagementService.isConnected(activeInput.uri)) {
|
||||||
|
let includePassword = false;
|
||||||
|
this._connectionManagementService.getConnectionString(activeInput.uri, includePassword).then(result => {
|
||||||
|
let message = result
|
||||||
|
? result
|
||||||
|
: nls.localize('connectionAction.connectionString', "Connection string not available");
|
||||||
|
this._notificationService.info(message);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let message = nls.localize('connectionAction.noConnection', "No active connection available");
|
||||||
|
this._notificationService.info(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -260,6 +260,11 @@ export interface IConnectionManagementService {
|
|||||||
* in the connection profile's options dictionary, or undefined if the profile is not connected
|
* in the connection profile's options dictionary, or undefined if the profile is not connected
|
||||||
*/
|
*/
|
||||||
getActiveConnectionCredentials(profileId: string): { [name: string]: string };
|
getActiveConnectionCredentials(profileId: string): { [name: string]: string };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the connection string for the provided connection profile
|
||||||
|
*/
|
||||||
|
getConnectionString(ownerUri: string, includePassword: boolean): Thenable<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IConnectionDialogService = createDecorator<IConnectionDialogService>('connectionDialogService');
|
export const IConnectionDialogService = createDecorator<IConnectionDialogService>('connectionDialogService');
|
||||||
|
|||||||
@@ -1345,4 +1345,24 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
|||||||
credentials[passwordOption.name] = profile.options[passwordOption.name];
|
credentials[passwordOption.name] = profile.options[passwordOption.name];
|
||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the connection string for the provided connection profile
|
||||||
|
*/
|
||||||
|
public getConnectionString(ownerUri: string, includePassword: boolean = false): Thenable<string> {
|
||||||
|
if (!ownerUri) {
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
let providerId = this.getProviderIdFromUri(ownerUri);
|
||||||
|
if (!providerId) {
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._providers.get(providerId).onReady.then(provider => {
|
||||||
|
return provider.getConnectionString(ownerUri, includePassword).then(connectionString => {
|
||||||
|
return connectionString;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/sql/sqlops.d.ts
vendored
7
src/sql/sqlops.d.ts
vendored
@@ -87,6 +87,11 @@ declare module 'sqlops' {
|
|||||||
*/
|
*/
|
||||||
export function getActiveConnections(): Thenable<Connection[]>;
|
export function getActiveConnections(): Thenable<Connection[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get connection string
|
||||||
|
*/
|
||||||
|
export function getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the credentials for an active connection
|
* Get the credentials for an active connection
|
||||||
* @param {string} connectionId The id of the connection
|
* @param {string} connectionId The id of the connection
|
||||||
@@ -322,6 +327,8 @@ declare module 'sqlops' {
|
|||||||
|
|
||||||
rebuildIntelliSenseCache(connectionUri: string): Thenable<void>;
|
rebuildIntelliSenseCache(connectionUri: string): Thenable<void>;
|
||||||
|
|
||||||
|
getConnectionString(connectionUri: string, includePassword: boolean): Thenable<string> ;
|
||||||
|
|
||||||
registerOnConnectionComplete(handler: (connSummary: ConnectionInfoSummary) => any): void;
|
registerOnConnectionComplete(handler: (connSummary: ConnectionInfoSummary) => any): void;
|
||||||
|
|
||||||
registerOnIntelliSenseCacheComplete(handler: (connectionUri: string) => any): void;
|
registerOnIntelliSenseCacheComplete(handler: (connectionUri: string) => any): void;
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
|||||||
return this._proxy.$listDatabases(connectionId);
|
return this._proxy.$listDatabases(connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||||
|
return this._proxy.$getConnectionString(connectionId, includePassword);
|
||||||
|
}
|
||||||
|
|
||||||
public $getUriForConnection(connectionId: string): Thenable<string> {
|
public $getUriForConnection(connectionId: string): Thenable<string> {
|
||||||
return this._proxy.$getUriForConnection(connectionId);
|
return this._proxy.$getUriForConnection(connectionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
|||||||
return this._resolveProvider<sqlops.ConnectionProvider>(handle).listDatabases(connectionUri);
|
return this._resolveProvider<sqlops.ConnectionProvider>(handle).listDatabases(connectionUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$getConnectionString(handle: number, connectionUri: string, includePassword: boolean): Thenable<string> {
|
||||||
|
return this._resolveProvider<sqlops.ConnectionProvider>(handle).getConnectionString(connectionUri, includePassword);
|
||||||
|
}
|
||||||
|
|
||||||
$rebuildIntelliSenseCache(handle: number, connectionUri: string): Thenable<void> {
|
$rebuildIntelliSenseCache(handle: number, connectionUri: string): Thenable<void> {
|
||||||
return this._resolveProvider<sqlops.ConnectionProvider>(handle).rebuildIntelliSenseCache(connectionUri);
|
return this._resolveProvider<sqlops.ConnectionProvider>(handle).rebuildIntelliSenseCache(connectionUri);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
|||||||
return result.databaseNames;
|
return result.databaseNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async $getConnectionString(connectionId: string, includePassword: boolean): Promise<string> {
|
||||||
|
let connection = this._connectionManagementService.getActiveConnections().find(profile => profile.id === connectionId);
|
||||||
|
return await this._connectionManagementService.getConnectionString(connection, includePassword);
|
||||||
|
}
|
||||||
|
|
||||||
public $getUriForConnection(connectionId: string): Thenable<string> {
|
public $getUriForConnection(connectionId: string): Thenable<string> {
|
||||||
return Promise.resolve(this._connectionManagementService.getConnectionUriFromId(connectionId));
|
return Promise.resolve(this._connectionManagementService.getConnectionUriFromId(connectionId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
|
|||||||
listDatabases(connectionUri: string): Thenable<sqlops.ListDatabasesResult> {
|
listDatabases(connectionUri: string): Thenable<sqlops.ListDatabasesResult> {
|
||||||
return self._proxy.$listDatabases(handle, connectionUri);
|
return self._proxy.$listDatabases(handle, connectionUri);
|
||||||
},
|
},
|
||||||
|
getConnectionString(connectionUri: string, includePassword: boolean): Thenable<string> {
|
||||||
|
return self._proxy.$getConnectionString(handle, connectionUri, includePassword);
|
||||||
|
},
|
||||||
rebuildIntelliSenseCache(connectionUri: string): Thenable<void> {
|
rebuildIntelliSenseCache(connectionUri: string): Thenable<void> {
|
||||||
return self._proxy.$rebuildIntelliSenseCache(handle, connectionUri);
|
return self._proxy.$rebuildIntelliSenseCache(handle, connectionUri);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ export function createApiFactory(
|
|||||||
listDatabases(connectionId: string): Thenable<string[]> {
|
listDatabases(connectionId: string): Thenable<string[]> {
|
||||||
return extHostConnectionManagement.$listDatabases(connectionId);
|
return extHostConnectionManagement.$listDatabases(connectionId);
|
||||||
},
|
},
|
||||||
|
getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||||
|
return extHostConnectionManagement.$getConnectionString(connectionId, includePassword);
|
||||||
|
},
|
||||||
getUriForConnection(connectionId: string): Thenable<string> {
|
getUriForConnection(connectionId: string): Thenable<string> {
|
||||||
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
return extHostConnectionManagement.$getUriForConnection(connectionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ export abstract class ExtHostDataProtocolShape {
|
|||||||
*/
|
*/
|
||||||
$listDatabases(handle: number, connectionUri: string): Thenable<sqlops.ListDatabasesResult> { throw ni(); }
|
$listDatabases(handle: number, connectionUri: string): Thenable<sqlops.ListDatabasesResult> { throw ni(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the connection string for the connection specified by connectionUri
|
||||||
|
* @param handle the handle to use when looking up a provider
|
||||||
|
* @param connectionUri URI identifying a connected resource
|
||||||
|
*/
|
||||||
|
$getConnectionString(handle: number, connectionUri: string, includePassword: boolean): Thenable<string> { throw ni(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies all listeners on the Extension Host side that a language change occurred
|
* Notifies all listeners on the Extension Host side that a language change occurred
|
||||||
* for a dataprotocol language. The sub-flavor is the specific implementation used for query
|
* for a dataprotocol language. The sub-flavor is the specific implementation used for query
|
||||||
@@ -474,6 +481,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
|
|||||||
$getCurrentConnection(): Thenable<sqlops.connection.Connection>;
|
$getCurrentConnection(): Thenable<sqlops.connection.Connection>;
|
||||||
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
||||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||||
|
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,4 +253,8 @@ export class TestConnectionManagementService implements IConnectionManagementSer
|
|||||||
getActiveConnectionCredentials(profileId: string): { [name: string]: string } {
|
getActiveConnectionCredentials(profileId: string): { [name: string]: string } {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getConnectionString(profile: IConnectionProfile): Thenable<string> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,10 @@ export class ConnectionProviderStub implements sqlops.ConnectionProvider {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getConnectionString(connectionUri: string): Thenable<string> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
rebuildIntelliSenseCache(connectionUri: string): Thenable<void> {
|
rebuildIntelliSenseCache(connectionUri: string): Thenable<void> {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user