Connect query editor when producing script from object management dialogs. (#24015)

This commit is contained in:
Cory Rivera
2023-07-28 14:26:33 -07:00
committed by GitHub
parent 7144703273
commit 5c5b73525d
2 changed files with 25 additions and 2 deletions

View File

@@ -26,7 +26,6 @@ export interface ObjectManagementDialogOptions extends ScriptableDialogOptions {
isNewObject: boolean;
parentUrn: string;
objectUrn?: string;
objectExplorerContext?: azdata.ObjectExplorerContext;
objectName?: string;
}

View File

@@ -15,6 +15,10 @@ export interface ScriptableDialogOptions {
* The width of the dialog, defaults to narrow if not set
*/
width?: azdata.window.DialogWidth;
/**
* The object explorer context in which this dialog was opened.
*/
objectExplorerContext?: azdata.ObjectExplorerContext;
}
/**
@@ -90,7 +94,27 @@ export abstract class ScriptableDialogBase<OptionsType extends ScriptableDialogO
const script = await this.generateScript();
if (script) {
message = localizedConstants.ScriptGeneratedText;
await azdata.queryeditor.openQueryDocument({ content: script }, providerId);
let doc = await azdata.queryeditor.openQueryDocument({ content: script }, providerId);
if (this.options.objectExplorerContext?.connectionProfile) {
let profile = this.options.objectExplorerContext?.connectionProfile;
let convertedProfile: azdata.connection.ConnectionProfile = {
providerId: profile.providerName,
connectionId: profile.id,
connectionName: profile.connectionName,
serverName: profile.serverName,
databaseName: profile.databaseName,
userName: profile.userName,
password: profile.password,
authenticationType: profile.authenticationType,
savePassword: profile.savePassword,
groupFullName: profile.groupFullName,
groupId: profile.groupId,
saveProfile: profile.savePassword,
azureTenantId: profile.azureTenantId,
options: profile.options
};
await doc.connect(convertedProfile);
}
} else {
message = localizedConstants.NoActionScriptedMessage;
}