mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -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;
|
let self = this;
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
self.showBackupDialog(connection).then(() => {
|
self.showBackupDialog(connection).then(() => {
|
||||||
resolve();
|
resolve(void 0);
|
||||||
}, error => {
|
}, error => {
|
||||||
reject();
|
reject();
|
||||||
});
|
});
|
||||||
@@ -145,7 +145,7 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let backupOptions = this.getOptions(this._currentProvider);
|
let backupOptions = this.getOptions(this._currentProvider);
|
||||||
return new TPromise<void>(() => {
|
return new TPromise<void>((resolve) => {
|
||||||
let uri = this._connectionManagementService.getConnectionUri(connection)
|
let uri = this._connectionManagementService.getConnectionUri(connection)
|
||||||
+ ProviderConnectionInfo.idSeparator
|
+ ProviderConnectionInfo.idSeparator
|
||||||
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
+ ConnectionUtils.ConnectionUriBackupIdAttributeName
|
||||||
@@ -168,6 +168,7 @@ export class BackupUiService implements IBackupUiService {
|
|||||||
} else {
|
} else {
|
||||||
(backupDialog as BackupDialog).open(connection);
|
(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 { TreeUpdateUtils } from 'sql/parts/objectExplorer/viewlet/treeUpdateUtils';
|
||||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||||
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
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 { ConnectionContextKey } from 'sql/parts/connection/common/connectionContextKey';
|
||||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { TreeNodeContextKey } from './treeNodeContextKey';
|
import { TreeNodeContextKey } from './treeNodeContextKey';
|
||||||
@@ -161,8 +161,10 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
private getBuiltInNodeActions(context: ObjectExplorerContext): IAction[] {
|
private getBuiltInNodeActions(context: ObjectExplorerContext): IAction[] {
|
||||||
let actions: IAction[] = [];
|
let actions: IAction[] = [];
|
||||||
let treeNode = context.treeNode;
|
let treeNode = context.treeNode;
|
||||||
|
let isAvailableDatabaseNode = false;
|
||||||
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
||||||
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
||||||
|
isAvailableDatabaseNode = true;
|
||||||
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
|
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
|
||||||
this.addNewQueryAction(context, actions);
|
this.addNewQueryAction(context, actions);
|
||||||
} else {
|
} else {
|
||||||
@@ -171,6 +173,12 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.addScriptingActions(context, actions);
|
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));
|
actions.push(this._instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL, context.tree, treeNode));
|
||||||
|
|
||||||
return actions;
|
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 {
|
private addScriptingActions(context: ObjectExplorerContext, actions: IAction[]): void {
|
||||||
if (this._scriptingService.isProviderRegistered(context.profile.providerName)) {
|
if (this._scriptingService.isProviderRegistered(context.profile.providerName)) {
|
||||||
let scriptMap: Map<NodeType, any[]> = ObjectExplorerActionUtilities.getScriptMap(context.treeNode);
|
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> {
|
export function showBackup(connection: IConnectionProfile, backupUiService: IBackupUiService): Promise<void> {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
backupUiService.showBackup(connection);
|
backupUiService.showBackup(connection).then(() => {
|
||||||
|
resolve(void 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showRestore(connection: IConnectionProfile, restoreDialogService: IRestoreDialogController): Promise<void> {
|
export function showRestore(connection: IConnectionProfile, restoreDialogService: IRestoreDialogController): Promise<void> {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
restoreDialogService.showDialog(connection);
|
restoreDialogService.showDialog(connection).then(() => {
|
||||||
|
resolve(void 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user