Fixing a couple database reference dialog bugs (#15523)

* fixing a couple database reference dialog bugs

* update comment
This commit is contained in:
Kim Santiago
2021-05-25 11:37:13 -07:00
committed by GitHub
parent f691701c1c
commit 25352fa39c

View File

@@ -247,6 +247,8 @@ export class AddDatabaseReferenceDialog {
this.formBuilder!.removeFormItem(<azdata.FormComponent>this.systemDatabaseFormComponent);
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.projectFormComponent, 2);
this.locationDropdown!.values = constants.locationDropdownValues;
this.currentReferenceType = ReferenceType.project;
this.updateEnabledInputBoxes();
this.tryEnableAddReferenceButton();
@@ -274,7 +276,6 @@ export class AddDatabaseReferenceDialog {
this.formBuilder!.insertFormItem(<azdata.FormComponent>this.dacpacFormComponent, 2);
this.locationDropdown!.values = constants.locationDropdownValues;
this.locationDropdown!.value = constants.differentDbSameServer;
this.currentReferenceType = ReferenceType.dacpac;
this.updateEnabledInputBoxes();
@@ -304,7 +305,6 @@ export class AddDatabaseReferenceDialog {
};
}
private createSystemDatabaseDropdown(): azdata.FormComponent {
this.systemDatabaseDropdown = this.view!.modelBuilder.dropDown().withProperties({
values: [constants.master, constants.msdb],
@@ -403,7 +403,6 @@ export class AddDatabaseReferenceDialog {
/**
* Update the enabled input boxes based on what the location of the database reference selected in the dropdown is
* @param isSystemDb
*/
public updateEnabledInputBoxes(): void {
const isSystemDb = this.currentReferenceType === ReferenceType.systemDb;
@@ -445,22 +444,27 @@ export class AddDatabaseReferenceDialog {
}
}
/**
* Sets the default values in the database name and variable text boxes if they are enabled
*/
private setDefaultDatabaseValues(): void {
switch (this.currentReferenceType) {
case ReferenceType.project: {
this.databaseNameTextbox!.value = <string>this.projectDropdown?.value;
this.databaseVariableTextbox!.value = `${this.projectDropdown?.value}`;
break;
}
case ReferenceType.systemDb: {
this.databaseNameTextbox!.value = <string>this.systemDatabaseDropdown?.value;
break;
}
case ReferenceType.dacpac: {
const dacpacName = this.dacpacTextbox!.value ? path.parse(this.dacpacTextbox!.value!).name : '';
this.databaseNameTextbox!.value = dacpacName;
this.databaseVariableTextbox!.value = dacpacName ? `${dacpacName}` : '';
break;
if (this.databaseNameTextbox!.enabled) {
switch (this.currentReferenceType) {
case ReferenceType.project: {
this.databaseNameTextbox!.value = <string>this.projectDropdown?.value;
this.databaseVariableTextbox!.value = `${this.projectDropdown?.value}`;
break;
}
case ReferenceType.systemDb: {
this.databaseNameTextbox!.value = <string>this.systemDatabaseDropdown?.value;
break;
}
case ReferenceType.dacpac: {
const dacpacName = this.dacpacTextbox!.value ? path.parse(this.dacpacTextbox!.value!).name : '';
this.databaseNameTextbox!.value = dacpacName;
this.databaseVariableTextbox!.value = dacpacName ? `${dacpacName}` : '';
break;
}
}
}
}