fix duplicate sqlcmd var header when loading publish profile multiple times (#16007)

* fix duplicate sqlcmd var header when loading publish profile multiple times

* remove variable to keep track of count
This commit is contained in:
Kim Santiago
2021-07-08 14:37:07 -07:00
committed by GitHub
parent 74cfac39d2
commit c69c303a2b

View File

@@ -556,6 +556,16 @@ export class PublishDatabaseDialog {
this.targetDatabaseDropDown!.value = result.databaseName;
}
if (Object.keys(result.sqlCmdVariables).length) {
// add SQLCMD Variables table if it wasn't there before and the profile had sqlcmd variables
if (Object.keys(this.project.sqlCmdVariables).length === 0 && Object.keys(<Record<string, string>>this.sqlCmdVars).length === 0) {
this.formBuilder?.addFormItem(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
}
} 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(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
}
for (let key in result.sqlCmdVariables) {
(<Record<string, string>>this.sqlCmdVars)[key] = result.sqlCmdVariables[key];
}
@@ -567,16 +577,6 @@ export class PublishDatabaseDialog {
dataValues: data
});
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?.addFormItem(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
}
} 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(<azdataType.FormComponentGroup>this.sqlCmdVariablesFormComponentGroup);
}
// show file path in text box and hover text
this.loadProfileTextBox!.value = fileUris[0].fsPath;
this.loadProfileTextBox!.updateProperty('title', fileUris[0].fsPath);