mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
Update action run return type (#15568)
* Update action run return type * fix tests * Update rest * Add back null checks
This commit is contained in:
@@ -30,14 +30,9 @@ export class EditDashboardAction extends Action {
|
||||
super(EditDashboardAction.ID, EditDashboardAction.EDITLABEL, EditDashboardAction.ICON);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
try {
|
||||
this.editFn.apply(this.context);
|
||||
this.toggleLabel();
|
||||
return Promise.resolve(true);
|
||||
} catch (e) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
async run(): Promise<void> {
|
||||
this.editFn.apply(this.context);
|
||||
this.toggleLabel();
|
||||
}
|
||||
|
||||
private toggleLabel(): void {
|
||||
@@ -64,13 +59,8 @@ export class RefreshWidgetAction extends Action {
|
||||
super(RefreshWidgetAction.ID, RefreshWidgetAction.LABEL, RefreshWidgetAction.ICON);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
try {
|
||||
this.refreshFn.apply(this.context);
|
||||
return Promise.resolve(true);
|
||||
} catch (e) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
async run(): Promise<void> {
|
||||
this.refreshFn.apply(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +76,11 @@ export class ToolbarAction extends Action {
|
||||
super(id, label, cssClass);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
async run(): Promise<void> {
|
||||
try {
|
||||
this.runFn.apply(this.context, [this.id]);
|
||||
return Promise.resolve(true);
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,13 +99,12 @@ export class ToggleMoreWidgetAction extends Action {
|
||||
super(ToggleMoreWidgetAction.ID, ToggleMoreWidgetAction.LABEL, ToggleMoreWidgetAction.ICON);
|
||||
}
|
||||
|
||||
run(context: StandardKeyboardEvent): Promise<boolean> {
|
||||
async run(context: StandardKeyboardEvent): Promise<void> {
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => context.target,
|
||||
getActions: () => this._actions,
|
||||
getActionsContext: () => this._context
|
||||
});
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +121,8 @@ export class DeleteWidgetAction extends Action {
|
||||
super(DeleteWidgetAction.ID, DeleteWidgetAction.LABEL, DeleteWidgetAction.ICON);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
async run(): Promise<void> {
|
||||
this.angularEventService.sendAngularEvent(this._uri, AngularEventType.DELETE_WIDGET, { id: this._widgetId });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,11 +153,10 @@ export class PinUnpinTabAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
public run(): Promise<boolean> {
|
||||
public async run(): Promise<void> {
|
||||
this._isPinned = !this._isPinned;
|
||||
this.updatePinStatus();
|
||||
this.angularEventService.sendAngularEvent(this._uri, AngularEventType.PINUNPIN_TAB, { tabId: this._tabId, isPinned: this._isPinned });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +176,8 @@ export class AddFeatureTabAction extends Action {
|
||||
this._register(this._angularEventService.onAngularEvent(this._uri)(event => this.handleDashboardEvent(event)));
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
async run(): Promise<void> {
|
||||
this._newDashboardTabService.showDialog(this._dashboardTabs, this._openedTabs, this._uri);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
private handleDashboardEvent(event: IAngularEvent): void {
|
||||
@@ -236,10 +220,9 @@ export class CollapseWidgetAction extends Action {
|
||||
this.expanded = !this.collpasedState;
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
async run(): Promise<void> {
|
||||
this._toggleState();
|
||||
this._angularEventService.sendAngularEvent(this._uri, AngularEventType.COLLAPSE_WIDGET, this._widgetUuid);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
private _toggleState(): void {
|
||||
|
||||
@@ -72,20 +72,14 @@ export class OEManageConnectionAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(actionContext: ObjectExplorerActionsContext): Promise<any> {
|
||||
async run(actionContext: ObjectExplorerActionsContext): Promise<void> {
|
||||
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
||||
this._treeSelectionHandler.onTreeActionStateChange(true);
|
||||
let self = this;
|
||||
let promise = new Promise<boolean>((resolve, reject) => {
|
||||
self.doManage(actionContext).then((success) => {
|
||||
self.done();
|
||||
resolve(success);
|
||||
}, error => {
|
||||
self.done();
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
try {
|
||||
await this.doManage(actionContext);
|
||||
} finally {
|
||||
this.done();
|
||||
}
|
||||
}
|
||||
|
||||
private async doManage(actionContext: ObjectExplorerActionsContext): Promise<boolean> {
|
||||
|
||||
@@ -18,9 +18,8 @@ export class ExplorerManageAction extends ManageAction {
|
||||
super(id, label, connectionManagementService, angularEventingService);
|
||||
}
|
||||
|
||||
public run(actionContext: ManageActionContext): Promise<boolean> {
|
||||
const promise = super.run(actionContext);
|
||||
return promise;
|
||||
public async run(actionContext: ManageActionContext): Promise<void> {
|
||||
await super.run(actionContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export class RunInsightQueryAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(context: InsightActionContext): Promise<boolean> {
|
||||
public async run(context: InsightActionContext): Promise<void> {
|
||||
let queryString: string = undefined;
|
||||
let eol: string = this._textResourcePropertiesService.getEOL(undefined);
|
||||
if (context.insight && context.insight.query) {
|
||||
@@ -34,9 +34,9 @@ export class RunInsightQueryAction extends Action {
|
||||
queryString = context.insight.query.join(eol);
|
||||
}
|
||||
} else {
|
||||
return Promise.resolve(false);
|
||||
return;
|
||||
}
|
||||
return this.instantiationService.invokeFunction(openNewQuery, context.profile, queryString,
|
||||
RunQueryOnConnectionMode.executeQuery).then(() => true, () => false);
|
||||
await this.instantiationService.invokeFunction(openNewQuery, context.profile, queryString,
|
||||
RunQueryOnConnectionMode.executeQuery);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user