Save publish profile in Publish UI workflow (#22700)

* Add profile section in Publish project UI

* Move publish profile row below Publish Target

* Add contract for savePublishProfie and SaveProfileAs button functionality

* Make the DacFx contract functional

* Send values from UI to DacFx service call

* Fix build error

* Address comment, remove print statements

* Address comments

* Set correct connection string

* Fix functionality for rename, exclude, delete publish profiles. Add new profile to the tree and sqlproj.

* Address comment to update alignement of button

* Address comments

* Update button to use title casing
This commit is contained in:
Sakshi Sharma
2023-04-13 17:08:24 -07:00
committed by GitHub
parent 3deb163210
commit 91ea2b43d6
11 changed files with 148 additions and 37 deletions

View File

@@ -25,7 +25,7 @@ import { ImportDataModel } from '../models/api/import';
import { NetCoreTool, DotNetError } from '../tools/netcoreTool';
import { ShellCommandOptions } from '../tools/shellExecutionHelper';
import { BuildHelper } from '../tools/buildHelper';
import { readPublishProfile } from '../models/publishProfile/publishProfile';
import { readPublishProfile, savePublishProfile } from '../models/publishProfile/publishProfile';
import { AddDatabaseReferenceDialog } from '../dialogs/addDatabaseReferenceDialog';
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings } from '../models/IDatabaseReferenceSettings';
import { DatabaseReferenceTreeItem } from '../models/tree/databaseReferencesTreeItem';
@@ -445,6 +445,7 @@ export class ProjectsController {
publishDatabaseDialog.publishToContainer = async (proj, prof) => this.publishToDockerContainer(proj, prof);
publishDatabaseDialog.generateScript = async (proj, prof) => this.publishOrScriptProject(proj, prof, false);
publishDatabaseDialog.readPublishProfile = async (profileUri) => readPublishProfile(profileUri);
publishDatabaseDialog.savePublishProfile = async (profilePath, databaseName, connectionString, sqlCommandVariableValues, deploymentOptions) => savePublishProfile(profilePath, databaseName, connectionString, sqlCommandVariableValues, deploymentOptions);
publishDatabaseDialog.openDialog();
@@ -820,6 +821,7 @@ export class ProjectsController {
await project.excludePostDeploymentScript(fileEntry.relativePath);
break;
case constants.DatabaseProjectItemType.noneFile:
case constants.DatabaseProjectItemType.publishProfile:
await project.excludeNoneItem(fileEntry.relativePath);
break;
default:
@@ -879,6 +881,7 @@ export class ProjectsController {
await project.deletePostDeploymentScript(node.entryKey);
break;
case constants.DatabaseProjectItemType.noneFile:
case constants.DatabaseProjectItemType.publishProfile:
await project.deleteNoneItem(node.entryKey);
break;
default:
@@ -903,13 +906,21 @@ export class ProjectsController {
const node = context.element as BaseProjectTreeItem;
const project = await this.getProjectFromContext(node);
const file = this.getFileProjectEntry(project, node);
const baseName = path.basename(node.friendlyName);
let fileExtension: string;
if (utils.isPublishProfile(baseName)) {
fileExtension = constants.publishProfileExtension;
} else {
fileExtension = constants.sqlFileExtension;
}
// need to use quickpick because input box isn't supported in treeviews
// https://github.com/microsoft/vscode/issues/117502 and https://github.com/microsoft/vscode/issues/97190
const newFileName = await vscode.window.showInputBox(
{
title: constants.enterNewName,
value: path.basename(node.friendlyName, constants.sqlFileExtension),
value: path.basename(baseName, fileExtension),
ignoreFocusOut: true,
validateInput: async (value) => {
return await this.fileAlreadyExists(value, file?.fsUri.fsPath!) ? constants.fileAlreadyExists(value) : undefined;
@@ -920,7 +931,7 @@ export class ProjectsController {
return;
}
const newFilePath = path.join(path.dirname(utils.getPlatformSafeFileEntryPath(file?.relativePath!)), `${newFileName}.sql`);
const newFilePath = path.join(path.dirname(utils.getPlatformSafeFileEntryPath(file?.relativePath!)), `${newFileName}${fileExtension}`);
const renameResult = await project.move(node, newFilePath);