Chaning the name of server in deploy option if target is Azure (#18828)

This commit is contained in:
Leila Lali
2022-03-28 15:07:09 -07:00
committed by GitHub
parent 893015010d
commit aad20bc338
6 changed files with 66 additions and 40 deletions

View File

@@ -119,10 +119,11 @@ async function launchEulaQuickPick(baseImage: string): Promise<boolean> {
*/
export async function launchPublishToDockerContainerQuickpick(project: Project): Promise<IDeployProfile | undefined> {
const name = uiUtils.getPublishServerName(project.getProjectTargetVersion());
let localDbSetting: ILocalDbSetting | undefined;
// Deploy to docker selected
let portNumber = await vscode.window.showInputBox({
title: constants.enterPortNumber,
title: constants.enterPortNumber(name),
ignoreFocusOut: true,
value: constants.defaultPortNumber,
validateInput: input => !utils.validateSqlServerPortNumber(input) ? constants.portMustBeNumber : undefined
@@ -136,10 +137,10 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
let password: string | undefined = '';
password = await vscode.window.showInputBox({
title: constants.enterPassword,
title: constants.enterPassword(name),
ignoreFocusOut: true,
value: password,
validateInput: input => !utils.isValidSQLPassword(input) ? constants.invalidSQLPasswordMessage : undefined,
validateInput: input => !utils.isValidSQLPassword(input) ? constants.invalidSQLPasswordMessage(name) : undefined,
password: true
}
);
@@ -151,10 +152,10 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
let confirmPassword: string | undefined = '';
confirmPassword = await vscode.window.showInputBox({
title: constants.confirmPassword,
title: constants.confirmPassword(name),
ignoreFocusOut: true,
value: confirmPassword,
validateInput: input => input !== password ? constants.passwordNotMatch : undefined,
validateInput: input => input !== password ? constants.passwordNotMatch(name) : undefined,
password: true
}
);
@@ -167,7 +168,7 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
const baseImages = uiUtils.getDockerBaseImages();
const baseImage = await vscode.window.showQuickPick(
baseImages.map(x => x.name),
{ title: constants.selectBaseImage, ignoreFocusOut: true });
{ title: constants.selectBaseImage(name), ignoreFocusOut: true });
// Return when user hits escape
if (!baseImage) {

View File

@@ -14,7 +14,7 @@ import { IDeploySettings } from '../models/IDeploySettings';
import { DeploymentOptions } from 'mssql';
import { IconPathHelper } from '../common/iconHelper';
import { cssStyles } from '../common/uiConstants';
import { getAgreementDisplayText, getConnectionName, getDockerBaseImages } from './utils';
import { getAgreementDisplayText, getConnectionName, getDockerBaseImages, getPublishServerName } from './utils';
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
import { IDeployProfile } from '../models/deploy/deployProfile';
import { Deferred } from '../common/promise';
@@ -367,6 +367,7 @@ export class PublishDatabaseDialog {
}
private createPublishTypeRadioButtons(view: azdataType.ModelView): azdataType.Component {
const name = getPublishServerName(this.project.getProjectTargetVersion());
const publishToLabel = view.modelBuilder.text().withProps({
value: constants.publishTo,
width: cssStyles.publishDialogLabelWidth
@@ -374,7 +375,7 @@ export class PublishDatabaseDialog {
this.existingServerRadioButton = view.modelBuilder.radioButton()
.withProps({
name: 'publishType',
label: constants.publishToExistingServer
label: constants.publishToExistingServer(name)
}).component();
this.existingServerRadioButton.checked = true;
@@ -385,7 +386,7 @@ export class PublishDatabaseDialog {
this.dockerServerRadioButton = view.modelBuilder.radioButton()
.withProps({
name: 'publishType',
label: constants.publishToDockerContainer
label: constants.publishToDockerContainer(name)
}).component();
this.dockerServerRadioButton.onDidChangeCheckedState((checked) => {
@@ -539,10 +540,11 @@ export class PublishDatabaseDialog {
}
private createLocalDbInfoRow(view: azdataType.ModelView): azdataType.FlexContainer {
const name = getPublishServerName(this.project.getProjectTargetVersion());
this.serverPortTextBox = view.modelBuilder.inputBox().withProps({
value: constants.defaultPortNumber,
ariaLabel: constants.serverPortNumber,
placeHolder: constants.serverPortNumber,
ariaLabel: constants.serverPortNumber(name),
placeHolder: constants.serverPortNumber(name),
width: cssStyles.publishDialogTextboxWidth,
enabled: true,
inputType: 'number',
@@ -552,26 +554,26 @@ export class PublishDatabaseDialog {
this.serverPortTextBox.onTextChanged(() => {
this.tryEnableGenerateScriptAndOkButtons();
});
const serverPortRow = this.createFormRow(view, constants.serverPortNumber, this.serverPortTextBox);
const serverPortRow = this.createFormRow(view, constants.serverPortNumber(name), this.serverPortTextBox);
this.serverAdminPasswordTextBox = view.modelBuilder.inputBox().withProps({
value: '',
ariaLabel: constants.serverPassword,
placeHolder: constants.serverPassword,
ariaLabel: constants.serverPassword(name),
placeHolder: constants.serverPassword(name),
width: cssStyles.publishDialogTextboxWidth,
enabled: true,
inputType: 'password',
validationErrorMessage: constants.invalidSQLPasswordMessage
validationErrorMessage: constants.invalidSQLPasswordMessage(name)
}).withValidation(component => !utils.isEmptyString(component.value) && utils.isValidSQLPassword(component.value || '')).component();
const serverPasswordRow = this.createFormRow(view, constants.serverPassword, this.serverAdminPasswordTextBox);
const serverPasswordRow = this.createFormRow(view, constants.serverPassword(name), this.serverAdminPasswordTextBox);
this.serverConfigAdminPasswordTextBox = view.modelBuilder.inputBox().withProps({
value: '',
ariaLabel: constants.confirmServerPassword,
placeHolder: constants.confirmServerPassword,
ariaLabel: constants.confirmServerPassword(name),
placeHolder: constants.confirmServerPassword(name),
width: cssStyles.publishDialogTextboxWidth,
enabled: true,
inputType: 'password',
validationErrorMessage: constants.passwordNotMatch
validationErrorMessage: constants.passwordNotMatch(name)
}).withValidation(component => component.value === this.serverAdminPasswordTextBox?.value).component();
this.serverAdminPasswordTextBox.onTextChanged(() => {
this.tryEnableGenerateScriptAndOkButtons();
@@ -582,18 +584,18 @@ export class PublishDatabaseDialog {
this.serverConfigAdminPasswordTextBox.onTextChanged(() => {
this.tryEnableGenerateScriptAndOkButtons();
});
const serverConfirmPasswordRow = this.createFormRow(view, constants.confirmServerPassword, this.serverConfigAdminPasswordTextBox);
const serverConfirmPasswordRow = this.createFormRow(view, constants.confirmServerPassword(name), this.serverConfigAdminPasswordTextBox);
const baseImages = getDockerBaseImages();
this.baseDockerImageDropDown = view.modelBuilder.dropDown().withProps({
values: baseImages.map(x => x.name),
ariaLabel: constants.baseDockerImage,
ariaLabel: constants.baseDockerImage(name),
width: cssStyles.publishDialogTextboxWidth,
enabled: true
}).component();
const agreementInfo = baseImages[0].agreementInfo;
const dropDownRow = this.createFormRow(view, constants.baseDockerImage, this.baseDockerImageDropDown);
const dropDownRow = this.createFormRow(view, constants.baseDockerImage(name), this.baseDockerImageDropDown);
this.eulaCheckBox = view.modelBuilder.checkBox().withProps({
ariaLabel: getAgreementDisplayText(agreementInfo),
required: true

View File

@@ -11,6 +11,7 @@ import { promptForPublishProfile } from './publishDatabaseDialog';
import { getDefaultPublishDeploymentOptions, getVscodeMssqlApi } from '../common/utils';
import { IConnectionInfo } from 'vscode-mssql';
import { IDeploySettings } from '../models/IDeploySettings';
import { getPublishServerName } from './utils';
/**
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
@@ -206,11 +207,11 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn
return settings;
}
export async function launchPublishTargetOption(): Promise<string | undefined> {
export async function launchPublishTargetOption(project: Project): Promise<constants.PublishTargetType | undefined> {
// Show options to user for deploy to existing server or docker
const name = getPublishServerName(project.getProjectTargetVersion());
const publishOption = await vscode.window.showQuickPick(
[constants.publishToExistingServer, constants.publishToDockerContainer],
[constants.publishToExistingServer(name), constants.publishToDockerContainer(name)],
{ title: constants.selectPublishOption, ignoreFocusOut: true });
// Return when user hits escape
@@ -218,6 +219,13 @@ export async function launchPublishTargetOption(): Promise<string | undefined> {
return undefined;
}
return publishOption;
switch (publishOption) {
case constants.publishToExistingServer(name):
return constants.PublishTargetType.existingServer;
case constants.publishToDockerContainer(name):
return constants.PublishTargetType.docker;
default:
return constants.PublishTargetType.existingServer;
}
}

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { SqlTargetPlatform } from 'sqldbproj';
import * as constants from '../common/constants';
import { AgreementInfo, DockerImageInfo } from '../models/deploy/deployProfile';
@@ -30,6 +31,13 @@ export function getAgreementDisplayText(agreementInfo: AgreementInfo): string {
return constants.eulaAgreementText(agreementInfo.link!.text);
}
/**
* Returns the title for SQL server based on the target version
*/
export function getPublishServerName(target: string): string {
return target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure) ? constants.AzureSqlServerName : constants.SqlServerName;
}
export function getDockerBaseImages(): DockerImageInfo[] {
return [
{