mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
Backend work for Notebook Parameterization and Tests (#12914)
* Backend work for Parameterization + Tests * minor comments * fix test * address comments
This commit is contained in:
@@ -145,6 +145,9 @@ export class CellToggleMoreActions {
|
||||
instantiationService.createInstance(CollapseCellAction, 'collapseCell', localize('collapseCell', "Collapse Cell"), true),
|
||||
instantiationService.createInstance(CollapseCellAction, 'expandCell', localize('expandCell', "Expand Cell"), false),
|
||||
new Separator(),
|
||||
instantiationService.createInstance(ParametersCellAction, 'makeParameterCell', localize('makeParameterCell', "Make parameter cell"), true),
|
||||
instantiationService.createInstance(ParametersCellAction, 'removeParameterCell', localize('RemoveParameterCell', "Remove parameter cell"), false),
|
||||
new Separator(),
|
||||
instantiationService.createInstance(ClearCellOutputAction, 'clear', localize('clear', "Clear Result")),
|
||||
);
|
||||
}
|
||||
@@ -364,3 +367,40 @@ export class ToggleMoreActions extends Action {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
export class ParametersCellAction extends CellActionBase {
|
||||
constructor(id: string,
|
||||
label: string,
|
||||
private parametersCell: boolean,
|
||||
@INotificationService notificationService: INotificationService
|
||||
) {
|
||||
super(id, label, undefined, notificationService);
|
||||
}
|
||||
|
||||
public canRun(context: CellContext): boolean {
|
||||
return context.cell?.cellType === CellTypes.Code;
|
||||
}
|
||||
|
||||
async doRun(context: CellContext): Promise<void> {
|
||||
try {
|
||||
let cell = context.cell || context.model.activeCell;
|
||||
if (cell) {
|
||||
if (this.parametersCell) {
|
||||
if (!cell.isParameter) {
|
||||
cell.isParameter = true;
|
||||
}
|
||||
} else {
|
||||
if (cell.isParameter) {
|
||||
cell.isParameter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
let message = getErrorMessage(error);
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user