From efc818295430f1aa8fc068930b1423c39b170b29 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Wed, 22 Jul 2020 17:59:26 -0700 Subject: [PATCH] fix sql proj sqlcmd table showing after loading profile when it shouldn't (#11479) --- .../src/dialogs/publishDatabaseDialog.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts index 6036188ee7..e04dd3c106 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts @@ -29,6 +29,7 @@ export class PublishDatabaseDialog { private dataSourcesRadioButton: azdata.RadioButtonComponent | undefined; private loadProfileButton: azdata.ButtonComponent | undefined; private sqlCmdVariablesTable: azdata.TableComponent | undefined; + private sqlCmdVariablesFormComponent: azdata.FormComponent | undefined; private formBuilder: azdata.FormBuilder | undefined; private connectionId: string | undefined; @@ -106,6 +107,11 @@ export class PublishDatabaseDialog { height: 400 }).component(); + this.sqlCmdVariablesFormComponent = { + title: constants.sqlCmdTableLabel, + component: this.sqlCmdVariablesTable + }; + this.formBuilder = view.modelBuilder.formContainer() .withFormItems([ { @@ -418,13 +424,14 @@ export class PublishDatabaseDialog { data: data }); - // add SQLCMD Variables table if it wasn't there before - if (Object.keys(this.project.sqlCmdVariables).length === 0) { - this.formBuilder?.insertFormItem({ - title: constants.sqlCmdTableLabel, - component: this.sqlCmdVariablesTable - }, - 6); + if (Object.keys(result.sqlCmdVariables).length) { + // add SQLCMD Variables table if it wasn't there before + if (Object.keys(this.project.sqlCmdVariables).length === 0) { + this.formBuilder?.insertFormItem(this.sqlCmdVariablesFormComponent, 6); + } + } else if (Object.keys(this.project.sqlCmdVariables).length === 0) { + // remove the table if there are no SQLCMD variables in the project and loaded profile + this.formBuilder?.removeFormItem(this.sqlCmdVariablesFormComponent); } } });