From f2ee8b11b41ffa238d239f56eb77de2e83d1b613 Mon Sep 17 00:00:00 2001 From: Udeesha Gautam <46980425+udeeshagautam@users.noreply.github.com> Date: Fri, 30 Apr 2021 10:50:26 -0700 Subject: [PATCH] Fixing the update issue with backup default name (#15082) * Fixing the update issue with backup default name * Avoiding to call select again since that fires an event * Fixing comment and backup name --- src/sql/base/browser/ui/selectBox/selectBox.ts | 8 ++++++++ .../workbench/contrib/backup/browser/backup.component.ts | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sql/base/browser/ui/selectBox/selectBox.ts b/src/sql/base/browser/ui/selectBox/selectBox.ts index 9d5cebab61..c70b2d570c 100644 --- a/src/sql/base/browser/ui/selectBox/selectBox.ts +++ b/src/sql/base/browser/ui/selectBox/selectBox.ts @@ -216,6 +216,14 @@ export class SelectBox extends vsSelectBox { let selectOptions: SelectOptionItemSQL[] = SelectBox.createOptions(options); this.populateOptionsDictionary(selectOptions); super.setOptions(selectOptions, selected); + // Adding following since setOptions from super alone is not setting this._selectedOption + let selectedOptionIndex = this._optionsDictionary.get(this._selectedOption); + if (selectedOptionIndex === selected) { + return; + } + if (this._dialogOptions !== undefined) { + this._selectedOption = this._dialogOptions[selected]?.value; + } } public get value(): string { diff --git a/src/sql/workbench/contrib/backup/browser/backup.component.ts b/src/sql/workbench/contrib/backup/browser/backup.component.ts index 33c92bd2bf..a71b65b205 100644 --- a/src/sql/workbench/contrib/backup/browser/backup.component.ts +++ b/src/sql/workbench/contrib/backup/browser/backup.component.ts @@ -740,9 +740,10 @@ export class BackupComponent extends AngularDisposable { } private setDefaultBackupName(): void { - if (this.backupNameBox && (!this.backupNameBox.value || this.backupNameBox.value.trim().length === 0)) { + const suggestedNamePrefix = this.databaseName + '-' + this.getSelectedBackupType().replace(' ', '-'); + if (this.backupNameBox && (!this.backupNameBox.value || this.backupNameBox.value.trim().length === 0 || !this.backupNameBox.value.startsWith(suggestedNamePrefix))) { let utc = new Date().toJSON().slice(0, 19); - this.backupNameBox.value = this.databaseName + '-' + this.getSelectedBackupType() + '-' + utc; + this.backupNameBox.value = suggestedNamePrefix + '-' + utc; } }