Revert 'Add profile section in Publish project UI (#21906)' (#22047)

This reverts commit cb58286247.
This commit is contained in:
Kim Santiago
2023-02-27 15:09:50 -08:00
committed by GitHub
parent febfe3718f
commit e675fc14f0
10 changed files with 23 additions and 131 deletions

View File

@@ -136,8 +136,6 @@ export const server = localize('server', "Server");
export const defaultUser = localize('default', "default");
export const selectProfileToUse = localize('selectProfileToUse', "Select publish profile to load");
export const selectProfile = localize('selectProfile', "Select Profile");
export const saveProfileAsButtonText = localize('saveProfileAsButtonText', "Save Profile As...");
export const save = localize('save', "Save");
export const dontUseProfile = localize('dontUseProfile', "Don't use profile");
export const browseForProfileWithIcon = `$(folder) ${localize('browseForProfile', "Browse for profile")}`;
export const chooseAction = localize('chooseAction', "Choose action");

View File

@@ -26,7 +26,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, savePublishProfile } from '../models/publishProfile/publishProfile';
import { readPublishProfile } from '../models/publishProfile/publishProfile';
import { AddDatabaseReferenceDialog } from '../dialogs/addDatabaseReferenceDialog';
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings } from '../models/IDatabaseReferenceSettings';
import { DatabaseReferenceTreeItem } from '../models/tree/databaseReferencesTreeItem';
@@ -411,7 +411,6 @@ 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();

View File

@@ -8,7 +8,6 @@ import * as vscode from 'vscode';
import * as constants from '../common/constants';
import * as utils from '../common/utils';
import * as uiUtils from './utils';
import * as path from 'path';
import { Project } from '../models/project';
import { SqlConnectionDataSource } from '../models/dataSources/sqlConnectionStringSource';
@@ -63,7 +62,6 @@ export class PublishDatabaseDialog {
protected optionsButton: azdataType.ButtonComponent | undefined;
private publishOptionsDialog: PublishOptionsDialog | undefined;
public publishOptionsModified: boolean = false;
private publishProfileUri: vscode.Uri | undefined;
private completionPromise: Deferred = new Deferred();
@@ -73,7 +71,6 @@ export class PublishDatabaseDialog {
public publishToContainer: ((proj: Project, profile: IPublishToDockerSettings) => any) | undefined;
public generateScript: ((proj: Project, profile: ISqlProjectPublishSettings) => any) | undefined;
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
public savePublishProfile: ((profilePath: string, databaseName: string, connectionString: string, sqlCommandVariableValues?: Record<string, string>, deploymentOptions?: DeploymentOptions) => any) | undefined;
constructor(private project: Project) {
this.dialog = utils.getAzdataApi()!.window.createModelViewDialog(constants.publishDialogName, 'sqlProjectPublishDialog');
@@ -147,14 +144,13 @@ export class PublishDatabaseDialog {
const options = await this.getDefaultDeploymentOptions();
this.setDeploymentOptions(options);
const profileRow = this.createProfileSection(view);
const profileRow = this.createProfileRow(view);
this.connectionRow = this.createConnectionRow(view);
this.databaseRow = this.createDatabaseRow(view);
const displayOptionsButton = this.createOptionsButton(view);
const horizontalFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
horizontalFormSection.addItems([this.databaseRow]);
horizontalFormSection.addItems([profileRow, this.databaseRow]);
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
.withFormItems([
@@ -165,10 +161,6 @@ export class PublishDatabaseDialog {
component: flexRadioButtonsModel,
title: ''
},
{
component: profileRow,
title: constants.profile
},
{
component: this.connectionRow,
title: ''
@@ -440,20 +432,18 @@ export class PublishDatabaseDialog {
this.createDatabaseRow(view);
this.tryEnableGenerateScriptAndOkButtons();
if (existingServer) {
if (this.connectionRow) {
this.formBuilder!.insertFormItem({
title: '',
component: this.connectionRow
}, 2);
}
if (this.localDbSection) {
this.formBuilder!.removeFormItem({
title: '',
component: this.localDbSection
});
}
if (this.connectionRow) {
this.formBuilder!.insertFormItem({
title: '',
component: this.connectionRow
}, 3);
}
} else {
if (this.connectionRow) {
this.formBuilder!.removeFormItem({
@@ -461,7 +451,6 @@ export class PublishDatabaseDialog {
component: this.connectionRow
});
}
if (this.localDbSection) {
this.formBuilder!.insertFormItem({
title: '',
@@ -535,10 +524,8 @@ export class PublishDatabaseDialog {
}
}
private createProfileSection(view: azdataType.ModelView): azdataType.FlexContainer {
const selectProfileButton = this.createSelectProfileButton(view);
const saveProfileAsButton = this.createSaveProfileAsButton(view);
private createProfileRow(view: azdataType.ModelView): azdataType.FlexContainer {
const loadProfileButton = this.createLoadProfileButton(view);
this.loadProfileTextBox = view.modelBuilder.inputBox().withProps({
placeHolder: constants.loadProfilePlaceholderText,
ariaLabel: constants.profile,
@@ -546,7 +533,13 @@ export class PublishDatabaseDialog {
enabled: false
}).component();
const profileRow = view.modelBuilder.flexContainer().withItems([this.loadProfileTextBox, selectProfileButton, saveProfileAsButton], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
const profileLabel = view.modelBuilder.text().withProps({
value: constants.profile,
width: cssStyles.publishDialogLabelWidth
}).component();
const profileRow = view.modelBuilder.flexContainer().withItems([profileLabel, this.loadProfileTextBox], { flex: '0 0 auto', CSSStyles: { 'margin-right': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
profileRow.insertItem(loadProfileButton, 2, { CSSStyles: { 'margin-right': '0px' } });
return profileRow;
}
@@ -849,14 +842,12 @@ export class PublishDatabaseDialog {
}
}
private createSelectProfileButton(view: azdataType.ModelView): azdataType.ButtonComponent {
private createLoadProfileButton(view: azdataType.ModelView): azdataType.ButtonComponent {
let loadProfileButton: azdataType.ButtonComponent = view.modelBuilder.button().withProps({
label: constants.selectProfile,
title: constants.selectProfile,
ariaLabel: constants.selectProfile,
width: cssStyles.PublishingOptionsButtonWidth,
height: '25px',
secondary: true,
ariaLabel: constants.loadProfilePlaceholderText,
iconPath: IconPathHelper.folder_blue,
height: '18px',
width: '18px'
}).component();
loadProfileButton.onDidClick(async () => {
@@ -904,57 +895,12 @@ export class PublishDatabaseDialog {
await this.loadProfileTextBox!.updateProperty('title', fileUris[0].fsPath);
this.profileUsed = true;
this.publishProfileUri = fileUris[0];
this.tryEnableGenerateScriptAndOkButtons();
}
});
return loadProfileButton;
}
private createSaveProfileAsButton(view: azdataType.ModelView): azdataType.ButtonComponent {
let saveProfileAsButton: azdataType.ButtonComponent = view.modelBuilder.button().withProps({
label: constants.saveProfileAsButtonText,
title: constants.saveProfileAsButtonText,
ariaLabel: constants.saveProfileAsButtonText,
width: cssStyles.PublishingOptionsButtonWidth,
height: '25px',
secondary: true
}).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`)),
saveLabel: constants.save,
filters: {
'Publish Settings Files': ['publish.xml'],
}
}
);
if (!filePath) {
return;
}
if (this.savePublishProfile) {
const targetConnectionString = this.connectionId ? await utils.getAzdataApi()!.connection.getConnectionString(this.connectionId, false) : '';
const targetDatabaseName = this.targetDatabaseName ?? '';
const deploymentOptions = await this.getDeploymentOptions();
await this.savePublishProfile(filePath.fsPath, targetDatabaseName, targetConnectionString, this.getSqlCmdVariablesForPublish(), deploymentOptions);
}
this.profileUsed = true;
this.publishProfileUri = filePath;
await this.project.addPublishProfileToProjFile(filePath.fsPath);
void vscode.commands.executeCommand(constants.refreshDataWorkspaceCommand); //refresh data workspace to load the newly added profile to the tree
});
return saveProfileAsButton;
}
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdataType.DeclarativeTableCellValue[][] {
let data = [];
for (let key in sqlCmdVars) {

View File

@@ -125,11 +125,3 @@ async function readConnectionString(xmlDoc: any): Promise<{ connectionId: string
server: server
};
}
/**
* saves publish settings to the specified profile file
*/
export async function savePublishProfile(profilePath: string, databaseName: string, connectionString: string, sqlCommandVariableValues?: Record<string, string>, deploymentOptions?: mssql.DeploymentOptions): Promise<void> {
const dacFxService = await utils.getDacFxService();
await dacFxService.savePublishProfile(profilePath, databaseName, connectionString, sqlCommandVariableValues, deploymentOptions);
}

View File

@@ -22,11 +22,6 @@ export const mockDacFxResult = {
report: ''
};
export const mockSavePublishResult = {
success: true,
errorMessage: ''
};
/* Get the deployment options sample model */
export function getDeploymentOptions(): mssql.DeploymentOptions {
const sampleDesc = 'Sample Description text';
@@ -62,7 +57,6 @@ export class MockDacFxService implements mssql.IDacFxService {
public getOptionsFromProfile(_: string): Thenable<mssql.DacFxOptionsResult> { return Promise.resolve(mockDacFxOptionsResult); }
public validateStreamingJob(_: string, __: string): Thenable<mssql.ValidateStreamingJobResult> { return Promise.resolve(mockDacFxResult); }
public parseTSqlScript(_: string, __: string): Thenable<mssql.ParseTSqlScriptResult> { return Promise.resolve({ containsCreateTableStatement: true }); }
public savePublishProfile(_: string, __: string, ___: string, ______?: Record<string, string>): Thenable<azdata.ResultStatus> { return Promise.resolve(mockSavePublishResult); }
}
export function createContext(): TestContext {