Fix backup/restore dialog titles not updating (#23164)

* Fix backup/restore dialog titles not updating

* Don't cast
This commit is contained in:
Charles Gagnon
2023-05-18 10:58:56 -07:00
committed by GitHub
parent 1efe948abe
commit d3f1d594e9
3 changed files with 17 additions and 6 deletions

View File

@@ -661,7 +661,7 @@ export abstract class Modal extends Disposable implements IThemable {
/**
* Set the title of the modal
*/
protected set title(title: string) {
public set title(title: string) {
this._title = title;
if (this._modalTitle) {
this._modalTitle.innerText = title;
@@ -671,7 +671,7 @@ export abstract class Modal extends Disposable implements IThemable {
}
}
protected get title(): string {
public get title(): string {
return this._title;
}

View File

@@ -17,6 +17,7 @@ import { BackupDialog } from 'sql/workbench/contrib/backup/browser/backupDialog'
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
import { IBackupService, TaskExecutionMode } from 'sql/platform/backup/common/backupService';
import { IBackupUiService } from 'sql/workbench/contrib/backup/common/backupUiService';
import { localize } from 'vs/nls';
export class BackupUiService implements IBackupUiService {
public _serviceBrand: undefined;
@@ -62,11 +63,12 @@ export class BackupUiService implements IBackupUiService {
this._connectionUri = ConnectionUtils.generateUri(connection);
this._currentProvider = connection.providerName;
let backupDialog = this._backupDialogs[this._currentProvider];
const backupDialogTitle = localize('backupDialogTitle', 'Backup database - {0}:{1}', connection.serverName, connection.databaseName);
const backupOptions = this.getOptions(this._currentProvider);
if (!backupDialog) {
let backupOptions = this.getOptions(this._currentProvider);
if (backupOptions) {
backupDialog = this._instantiationService.createInstance(
OptionsDialog, 'Backup database - ' + connection.serverName + ':' + connection.databaseName, 'BackupOptions', undefined);
OptionsDialog, backupDialogTitle, 'BackupOptions', undefined);
backupDialog.onOk(() => this.handleOptionDialogClosed());
}
else {
@@ -74,9 +76,12 @@ export class BackupUiService implements IBackupUiService {
}
backupDialog.render();
this._backupDialogs[this._currentProvider] = backupDialog;
} else if (backupOptions) {
// Update the title for non-MSSQL restores each time so they show the correct database name since those
// use just a basic OptionsDialog which doesn't get updated on every open
backupDialog.title = backupDialogTitle;
}
let backupOptions = this.getOptions(this._currentProvider);
let uri = this._connectionManagementService.getConnectionUri(connection)
+ ProviderConnectionInfo.idSeparator
+ ConnectionUtils.ConnectionUriBackupIdAttributeName

View File

@@ -24,6 +24,7 @@ import { invalidProvider } from 'sql/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log';
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
import { localize } from 'vs/nls';
export class RestoreService implements IRestoreService {
@@ -300,6 +301,7 @@ export class RestoreDialogController implements IRestoreDialogController {
this._connectionService.connect(connection, this._ownerUri).then(connectionResult => {
this._sessionId = undefined;
this._currentProvider = this.getCurrentProviderId();
const dialogTitle = localize('restoreDialogTitle', 'Restore database - {0}:{1}', connection.serverName, connection.databaseName);
if (!this._restoreDialogs[this._currentProvider]) {
let newRestoreDialog: RestoreDialog | OptionsDialog;
if (this._currentProvider === ConnectionConstants.mssqlProviderName) {
@@ -311,12 +313,16 @@ export class RestoreDialogController implements IRestoreDialogController {
newRestoreDialog.onDatabaseListFocused(() => this.fetchDatabases(provider));
} else {
newRestoreDialog = this._instantiationService.createInstance(
OptionsDialog, 'Restore database - ' + connection.serverName + ':' + connection.databaseName, 'RestoreOptions', undefined);
OptionsDialog, dialogTitle, 'RestoreOptions', undefined);
newRestoreDialog.onOk(() => this.handleOnRestore());
}
newRestoreDialog.onCloseEvent(() => this.handleOnClose());
newRestoreDialog.render();
this._restoreDialogs[this._currentProvider] = newRestoreDialog;
} else if (this._currentProvider !== ConnectionConstants.mssqlProviderName) {
// Update the title for non-MSSQL restores each time so they show the correct database name since those
// use just a basic OptionsDialog which doesn't get updated on every open
this._restoreDialogs[this._currentProvider].title = dialogTitle;
}
if (this._currentProvider === ConnectionConstants.mssqlProviderName) {