|
3 | 3 | 'use strict';
|
4 | 4 | import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api';
|
5 | 5 |
|
6 |
| -import { IRefreshVariablesRequest } from '../../../client/datascience/interactive-common/interactiveWindowTypes'; |
| 6 | +import { InteractiveWindowMessages, IRefreshVariablesRequest } from '../../../client/datascience/interactive-common/interactiveWindowTypes'; |
7 | 7 | import { IJupyterVariable, IJupyterVariablesRequest } from '../../../client/datascience/types';
|
8 | 8 | import {
|
9 | 9 | CommonAction,
|
10 | 10 | CommonActionType,
|
| 11 | + createIncomingAction, |
| 12 | + createIncomingActionWithPayload, |
11 | 13 | ICellAction,
|
12 | 14 | ICodeAction,
|
13 | 15 | ICodeCreatedAction,
|
14 | 16 | IEditCellAction,
|
15 | 17 | ILinkClickAction,
|
16 | 18 | IScrollAction,
|
17 |
| - IShowDataViewerAction, |
18 |
| - IShowPlotAction |
| 19 | + IShowDataViewerAction |
19 | 20 | } from '../../interactive-common/redux/reducers/types';
|
20 | 21 |
|
21 | 22 | // See https://react-redux.js.org/using-react-redux/connect-mapdispatch#defining-mapdispatchtoprops-as-an-object
|
22 | 23 | export const actionCreators = {
|
23 |
| - refreshVariables: (newExecutionCount?: number): CommonAction<IRefreshVariablesRequest> => ({ type: CommonActionType.REFRESH_VARIABLES, payload: { newExecutionCount } }), |
24 |
| - restartKernel: (): CommonAction<never | undefined> => ({ type: CommonActionType.RESTART_KERNEL }), |
25 |
| - interruptKernel: (): CommonAction<never | undefined> => ({ type: CommonActionType.INTERRUPT_KERNEL }), |
26 |
| - deleteAllCells: (): CommonAction<never | undefined> => ({ type: CommonActionType.DELETE_ALL_CELLS }), |
27 |
| - deleteCell: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.DELETE_CELL, payload: { cellId } }), |
28 |
| - undo: (): CommonAction<never | undefined> => ({ type: CommonActionType.UNDO }), |
29 |
| - redo: (): CommonAction<never | undefined> => ({ type: CommonActionType.REDO }), |
30 |
| - linkClick: (href: string): CommonAction<ILinkClickAction> => ({ type: CommonActionType.LINK_CLICK, payload: { href } }), |
31 |
| - showPlot: (imageHtml: string): CommonAction<IShowPlotAction> => ({ type: CommonActionType.SHOW_PLOT, payload: { imageHtml } }), |
32 |
| - toggleInputBlock: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.TOGGLE_INPUT_BLOCK, payload: { cellId } }), |
33 |
| - gotoCell: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.GOTO_CELL, payload: { cellId } }), |
34 |
| - copyCellCode: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.COPY_CELL_CODE, payload: { cellId } }), |
35 |
| - gatherCell: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.GATHER_CELL, payload: { cellId } }), |
36 |
| - clickCell: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.CLICK_CELL, payload: { cellId } }), |
37 |
| - doubleClickCell: (cellId: string): CommonAction<ICellAction> => ({ type: CommonActionType.DOUBLE_CLICK_CELL, payload: { cellId } }), |
38 |
| - editCell: (cellId: string, changes: monacoEditor.editor.IModelContentChange[], modelId: string, code: string): CommonAction<IEditCellAction> => ({ |
39 |
| - type: CommonActionType.EDIT_CELL, |
40 |
| - payload: { cellId, changes, modelId, code } |
41 |
| - }), |
42 |
| - submitInput: (code: string, cellId: string): CommonAction<ICodeAction> => ({ type: CommonActionType.SUBMIT_INPUT, payload: { code, cellId } }), |
43 |
| - toggleVariableExplorer: (): CommonAction<never | undefined> => ({ type: CommonActionType.TOGGLE_VARIABLE_EXPLORER }), |
44 |
| - expandAll: (): CommonAction<never | undefined> => ({ type: CommonActionType.EXPAND_ALL }), |
45 |
| - collapseAll: (): CommonAction<never | undefined> => ({ type: CommonActionType.COLLAPSE_ALL }), |
46 |
| - export: (): CommonAction<never | undefined> => ({ type: CommonActionType.EXPORT }), |
47 |
| - showDataViewer: (variable: IJupyterVariable, columnSize: number): CommonAction<IShowDataViewerAction> => ({ |
48 |
| - type: CommonActionType.SHOW_DATA_VIEWER, |
49 |
| - payload: { variable, columnSize } |
50 |
| - }), |
51 |
| - editorLoaded: (): CommonAction<never | undefined> => ({ type: CommonActionType.EDITOR_LOADED }), |
52 |
| - scroll: (isAtBottom: boolean): CommonAction<IScrollAction> => ({ type: CommonActionType.SCROLL, payload: { isAtBottom } }), |
53 |
| - unfocus: (cellId: string | undefined): CommonAction<ICellAction> => ({ type: CommonActionType.UNFOCUS_CELL, payload: { cellId } }), |
54 |
| - codeCreated: (cellId: string | undefined, modelId: string): CommonAction<ICodeCreatedAction> => ({ type: CommonActionType.CODE_CREATED, payload: { cellId, modelId } }), |
55 |
| - editorUnmounted: (): CommonAction<never | undefined> => ({ type: CommonActionType.UNMOUNT }), |
56 |
| - selectKernel: (): CommonAction<never | undefined> => ({ type: CommonActionType.SELECT_KERNEL }), |
57 |
| - selectServer: (): CommonAction<never | undefined> => ({ type: CommonActionType.SELECT_SERVER }), |
58 |
| - getVariableData: (newExecutionCount: number, startIndex: number = 0, pageSize: number = 100): CommonAction<IJupyterVariablesRequest> => ({ |
59 |
| - type: CommonActionType.GET_VARIABLE_DATA, |
60 |
| - payload: { executionCount: newExecutionCount, sortColumn: 'name', sortAscending: true, startIndex, pageSize } |
61 |
| - }) |
| 24 | + refreshVariables: (newExecutionCount?: number): CommonAction<IRefreshVariablesRequest> => |
| 25 | + createIncomingActionWithPayload(CommonActionType.REFRESH_VARIABLES, { newExecutionCount }), |
| 26 | + restartKernel: (): CommonAction => createIncomingAction(CommonActionType.RESTART_KERNEL), |
| 27 | + interruptKernel: (): CommonAction => createIncomingAction(CommonActionType.INTERRUPT_KERNEL), |
| 28 | + deleteAllCells: (): CommonAction => createIncomingAction(InteractiveWindowMessages.DeleteAllCells), |
| 29 | + deleteCell: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(InteractiveWindowMessages.DeleteCell, { cellId }), |
| 30 | + undo: (): CommonAction => createIncomingAction(InteractiveWindowMessages.Undo), |
| 31 | + redo: (): CommonAction => createIncomingAction(InteractiveWindowMessages.Redo), |
| 32 | + linkClick: (href: string): CommonAction<ILinkClickAction> => createIncomingActionWithPayload(CommonActionType.LINK_CLICK, { href }), |
| 33 | + showPlot: (imageHtml: string): CommonAction<string> => createIncomingActionWithPayload(InteractiveWindowMessages.ShowPlot, imageHtml), |
| 34 | + toggleInputBlock: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.TOGGLE_INPUT_BLOCK, { cellId }), |
| 35 | + gotoCell: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.GOTO_CELL, { cellId }), |
| 36 | + copyCellCode: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.COPY_CELL_CODE, { cellId }), |
| 37 | + gatherCell: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.GATHER_CELL, { cellId }), |
| 38 | + clickCell: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.CLICK_CELL, { cellId }), |
| 39 | + doubleClickCell: (cellId: string): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.DOUBLE_CLICK_CELL, { cellId }), |
| 40 | + editCell: (cellId: string, changes: monacoEditor.editor.IModelContentChange[], modelId: string, code: string): CommonAction<IEditCellAction> => |
| 41 | + createIncomingActionWithPayload(CommonActionType.EDIT_CELL, { cellId, changes, modelId, code }), |
| 42 | + submitInput: (code: string, cellId: string): CommonAction<ICodeAction> => createIncomingActionWithPayload(CommonActionType.SUBMIT_INPUT, { code, cellId }), |
| 43 | + toggleVariableExplorer: (): CommonAction => createIncomingAction(CommonActionType.TOGGLE_VARIABLE_EXPLORER), |
| 44 | + expandAll: (): CommonAction => createIncomingAction(InteractiveWindowMessages.ExpandAll), |
| 45 | + collapseAll: (): CommonAction => createIncomingAction(InteractiveWindowMessages.CollapseAll), |
| 46 | + export: (): CommonAction => createIncomingAction(CommonActionType.EXPORT), |
| 47 | + showDataViewer: (variable: IJupyterVariable, columnSize: number): CommonAction<IShowDataViewerAction> => |
| 48 | + createIncomingActionWithPayload(CommonActionType.SHOW_DATA_VIEWER, { variable, columnSize }), |
| 49 | + editorLoaded: (): CommonAction => createIncomingAction(CommonActionType.EDITOR_LOADED), |
| 50 | + scroll: (isAtBottom: boolean): CommonAction<IScrollAction> => createIncomingActionWithPayload(CommonActionType.SCROLL, { isAtBottom }), |
| 51 | + unfocus: (cellId: string | undefined): CommonAction<ICellAction> => createIncomingActionWithPayload(CommonActionType.UNFOCUS_CELL, { cellId }), |
| 52 | + codeCreated: (cellId: string | undefined, modelId: string): CommonAction<ICodeCreatedAction> => |
| 53 | + createIncomingActionWithPayload(CommonActionType.CODE_CREATED, { cellId, modelId }), |
| 54 | + editorUnmounted: (): CommonAction => createIncomingAction(CommonActionType.UNMOUNT), |
| 55 | + selectKernel: (): CommonAction => createIncomingAction(InteractiveWindowMessages.SelectKernel), |
| 56 | + selectServer: (): CommonAction => createIncomingAction(CommonActionType.SELECT_SERVER), |
| 57 | + getVariableData: (newExecutionCount: number, startIndex: number = 0, pageSize: number = 100): CommonAction<IJupyterVariablesRequest> => |
| 58 | + createIncomingActionWithPayload(CommonActionType.GET_VARIABLE_DATA, { executionCount: newExecutionCount, sortColumn: 'name', sortAscending: true, startIndex, pageSize }) |
62 | 59 | };
|
0 commit comments