mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -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:
@@ -52,17 +52,9 @@ export class EditCellAction extends ToggleableAction {
|
||||
this.toggle(value);
|
||||
}
|
||||
|
||||
public run(context: CellContext): Promise<boolean> {
|
||||
let self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
self.editMode = !self.editMode;
|
||||
context.cell.isEditMode = self.editMode;
|
||||
resolve(true);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
public async run(context: CellContext): Promise<void> {
|
||||
this.editMode = !this.editMode;
|
||||
context.cell.isEditMode = this.editMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,13 +350,12 @@ export class ToggleMoreActions extends Action {
|
||||
super(ToggleMoreActions.ID, ToggleMoreActions.LABEL, ToggleMoreActions.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,10 @@ export abstract class CellActionBase extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
public run(context: CellContext): Promise<boolean> {
|
||||
public async run(context: CellContext): Promise<void> {
|
||||
if (hasModelAndCell(context, this.notificationService)) {
|
||||
return this.doRun(context).then(() => true);
|
||||
return this.doRun(context);
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
abstract doRun(context: CellContext): Promise<void>;
|
||||
@@ -172,8 +171,8 @@ export class RunCellAction extends MultiStateAction<CellExecutionState> {
|
||||
this.ensureContextIsUpdated(context);
|
||||
}
|
||||
|
||||
public run(context?: CellContext): Promise<boolean> {
|
||||
return this.doRun(context).then(() => true);
|
||||
public async run(context?: CellContext): Promise<void> {
|
||||
return this.doRun(context);
|
||||
}
|
||||
|
||||
public async doRun(context: CellContext): Promise<void> {
|
||||
|
||||
@@ -31,14 +31,13 @@ export class TransformMarkdownAction extends Action {
|
||||
super(id, label, cssClass);
|
||||
this._tooltip = tooltip;
|
||||
}
|
||||
public async run(context: any): Promise<boolean> {
|
||||
public async run(context: any): Promise<void> {
|
||||
if (!context?.cellModel?.showMarkdown && context?.cellModel?.showPreview) {
|
||||
this.transformDocumentCommand();
|
||||
} else {
|
||||
let markdownTextTransformer = new MarkdownTextTransformer(this._notebookService, this._cellModel);
|
||||
await markdownTextTransformer.transformText(this._type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private transformDocumentCommand() {
|
||||
@@ -607,7 +606,7 @@ export class ToggleViewAction extends Action {
|
||||
this._tooltip = tooltip;
|
||||
}
|
||||
|
||||
public async run(context: MarkdownToolbarComponent): Promise<boolean> {
|
||||
public async run(context: MarkdownToolbarComponent): Promise<void> {
|
||||
context.removeActiveClassFromModeActions();
|
||||
this.class += ' active';
|
||||
context.cellModel.showPreview = this.showPreview;
|
||||
@@ -618,6 +617,5 @@ export class ToggleViewAction extends Action {
|
||||
} else {
|
||||
context.showLinkAndImageButtons();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ export class ClearAllOutputsAction extends TooltipFromLabelAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(context: URI): Promise<boolean> {
|
||||
public async run(context: URI): Promise<void> {
|
||||
const editor = this._notebookService.findNotebookEditor(context);
|
||||
return editor.clearAllOutputs();
|
||||
await editor.clearAllOutputs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,11 +208,10 @@ export class TrustedAction extends ToggleableAction {
|
||||
this.toggle(value);
|
||||
}
|
||||
|
||||
public async run(context: URI): Promise<boolean> {
|
||||
public async run(context: URI): Promise<void> {
|
||||
const editor = this._notebookService.findNotebookEditor(context);
|
||||
this.trusted = !this.trusted;
|
||||
editor.model.trustedMode = this.trusted;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,15 +225,13 @@ export class RunAllCellsAction extends Action {
|
||||
) {
|
||||
super(id, label, cssClass);
|
||||
}
|
||||
public async run(context: URI): Promise<boolean> {
|
||||
public async run(context: URI): Promise<void> {
|
||||
try {
|
||||
this._telemetryService.sendActionEvent(TelemetryKeys.TelemetryView.Notebook, TelemetryKeys.NbTelemetryAction.RunAll);
|
||||
const editor = this._notebookService.findNotebookEditor(context);
|
||||
await editor.runAllCells();
|
||||
return true;
|
||||
} catch (e) {
|
||||
this.notificationService.error(getErrorMessage(e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,13 +267,12 @@ export class CollapseCellsAction extends ToggleableAction {
|
||||
this.expanded = !value;
|
||||
}
|
||||
|
||||
public async run(context: URI): Promise<boolean> {
|
||||
public async run(context: URI): Promise<void> {
|
||||
const editor = this._notebookService.findNotebookEditor(context);
|
||||
this.setCollapsed(!this.isCollapsed);
|
||||
editor.cells.forEach(cell => {
|
||||
cell.isCollapsed = this.isCollapsed;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ export class NotebookChartAction extends ToggleableAction {
|
||||
});
|
||||
}
|
||||
|
||||
public async run(context: IGridActionContext): Promise<boolean> {
|
||||
public async run(context: IGridActionContext): Promise<void> {
|
||||
this.resourceTable.toggleChartVisibility();
|
||||
this.toggle(!this.state.isOn);
|
||||
if (this.state.isOn) {
|
||||
@@ -573,6 +573,5 @@ export class NotebookChartAction extends ToggleableAction {
|
||||
).send();
|
||||
this.resourceTable.updateChartData(Math.min(rowCount, maxRowCount), columnCount, context.gridDataProvider);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user