From 11810f3238e1f28d524aff0d7f02cc7b73e8f8d6 Mon Sep 17 00:00:00 2001 From: Alex Ma Date: Wed, 6 Sep 2023 15:51:53 -0700 Subject: [PATCH] wip restoration of nonDefaultOptions --- extensions/mssql/src/tableDesigner/tableDesigner.ts | 8 ++++++-- src/sql/azdata.proposed.d.ts | 7 +++++++ .../platform/connection/common/connectionManagement.ts | 7 +++++++ .../test/common/testConnectionManagementService.ts | 4 ++++ .../api/browser/mainThreadConnectionManagement.ts | 5 +++++ .../workbench/api/common/extHostConnectionManagement.ts | 4 ++++ src/sql/workbench/api/common/sqlExtHost.api.impl.ts | 3 +++ src/sql/workbench/api/common/sqlExtHost.protocol.ts | 1 + .../connection/browser/connectionManagementService.ts | 5 +++++ 9 files changed, 42 insertions(+), 2 deletions(-) diff --git a/extensions/mssql/src/tableDesigner/tableDesigner.ts b/extensions/mssql/src/tableDesigner/tableDesigner.ts index f0917bb6131e..2e8f00c48240 100644 --- a/extensions/mssql/src/tableDesigner/tableDesigner.ts +++ b/extensions/mssql/src/tableDesigner/tableDesigner.ts @@ -28,9 +28,11 @@ export function registerTableDesignerCommands(appContext: AppContext) { } const tableIcon = context.nodeInfo!.nodeSubType as azdata.designers.TableIcon; const telemetryInfo = await getTelemetryInfo(context, tableIcon); + let nonDefaultOptions = await azdata.connection.getNonDefaultOptions(context.connectionProfile); + nonDefaultOptions = nonDefaultOptions.replace('(', '[').replace(')', ']'); await azdata.designers.openTableDesigner(sqlProviderName, { title: NewTableText, - tooltip: context.connectionProfile!.connectionName ? `${context.connectionProfile!.connectionName} - ${NewTableText}` : `${context.connectionProfile!.serverName} - ${context.connectionProfile!.databaseName} - ${NewTableText}`, + tooltip: `${context.connectionProfile!.serverName} - ${context.connectionProfile!.databaseName} - ${NewTableText}${nonDefaultOptions}`, server: context.connectionProfile!.serverName, database: context.connectionProfile!.databaseName, isNewTable: true, @@ -60,9 +62,11 @@ export function registerTableDesignerCommands(appContext: AppContext) { } const tableIcon = context.nodeInfo!.nodeSubType as azdata.designers.TableIcon; const telemetryInfo = await getTelemetryInfo(context, tableIcon); + let nonDefaultOptions = await azdata.connection.getNonDefaultOptions(context.connectionProfile); + nonDefaultOptions = nonDefaultOptions.replace('(', '[').replace(')', ']'); await azdata.designers.openTableDesigner(sqlProviderName, { title: `${schema}.${name}`, - tooltip: connName ? `${connName} - ${schema}.${name}` : `${server} - ${database} - ${schema}.${name}`, + tooltip: `${server} - ${database} - ${schema}.${name}${nonDefaultOptions}`, server: server, database: database, isNewTable: false, diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 611e07247c55..381d16c2343d 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -508,6 +508,13 @@ declare module 'azdata' { * @returns The new password that is returned from the operation or undefined if unsuccessful. */ export function openChangePasswordDialog(profile: IConnectionProfile): Thenable; + + /** + * Gets the non default options of the connection profile. + * @param profile The connection profile to get the options for. + * @returns The string key containing the non default options (if any) for the profile. + */ + export function getNonDefaultOptions(profile: IConnectionProfile): Thenable; } /* diff --git a/src/sql/platform/connection/common/connectionManagement.ts b/src/sql/platform/connection/common/connectionManagement.ts index 0061ba5ee672..29371625950f 100644 --- a/src/sql/platform/connection/common/connectionManagement.ts +++ b/src/sql/platform/connection/common/connectionManagement.ts @@ -381,6 +381,13 @@ export interface IConnectionManagementService { * @returns the new valid password that is entered, or undefined if cancelled or errored. */ openChangePasswordDialog(profile: IConnectionProfile): Promise; + + /** + * Launches the password change dialog. + * @param profile The connection profile to retrieve the non default connection options from + * @returns a string key containing the options that aren't default values. + */ + getNonDefaultOptions(profile: IConnectionProfile): string; } export enum RunQueryOnConnectionMode { diff --git a/src/sql/platform/connection/test/common/testConnectionManagementService.ts b/src/sql/platform/connection/test/common/testConnectionManagementService.ts index b91e7850bcf8..81f633b01ee3 100644 --- a/src/sql/platform/connection/test/common/testConnectionManagementService.ts +++ b/src/sql/platform/connection/test/common/testConnectionManagementService.ts @@ -355,6 +355,10 @@ export class TestConnectionManagementService implements IConnectionManagementSer return undefined; } + getNonDefaultOptions(profile: IConnectionProfile): string { + return undefined!; + } + openCustomErrorDialog(options: azdata.window.IErrorDialogOptions): Promise { return undefined; } diff --git a/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts b/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts index 2e0e37143965..f3f78a0b0c8b 100644 --- a/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts +++ b/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts @@ -185,6 +185,11 @@ export class MainThreadConnectionManagement extends Disposable implements MainTh return this._connectionManagementService.openChangePasswordDialog(convertedProfile); } + public $getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable { + let convertedProfile = new ConnectionProfile(this._capabilitiesService, profile); + return Promise.resolve(this._connectionManagementService.getNonDefaultOptions(convertedProfile)); + } + public async $listDatabases(connectionId: string): Promise { let connectionUri = await this.$getUriForConnection(connectionId); let result = await this._connectionManagementService.listDatabases(connectionUri); diff --git a/src/sql/workbench/api/common/extHostConnectionManagement.ts b/src/sql/workbench/api/common/extHostConnectionManagement.ts index 56f27dbc8fce..f704f12ecced 100644 --- a/src/sql/workbench/api/common/extHostConnectionManagement.ts +++ b/src/sql/workbench/api/common/extHostConnectionManagement.ts @@ -78,6 +78,10 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap return this._proxy.$openChangePasswordDialog(profile); } + $getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable { + return this._proxy.$getNonDefaultOptions(profile); + } + public $listDatabases(connectionId: string): Thenable { return this._proxy.$listDatabases(connectionId); } diff --git a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts index e88ee30d44f9..bf10b1a43623 100644 --- a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts @@ -143,6 +143,9 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable { return extHostConnectionManagement.$openChangePasswordDialog(profile); }, + getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable { + return extHostConnectionManagement.$getNonDefaultOptions(profile); + }, listDatabases(connectionId: string): Thenable { return extHostConnectionManagement.$listDatabases(connectionId); }, diff --git a/src/sql/workbench/api/common/sqlExtHost.protocol.ts b/src/sql/workbench/api/common/sqlExtHost.protocol.ts index e9ff8539030a..6b24d2e921fc 100644 --- a/src/sql/workbench/api/common/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/common/sqlExtHost.protocol.ts @@ -734,6 +734,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable { $getServerInfo(connectedId: string): Thenable; $openConnectionDialog(providers: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable; $openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable; + $getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable; $listDatabases(connectionId: string): Thenable; $getConnectionString(connectionId: string, includePassword: boolean): Thenable; $getUriForConnection(connectionId: string): Thenable; diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 0b3a02ccd446..6fb6cac98d0a 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -724,6 +724,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti return result; } + public getNonDefaultOptions(profile: interfaces.IConnectionProfile): string { + let convProfile = new ConnectionProfile(this._capabilitiesService, profile); + return convProfile.getNonDefaultOptionsString(); + } + private doActionsAfterConnectionComplete(uri: string, options: IConnectionCompletionOptions): void { let connectionManagementInfo = this._connectionStatusManager.findConnection(uri); if (!connectionManagementInfo) {