From ea464abaafc6f833eee23c7191ab9a4be7c94c55 Mon Sep 17 00:00:00 2001 From: udeeshagautam <46980425+udeeshagautam@users.noreply.github.com> Date: Thu, 30 May 2019 15:34:11 -0700 Subject: [PATCH] show not supported message for backup for Azure (#5762) * show not supported message for backup for Azure * Adding PR comments --- src/sql/workbench/common/actions.ts | 40 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/sql/workbench/common/actions.ts b/src/sql/workbench/common/actions.ts index a655922648..0f7b646150 100644 --- a/src/sql/workbench/common/actions.ts +++ b/src/sql/workbench/common/actions.ts @@ -239,18 +239,25 @@ export class BackupAction extends Task { } runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise { - if (!profile) { - let objectExplorerService = accessor.get(IObjectExplorerService); - let connectionManagementService = accessor.get(IConnectionManagementService); - let workbenchEditorService = accessor.get(IEditorService); - profile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionManagementService, workbenchEditorService); - } - let configurationService = accessor.get(IConfigurationService); - let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures']; + const configurationService = accessor.get(IConfigurationService); + const previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures']; if (!previewFeaturesEnabled) { return accessor.get(INotificationService).info(nls.localize('backup.isPreviewFeature', 'You must enable preview features in order to use backup')); } + const connectionManagementService = accessor.get(IConnectionManagementService); + if (!profile) { + const objectExplorerService = accessor.get(IObjectExplorerService); + const workbenchEditorService = accessor.get(IEditorService); + profile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionManagementService, workbenchEditorService); + } + if (profile) { + const serverInfo = connectionManagementService.getServerInfo(profile.id); + if (serverInfo && serverInfo.isCloud) { + return accessor.get(INotificationService).info(nls.localize('backup.commandNotSupported', 'Backup command is not supported for Azure SQL databases.')); + } + } + TaskUtilities.showBackup( profile, accessor.get(IBackupUiService) @@ -275,12 +282,25 @@ export class RestoreAction extends Task { } runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise { - let configurationService = accessor.get(IConfigurationService); - let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures']; + const configurationService = accessor.get(IConfigurationService); + const previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures']; if (!previewFeaturesEnabled) { return accessor.get(INotificationService).info(nls.localize('restore.isPreviewFeature', 'You must enable preview features in order to use restore')); } + let connectionManagementService = accessor.get(IConnectionManagementService); + if (!profile) { + const objectExplorerService = accessor.get(IObjectExplorerService); + const workbenchEditorService = accessor.get(IEditorService); + profile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionManagementService, workbenchEditorService); + } + if (profile) { + const serverInfo = connectionManagementService.getServerInfo(profile.id); + if (serverInfo && serverInfo.isCloud) { + return accessor.get(INotificationService).info(nls.localize('restore.commandNotSupported', 'Restore command is not supported for Azure SQL databases.')); + } + } + TaskUtilities.showRestore( profile, accessor.get(IRestoreDialogController)