Skip to content

Commit

Permalink
wip restoration of nonDefaultOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
smartguest committed Sep 6, 2023
1 parent 8c2154e commit 11810f3
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 2 deletions.
8 changes: 6 additions & 2 deletions extensions/mssql/src/tableDesigner/tableDesigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/sql/azdata.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined>;

/**
* 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<string>;
}

/*
Expand Down
7 changes: 7 additions & 0 deletions src/sql/platform/connection/common/connectionManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined>;

/**
* 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ export class TestConnectionManagementService implements IConnectionManagementSer
return undefined;
}

getNonDefaultOptions(profile: IConnectionProfile): string {
return undefined!;
}

openCustomErrorDialog(options: azdata.window.IErrorDialogOptions): Promise<string | undefined> {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ export class MainThreadConnectionManagement extends Disposable implements MainTh
return this._connectionManagementService.openChangePasswordDialog(convertedProfile);
}

public $getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable<string> {
let convertedProfile = new ConnectionProfile(this._capabilitiesService, profile);
return Promise.resolve(this._connectionManagementService.getNonDefaultOptions(convertedProfile));
}

public async $listDatabases(connectionId: string): Promise<string[]> {
let connectionUri = await this.$getUriForConnection(connectionId);
let result = await this._connectionManagementService.listDatabases(connectionUri);
Expand Down
4 changes: 4 additions & 0 deletions src/sql/workbench/api/common/extHostConnectionManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
return this._proxy.$openChangePasswordDialog(profile);
}

$getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable<string> {
return this._proxy.$getNonDefaultOptions(profile);
}

public $listDatabases(connectionId: string): Thenable<string[]> {
return this._proxy.$listDatabases(connectionId);
}
Expand Down
3 changes: 3 additions & 0 deletions src/sql/workbench/api/common/sqlExtHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable<string | undefined> {
return extHostConnectionManagement.$openChangePasswordDialog(profile);
},
getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable<string> {
return extHostConnectionManagement.$getNonDefaultOptions(profile);
},
listDatabases(connectionId: string): Thenable<string[]> {
return extHostConnectionManagement.$listDatabases(connectionId);
},
Expand Down
1 change: 1 addition & 0 deletions src/sql/workbench/api/common/sqlExtHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable {
$getServerInfo(connectedId: string): Thenable<azdata.ServerInfo>;
$openConnectionDialog(providers: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable<azdata.connection.Connection>;
$openChangePasswordDialog(profile: azdata.IConnectionProfile): Thenable<string | undefined>;
$getNonDefaultOptions(profile: azdata.IConnectionProfile): Thenable<string>;
$listDatabases(connectionId: string): Thenable<string[]>;
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
$getUriForConnection(connectionId: string): Thenable<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 11810f3

Please sign in to comment.