mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Fixing an issue where backup launch was freezing ADS and restore launch was not doiing anything. This repros in absence of any connetcions. (#15041)
This commit is contained in:
@@ -19,6 +19,9 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
|
||||
export const BackupFeatureName = 'backup';
|
||||
export const backupIsPreviewFeature = localize('backup.isPreviewFeature', "You must enable preview features in order to use backup");
|
||||
export const backupNotSupportedOutOfDBContext = localize('backup.commandNotSupportedForServer', "Backup command is not supported outside of a database context. Please select a database and try again.");
|
||||
export const backupNotSupportedForAzure = localize('backup.commandNotSupported', "Backup command is not supported for Azure SQL databases.");
|
||||
|
||||
export function showBackup(accessor: ServicesAccessor, connection: IConnectionProfile): Promise<void> {
|
||||
const backupUiService = accessor.get(IBackupUiService);
|
||||
@@ -43,7 +46,7 @@ export class BackupAction extends Task {
|
||||
const configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
const previewFeaturesEnabled = configurationService.getValue<{ enablePreviewFeatures: boolean }>('workbench').enablePreviewFeatures;
|
||||
if (!previewFeaturesEnabled) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(localize('backup.isPreviewFeature', "You must enable preview features in order to use backup"));
|
||||
return accessor.get<INotificationService>(INotificationService).info(backupIsPreviewFeature);
|
||||
}
|
||||
|
||||
const connectionManagementService = accessor.get<IConnectionManagementService>(IConnectionManagementService);
|
||||
@@ -55,17 +58,20 @@ export class BackupAction extends Task {
|
||||
if (profile) {
|
||||
const serverInfo = connectionManagementService.getServerInfo(profile.id);
|
||||
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(localize('backup.commandNotSupported', "Backup command is not supported for Azure SQL databases."));
|
||||
return accessor.get<INotificationService>(INotificationService).info(backupNotSupportedForAzure);
|
||||
}
|
||||
|
||||
if (!profile.databaseName && profile.providerName === mssqlProviderName) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(localize('backup.commandNotSupportedForServer', "Backup command is not supported in Server Context. Please select a Database and try again."));
|
||||
return accessor.get<INotificationService>(INotificationService).info(backupNotSupportedOutOfDBContext);
|
||||
}
|
||||
}
|
||||
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
profile = profile ? profile : new ConnectionProfile(capabilitiesService, profile);
|
||||
if (!profile.databaseName) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(backupNotSupportedOutOfDBContext);
|
||||
}
|
||||
return instantiationService.invokeFunction(showBackup, profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ export function showRestore(accessor: ServicesAccessor, connection: IConnectionP
|
||||
}
|
||||
|
||||
export const RestoreFeatureName = 'restore';
|
||||
export const restoreIsPreviewFeature = localize('restore.isPreviewFeature', "You must enable preview features in order to use restore");
|
||||
export const restoreNotSupportedOutOfContext = localize('restore.commandNotSupportedOutsideContext', "Restore command is not supported outside of a server context. Please select a server or database and try again.");
|
||||
export const restoreNotSupportedForAzure = localize('restore.commandNotSupported', "Restore command is not supported for Azure SQL databases.");
|
||||
|
||||
|
||||
export class RestoreAction extends Task {
|
||||
public static readonly ID = RestoreFeatureName;
|
||||
@@ -44,7 +48,7 @@ export class RestoreAction extends Task {
|
||||
const configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
const previewFeaturesEnabled: boolean = configurationService.getValue<{ enablePreviewFeatures: boolean }>('workbench').enablePreviewFeatures;
|
||||
if (!previewFeaturesEnabled) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(localize('restore.isPreviewFeature', "You must enable preview features in order to use restore"));
|
||||
return accessor.get<INotificationService>(INotificationService).info(restoreIsPreviewFeature);
|
||||
}
|
||||
|
||||
let connectionManagementService = accessor.get<IConnectionManagementService>(IConnectionManagementService);
|
||||
@@ -56,13 +60,16 @@ export class RestoreAction extends Task {
|
||||
if (profile) {
|
||||
const serverInfo = connectionManagementService.getServerInfo(profile.id);
|
||||
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(localize('restore.commandNotSupported', "Restore command is not supported for Azure SQL databases."));
|
||||
return accessor.get<INotificationService>(INotificationService).info(restoreNotSupportedForAzure);
|
||||
}
|
||||
}
|
||||
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
profile = profile ? profile : new ConnectionProfile(capabilitiesService, profile);
|
||||
if (!profile.serverName) {
|
||||
return accessor.get<INotificationService>(INotificationService).info(restoreNotSupportedOutOfContext);
|
||||
}
|
||||
return instantiationService.invokeFunction(showRestore, profile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user