Add option to save Publish profile in VScode (#23067)

* Publish profile save changes for VSCode

* Fix publish settings

* Fix publish settings

* Address comments

* Address comments

* Address comments

* Address comment
This commit is contained in:
Sakshi Sharma
2023-05-16 10:47:58 -07:00
committed by GitHub
parent d9220c809c
commit 244d56eb12
7 changed files with 199 additions and 29 deletions

View File

@@ -20,7 +20,7 @@ import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/t
import { Deferred } from '../common/promise';
import { PublishOptionsDialog } from './publishOptionsDialog';
import { IPublishToDockerSettings, ISqlProjectPublishSettings } from '../models/deploy/publishSettings';
import { PublishProfile } from '../models/publishProfile/publishProfile';
import { PublishProfile, promptToSaveProfile } from '../models/publishProfile/publishProfile';
interface DataSourceDropdownValue extends azdataType.CategoryValue {
dataSource: SqlConnectionDataSource;
@@ -56,7 +56,6 @@ export class PublishDatabaseDialog {
private connectionIsDataSource: boolean | undefined;
private sqlCmdVars: Map<string, string> | undefined;
private deploymentOptions: DeploymentOptions | undefined;
private profileUsed: boolean = false;
private serverName: string | undefined;
protected optionsButton: azdataType.ButtonComponent | undefined;
private publishOptionsDialog: PublishOptionsDialog | undefined;
@@ -240,7 +239,7 @@ export class PublishDatabaseDialog {
connectionUri: await this.getConnectionUri(),
sqlCmdVariables: this.getSqlCmdVariablesForPublish(),
deploymentOptions: await this.getDeploymentOptions(),
profileUsed: this.profileUsed
publishProfileUri: this.publishProfileUri
};
utils.getAzdataApi()!.window.closeDialog(this.dialog);
@@ -273,7 +272,7 @@ export class PublishDatabaseDialog {
connectionUri: '',
sqlCmdVariables: this.getSqlCmdVariablesForPublish(),
deploymentOptions: await this.getDeploymentOptions(),
profileUsed: this.profileUsed
publishProfileUri: this.publishProfileUri
}
};
@@ -294,7 +293,7 @@ export class PublishDatabaseDialog {
connectionUri: await this.getConnectionUri(),
sqlCmdVariables: sqlCmdVars,
deploymentOptions: await this.getDeploymentOptions(),
profileUsed: this.profileUsed
publishProfileUri: this.publishProfileUri
};
utils.getAzdataApi()!.window.closeDialog(this.dialog);
@@ -831,7 +830,6 @@ export class PublishDatabaseDialog {
this.loadProfileTextBox!.value = fileUris[0].fsPath;
await this.loadProfileTextBox!.updateProperty('title', fileUris[0].fsPath);
this.profileUsed = true;
this.publishProfileUri = fileUris[0];
}
});
@@ -850,15 +848,7 @@ export class PublishDatabaseDialog {
}).component();
saveProfileAsButton.onDidClick(async () => {
const filePath = await vscode.window.showSaveDialog(
{
defaultUri: this.publishProfileUri ?? vscode.Uri.file(path.join(this.project.projectFolderPath, `${this.project.projectFileName}_1.publish.xml`)),
saveLabel: constants.save,
filters: {
'Publish Settings Files': ['publish.xml'],
}
}
);
const filePath = await promptToSaveProfile(this.project, this.publishProfileUri);
if (!filePath) {
return;
@@ -873,7 +863,6 @@ export class PublishDatabaseDialog {
TelemetryReporter.sendActionEvent(TelemetryViews.SqlProjectPublishDialog, TelemetryActions.profileSaved);
}
this.profileUsed = true;
this.publishProfileUri = filePath;
await this.project.addNoneItem(path.relative(this.project.projectFolderPath, filePath.fsPath));

View File

@@ -21,6 +21,7 @@ import { ISqlProjectPublishSettings } from '../models/deploy/publishSettings';
export async function getPublishDatabaseSettings(project: ISqlProject, promptForConnection: boolean = true): Promise<ISqlProjectPublishSettings | undefined> {
// 1. Select publish settings file (optional)
let publishProfileUri;
// Create custom quickpick so we can control stuff like displaying the loading indicator
const quickPick = vscode.window.createQuickPick();
quickPick.items = [{ label: constants.dontUseProfile }, { label: constants.browseForProfileWithIcon }];
@@ -42,7 +43,7 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
// If the user cancels out of the file picker then just return and let them choose another option
return;
}
let publishProfileUri = locations[0];
publishProfileUri = locations[0];
try {
// Show loading state while reading profile
quickPick.busy = true;
@@ -214,7 +215,7 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
connectionUri: connectionUri || '',
sqlCmdVariables: sqlCmdVariables,
deploymentOptions: publishProfile?.options ?? await getDefaultPublishDeploymentOptions(project),
profileUsed: !!publishProfile
publishProfileUri: publishProfileUri
};
return settings;
}