mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Added context menu for DBs in explorer view to backup & restore db. (#2277)
* Added context menu for DBs in explorer view to backup & restore db. Fixed bug where progress bar didn't complete on backup/restore menuclick #2084 * Fix merge conflicts
This commit is contained in:
@@ -109,7 +109,7 @@ export class BackupUiService implements IBackupUiService {
|
||||
let self = this;
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
self.showBackupDialog(connection).then(() => {
|
||||
resolve();
|
||||
resolve(void 0);
|
||||
}, error => {
|
||||
reject();
|
||||
});
|
||||
@@ -145,7 +145,7 @@ export class BackupUiService implements IBackupUiService {
|
||||
}
|
||||
|
||||
let backupOptions = this.getOptions(this._currentProvider);
|
||||
return new TPromise<void>(() => {
|
||||
return new TPromise<void>((resolve) => {
|
||||
let uri = this._connectionManagementService.getConnectionUri(connection)
|
||||
+ ProviderConnectionInfo.idSeparator
|
||||
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
||||
@@ -168,6 +168,7 @@ export class BackupUiService implements IBackupUiService {
|
||||
} else {
|
||||
(backupDialog as BackupDialog).open(connection);
|
||||
}
|
||||
resolve(void 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile
|
||||
import { TreeUpdateUtils } from 'sql/parts/objectExplorer/viewlet/treeUpdateUtils';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { NewQueryAction } from 'sql/workbench/common/actions';
|
||||
import { NewQueryAction, BackupAction, RestoreAction } from 'sql/workbench/common/actions';
|
||||
import { ConnectionContextKey } from 'sql/parts/connection/common/connectionContextKey';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { TreeNodeContextKey } from './treeNodeContextKey';
|
||||
@@ -161,8 +161,10 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
||||
private getBuiltInNodeActions(context: ObjectExplorerContext): IAction[] {
|
||||
let actions: IAction[] = [];
|
||||
let treeNode = context.treeNode;
|
||||
let isAvailableDatabaseNode = false;
|
||||
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
||||
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
||||
isAvailableDatabaseNode = true;
|
||||
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
|
||||
this.addNewQueryAction(context, actions);
|
||||
} else {
|
||||
@@ -171,6 +173,12 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
||||
}
|
||||
|
||||
this.addScriptingActions(context, actions);
|
||||
|
||||
if (isAvailableDatabaseNode) {
|
||||
this.addBackupAction(context, actions);
|
||||
this.addRestoreAction(context, actions);
|
||||
}
|
||||
|
||||
actions.push(this._instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL, context.tree, treeNode));
|
||||
|
||||
return actions;
|
||||
@@ -182,6 +190,18 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private addBackupAction(context: ObjectExplorerContext, actions: IAction[]): void {
|
||||
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
|
||||
actions.push(this._instantiationService.createInstance(OEAction, BackupAction.ID, BackupAction.LABEL));
|
||||
}
|
||||
}
|
||||
|
||||
private addRestoreAction(context: ObjectExplorerContext, actions: IAction[]): void {
|
||||
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
|
||||
actions.push(this._instantiationService.createInstance(OEAction, RestoreAction.ID, RestoreAction.LABEL));
|
||||
}
|
||||
}
|
||||
|
||||
private addScriptingActions(context: ObjectExplorerContext, actions: IAction[]): void {
|
||||
if (this._scriptingService.isProviderRegistered(context.profile.providerName)) {
|
||||
let scriptMap: Map<NodeType, any[]> = ObjectExplorerActionUtilities.getScriptMap(context.treeNode);
|
||||
|
||||
@@ -354,13 +354,17 @@ export function showCreateLogin(uri: string, connection: IConnectionProfile, adm
|
||||
|
||||
export function showBackup(connection: IConnectionProfile, backupUiService: IBackupUiService): Promise<void> {
|
||||
return new Promise<void>((resolve) => {
|
||||
backupUiService.showBackup(connection);
|
||||
backupUiService.showBackup(connection).then(() => {
|
||||
resolve(void 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function showRestore(connection: IConnectionProfile, restoreDialogService: IRestoreDialogController): Promise<void> {
|
||||
return new Promise<void>((resolve) => {
|
||||
restoreDialogService.showDialog(connection);
|
||||
restoreDialogService.showDialog(connection).then(() => {
|
||||
resolve(void 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user