Changes to avoid flickering and ensuring the target DB is always selected correctly even if corresponding source is not present (#14295)

This commit is contained in:
Udeesha Gautam
2021-02-13 20:03:53 -08:00
committed by GitHub
parent 54facabde3
commit f4cf506290
3 changed files with 11 additions and 7 deletions

View File

@@ -634,9 +634,12 @@ export class RestoreDialog extends Modal {
}
private onSourceDatabaseChanged(selectedDatabase: string) {
this.viewModel.sourceDatabaseName = selectedDatabase;
this.viewModel.selectedBackupSets = undefined;
this.validateRestore(true);
// This check is to avoid any unnecessary even firing (to remove flickering)
if (this.viewModel.sourceDatabaseName !== selectedDatabase) {
this.viewModel.sourceDatabaseName = selectedDatabase;
this.viewModel.selectedBackupSets = undefined;
this.validateRestore(true);
}
}
private onRestoreFromChanged(selectedRestoreFrom: string) {

View File

@@ -319,8 +319,9 @@ export class RestoreDialogController implements IRestoreDialogController {
if (this._currentProvider === ConnectionConstants.mssqlProviderName) {
let restoreDialog = this._restoreDialogs[this._currentProvider] as RestoreDialog;
restoreDialog.viewModel.resetRestoreOptions(connection.databaseName!);
this.getMssqlRestoreConfigInfo().then(() => {
// database list is filled only after getMssqlRestoreConfigInfo() calling before will always set to empty value
restoreDialog.viewModel.resetRestoreOptions(connection.databaseName!, restoreDialog.viewModel.databaseList);
restoreDialog.open(connection.serverName, this._ownerUri!);
restoreDialog.validateRestore();
}, restoreConfigError => {

View File

@@ -245,13 +245,13 @@ export class RestoreViewModel {
/**
* Reset restore options to the default value
*/
public resetRestoreOptions(databaseName: string): void {
public resetRestoreOptions(databaseName: string, databaseList: string[] = []): void {
this.sourceDatabaseName = databaseName ? databaseName : '';
this.updateTargetDatabaseName(databaseName);
this.updateSourceDatabaseNames([], this.sourceDatabaseName);
this.databaseList = databaseList;
this.updateSourceDatabaseNames(this.databaseList, this.sourceDatabaseName);
this.updateFilePath('');
this.updateLastBackupTaken('');
this.databaseList = [];
this.selectedBackupSets = undefined;
for (let key in this._optionsMap) {
this._optionsMap[key].defaultValue = this.getDisplayValue(this._optionsMap[key].optionMetadata, this._optionsMap[key].optionMetadata.defaultValue);