mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Remove unused code (#4873)
* removes unused features * remove more unused code; formatting * lock changes * fix run issue
This commit is contained in:
@@ -12,7 +12,6 @@ import { IScriptingService } from 'sql/platform/scripting/common/scriptingServic
|
||||
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
|
||||
import { IAngularEventingService, AngularEventType } from 'sql/platform/angularEventing/common/angularEventingService';
|
||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/common/insightsDialogService';
|
||||
import { IAdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
import * as Constants from 'sql/common/constants';
|
||||
import { Task } from 'sql/platform/tasks/common/tasks';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||
@@ -58,22 +57,13 @@ export class NewQueryAction extends Task {
|
||||
}
|
||||
|
||||
public runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.newQuery(
|
||||
profile,
|
||||
accessor.get<IConnectionManagementService>(IConnectionManagementService),
|
||||
accessor.get<IQueryEditorService>(IQueryEditorService),
|
||||
accessor.get<IObjectExplorerService>(IObjectExplorerService),
|
||||
accessor.get<IEditorService>(IEditorService)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.newQuery(
|
||||
profile,
|
||||
accessor.get<IConnectionManagementService>(IConnectionManagementService),
|
||||
accessor.get<IQueryEditorService>(IQueryEditorService),
|
||||
accessor.get<IObjectExplorerService>(IObjectExplorerService),
|
||||
accessor.get<IEditorService>(IEditorService)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,21 +81,13 @@ export class ScriptSelectAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.scriptSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
return TaskUtilities.scriptSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,24 +106,15 @@ export class ScriptExecuteAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Execute,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Execute,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,24 +133,15 @@ export class ScriptAlterAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Alter,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Alter,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,22 +159,13 @@ export class EditDataAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.scriptEditSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.scriptEditSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,24 +184,15 @@ export class ScriptCreateAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Create,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Create,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,24 +211,15 @@ export class ScriptDeleteAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Delete,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Delete,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +237,7 @@ export class BackupAction extends Task {
|
||||
});
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise<void> {
|
||||
if (!profile) {
|
||||
let objectExplorerService = accessor.get<IObjectExplorerService>(IObjectExplorerService);
|
||||
let connectionManagementService = accessor.get<IConnectionManagementService>(IConnectionManagementService);
|
||||
@@ -310,24 +247,13 @@ export class BackupAction extends Task {
|
||||
let configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||
if (!previewFeaturesEnabled) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.isPreviewFeature', 'You must enable preview features in order to use backup'));
|
||||
});
|
||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.isPreviewFeature', 'You must enable preview features in order to use backup'));
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.showBackup(
|
||||
profile,
|
||||
accessor.get<IBackupUiService>(IBackupUiService)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
TaskUtilities.showBackup(
|
||||
profile,
|
||||
accessor.get<IBackupUiService>(IBackupUiService)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,28 +271,17 @@ export class RestoreAction extends Task {
|
||||
});
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise<void> {
|
||||
let configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||
if (!previewFeaturesEnabled) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.isPreviewFeature', 'You must enable preview features in order to use restore'));
|
||||
});
|
||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.isPreviewFeature', 'You must enable preview features in order to use restore'));
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.showRestore(
|
||||
profile,
|
||||
accessor.get<IRestoreDialogController>(IRestoreDialogController)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
TaskUtilities.showRestore(
|
||||
profile,
|
||||
accessor.get<IRestoreDialogController>(IRestoreDialogController)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,18 +298,12 @@ export class ManageAction extends Action {
|
||||
}
|
||||
|
||||
run(actionContext: ManageActionContext): Promise<boolean> {
|
||||
let self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
self._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
||||
() => {
|
||||
self._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
return this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
||||
() => {
|
||||
this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,31 +319,8 @@ export class InsightAction extends Action {
|
||||
}
|
||||
|
||||
run(actionContext: InsightActionContext): Promise<boolean> {
|
||||
let self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
self._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class NewDatabaseAction extends Action {
|
||||
public static ID = 'newDatabase';
|
||||
public static LABEL = nls.localize('newDatabase', 'New Database');
|
||||
public static ICON = 'new-database';
|
||||
|
||||
constructor(
|
||||
id: string, label: string, icon: string,
|
||||
@IAdminService private _adminService: IAdminService,
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
) {
|
||||
super(id, label, icon);
|
||||
}
|
||||
|
||||
run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.showCreateDatabase(actionContext.profile, this._adminService, this._errorMessageService);
|
||||
});
|
||||
this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +340,6 @@ export class ConfigureDashboardAction extends Task {
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then((result) => {
|
||||
resolve(void 0);
|
||||
}, err => {
|
||||
resolve(void 0);
|
||||
});
|
||||
});
|
||||
return accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user