@deephaven/console 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Console.css +44 -0
- package/dist/Console.css.map +1 -0
- package/dist/Console.js +875 -0
- package/dist/Console.js.map +1 -0
- package/dist/ConsoleInput.css +42 -0
- package/dist/ConsoleInput.css.map +1 -0
- package/dist/ConsoleInput.js +442 -0
- package/dist/ConsoleInput.js.map +1 -0
- package/dist/ConsoleMenu.css +25 -0
- package/dist/ConsoleMenu.css.map +1 -0
- package/dist/ConsoleMenu.js +192 -0
- package/dist/ConsoleMenu.js.map +1 -0
- package/dist/ConsolePropTypes.js +10 -0
- package/dist/ConsolePropTypes.js.map +1 -0
- package/dist/ConsoleShortcuts.js +85 -0
- package/dist/ConsoleShortcuts.js.map +1 -0
- package/dist/ConsoleStatusBar.css +52 -0
- package/dist/ConsoleStatusBar.css.map +1 -0
- package/dist/ConsoleStatusBar.js +105 -0
- package/dist/ConsoleStatusBar.js.map +1 -0
- package/dist/HeapUsage.css +61 -0
- package/dist/HeapUsage.css.map +1 -0
- package/dist/HeapUsage.js +168 -0
- package/dist/HeapUsage.js.map +1 -0
- package/dist/StoragePropTypes.js +16 -0
- package/dist/StoragePropTypes.js.map +1 -0
- package/dist/command-history/CommandHistory.css +41 -0
- package/dist/command-history/CommandHistory.css.map +1 -0
- package/dist/command-history/CommandHistory.js +381 -0
- package/dist/command-history/CommandHistory.js.map +1 -0
- package/dist/command-history/CommandHistoryActions.css +10 -0
- package/dist/command-history/CommandHistoryActions.css.map +1 -0
- package/dist/command-history/CommandHistoryActions.js +47 -0
- package/dist/command-history/CommandHistoryActions.js.map +1 -0
- package/dist/command-history/CommandHistoryItem.css +61 -0
- package/dist/command-history/CommandHistoryItem.css.map +1 -0
- package/dist/command-history/CommandHistoryItem.js +50 -0
- package/dist/command-history/CommandHistoryItem.js.map +1 -0
- package/dist/command-history/CommandHistoryItemTooltip.css +37 -0
- package/dist/command-history/CommandHistoryItemTooltip.css.map +1 -0
- package/dist/command-history/CommandHistoryItemTooltip.js +159 -0
- package/dist/command-history/CommandHistoryItemTooltip.js.map +1 -0
- package/dist/command-history/CommandHistoryStorage.js +2 -0
- package/dist/command-history/CommandHistoryStorage.js.map +1 -0
- package/dist/command-history/CommandHistoryTypes.js +2 -0
- package/dist/command-history/CommandHistoryTypes.js.map +1 -0
- package/dist/command-history/CommandHistoryViewportUpdater.js +57 -0
- package/dist/command-history/CommandHistoryViewportUpdater.js.map +1 -0
- package/dist/command-history/index.js +7 -0
- package/dist/command-history/index.js.map +1 -0
- package/dist/common/Code.js +45 -0
- package/dist/common/Code.js.map +1 -0
- package/dist/common/ConsoleConstants.js +10 -0
- package/dist/common/ConsoleConstants.js.map +1 -0
- package/dist/common/ConsoleUtils.js +62 -0
- package/dist/common/ConsoleUtils.js.map +1 -0
- package/dist/common/ObjectIcon.js +33 -0
- package/dist/common/ObjectIcon.js.map +1 -0
- package/dist/common/index.js +5 -0
- package/dist/common/index.js.map +1 -0
- package/dist/console-history/ConsoleHistory.css +42 -0
- package/dist/console-history/ConsoleHistory.css.map +1 -0
- package/dist/console-history/ConsoleHistory.js +42 -0
- package/dist/console-history/ConsoleHistory.js.map +1 -0
- package/dist/console-history/ConsoleHistoryItem.css +87 -0
- package/dist/console-history/ConsoleHistoryItem.css.map +1 -0
- package/dist/console-history/ConsoleHistoryItem.js +139 -0
- package/dist/console-history/ConsoleHistoryItem.js.map +1 -0
- package/dist/console-history/ConsoleHistoryItemResult.js +22 -0
- package/dist/console-history/ConsoleHistoryItemResult.js.map +1 -0
- package/dist/console-history/ConsoleHistoryResultErrorMessage.js +142 -0
- package/dist/console-history/ConsoleHistoryResultErrorMessage.js.map +1 -0
- package/dist/console-history/ConsoleHistoryResultInProgress.css +27 -0
- package/dist/console-history/ConsoleHistoryResultInProgress.css.map +1 -0
- package/dist/console-history/ConsoleHistoryResultInProgress.js +66 -0
- package/dist/console-history/ConsoleHistoryResultInProgress.js.map +1 -0
- package/dist/console-history/ConsoleHistoryTypes.js +2 -0
- package/dist/console-history/ConsoleHistoryTypes.js.map +1 -0
- package/dist/console-history/index.js +6 -0
- package/dist/console-history/index.js.map +1 -0
- package/dist/csv/CsvFormats.js +134 -0
- package/dist/csv/CsvFormats.js.map +1 -0
- package/dist/csv/CsvInputBar.css +36 -0
- package/dist/csv/CsvInputBar.css.map +1 -0
- package/dist/csv/CsvInputBar.js +342 -0
- package/dist/csv/CsvInputBar.js.map +1 -0
- package/dist/csv/CsvOverlay.css +57 -0
- package/dist/csv/CsvOverlay.css.map +1 -0
- package/dist/csv/CsvOverlay.js +244 -0
- package/dist/csv/CsvOverlay.js.map +1 -0
- package/dist/csv/CsvParser.js +268 -0
- package/dist/csv/CsvParser.js.map +1 -0
- package/dist/csv/CsvTypeParser.js +235 -0
- package/dist/csv/CsvTypeParser.js.map +1 -0
- package/dist/csv/NewTableColumnTypes.js +16 -0
- package/dist/csv/NewTableColumnTypes.js.map +1 -0
- package/dist/declaration.d.js +2 -0
- package/dist/declaration.d.js.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/log/LogLevel.js +11 -0
- package/dist/log/LogLevel.js.map +1 -0
- package/dist/log/LogLevelMenuItem.css +38 -0
- package/dist/log/LogLevelMenuItem.css.map +1 -0
- package/dist/log/LogLevelMenuItem.js +32 -0
- package/dist/log/LogLevelMenuItem.js.map +1 -0
- package/dist/log/LogView.css +65 -0
- package/dist/log/LogView.css.map +1 -0
- package/dist/log/LogView.js +487 -0
- package/dist/log/LogView.js.map +1 -0
- package/dist/monaco/MonacoProviders.js +314 -0
- package/dist/monaco/MonacoProviders.js.map +1 -0
- package/dist/monaco/MonacoTheme.module.css +54 -0
- package/dist/monaco/MonacoTheme.module.css.map +1 -0
- package/dist/monaco/MonacoUtils.js +423 -0
- package/dist/monaco/MonacoUtils.js.map +1 -0
- package/dist/monaco/index.js +4 -0
- package/dist/monaco/index.js.map +1 -0
- package/dist/monaco/lang/Language.js +2 -0
- package/dist/monaco/lang/Language.js.map +1 -0
- package/dist/monaco/lang/db.js +152 -0
- package/dist/monaco/lang/db.js.map +1 -0
- package/dist/monaco/lang/groovy.js +229 -0
- package/dist/monaco/lang/groovy.js.map +1 -0
- package/dist/monaco/lang/log.js +64 -0
- package/dist/monaco/lang/log.js.map +1 -0
- package/dist/monaco/lang/python.js +234 -0
- package/dist/monaco/lang/python.js.map +1 -0
- package/dist/monaco/lang/scala.js +264 -0
- package/dist/monaco/lang/scala.js.map +1 -0
- package/dist/notebook/Editor.css +6 -0
- package/dist/notebook/Editor.css.map +1 -0
- package/dist/notebook/Editor.js +130 -0
- package/dist/notebook/Editor.js.map +1 -0
- package/dist/notebook/ScriptEditor.css +8 -0
- package/dist/notebook/ScriptEditor.css.map +1 -0
- package/dist/notebook/ScriptEditor.d.ts.map +1 -1
- package/dist/notebook/ScriptEditor.js +311 -0
- package/dist/notebook/ScriptEditor.js.map +1 -0
- package/dist/notebook/ScriptEditorUtils.d.ts +7 -0
- package/dist/notebook/ScriptEditorUtils.d.ts.map +1 -1
- package/dist/notebook/ScriptEditorUtils.js +52 -0
- package/dist/notebook/ScriptEditorUtils.js.map +1 -0
- package/package.json +12 -12
package/dist/Console.js
ADDED
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
/**
|
|
7
|
+
* Console display for use in the Iris environment.
|
|
8
|
+
*/
|
|
9
|
+
import React, { PureComponent } from 'react';
|
|
10
|
+
import { ContextActions } from '@deephaven/components';
|
|
11
|
+
import { vsCheck } from '@deephaven/icons';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import memoize from 'memoize-one';
|
|
14
|
+
import throttle from 'lodash.throttle';
|
|
15
|
+
import Log from '@deephaven/log';
|
|
16
|
+
import { assertNotNull, Pending, PromiseUtils } from '@deephaven/utils';
|
|
17
|
+
import ConsoleHistory from "./console-history/ConsoleHistory.js";
|
|
18
|
+
import SHORTCUTS from "./ConsoleShortcuts.js";
|
|
19
|
+
import LogLevel from "./log/LogLevel.js";
|
|
20
|
+
import ConsoleInput from "./ConsoleInput.js";
|
|
21
|
+
import CsvOverlay from "./csv/CsvOverlay.js";
|
|
22
|
+
import CsvInputBar from "./csv/CsvInputBar.js";
|
|
23
|
+
import "./Console.css";
|
|
24
|
+
import ConsoleStatusBar from "./ConsoleStatusBar.js";
|
|
25
|
+
var log = Log.module('Console');
|
|
26
|
+
var DEFAULT_SETTINGS = {
|
|
27
|
+
isAutoLaunchPanelsEnabled: true,
|
|
28
|
+
isPrintStdOutEnabled: true,
|
|
29
|
+
isClosePanelsOnDisconnectEnabled: true
|
|
30
|
+
};
|
|
31
|
+
export class Console extends PureComponent {
|
|
32
|
+
/**
|
|
33
|
+
* Check if the provided log level is an error type
|
|
34
|
+
* @param logLevel The LogLevel being checked
|
|
35
|
+
* @returns true if the log level is an error level log
|
|
36
|
+
*/
|
|
37
|
+
static isErrorLevel(logLevel) {
|
|
38
|
+
return logLevel === LogLevel.STDERR || logLevel === LogLevel.ERROR || logLevel === LogLevel.FATAL;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Check if the provided log level is output level
|
|
43
|
+
* @param logLevel The LogLevel being checked
|
|
44
|
+
* @returns true if the log level should be output to the console
|
|
45
|
+
*/
|
|
46
|
+
static isOutputLevel(logLevel) {
|
|
47
|
+
// We want all errors to be output, in addition to STDOUT.
|
|
48
|
+
// That way the user is more likely to see them.
|
|
49
|
+
return logLevel === LogLevel.STDOUT || Console.isErrorLevel(logLevel);
|
|
50
|
+
}
|
|
51
|
+
constructor(props) {
|
|
52
|
+
super(props);
|
|
53
|
+
_defineProperty(this, "cancelListener", void 0);
|
|
54
|
+
_defineProperty(this, "consolePane", void 0);
|
|
55
|
+
_defineProperty(this, "consoleInput", void 0);
|
|
56
|
+
_defineProperty(this, "consoleHistoryScrollPane", void 0);
|
|
57
|
+
_defineProperty(this, "pending", void 0);
|
|
58
|
+
_defineProperty(this, "queuedLogMessages", void 0);
|
|
59
|
+
_defineProperty(this, "processLogMessageQueue", throttle(() => {
|
|
60
|
+
this.scrollConsoleHistoryToBottom();
|
|
61
|
+
this.setState(state => {
|
|
62
|
+
log.debug2('processLogMessageQueue', this.queuedLogMessages.length, ' items');
|
|
63
|
+
var {
|
|
64
|
+
consoleHistory
|
|
65
|
+
} = state;
|
|
66
|
+
consoleHistory = consoleHistory.concat(this.queuedLogMessages);
|
|
67
|
+
this.queuedLogMessages = [];
|
|
68
|
+
return {
|
|
69
|
+
consoleHistory
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}, Console.LOG_THROTTLE));
|
|
73
|
+
_defineProperty(this, "getObjects", memoize(objectMap => [...objectMap.values()]));
|
|
74
|
+
_defineProperty(this, "getContextActions", memoize(actions => [...actions, {
|
|
75
|
+
action: this.handleClearShortcut,
|
|
76
|
+
shortcut: SHORTCUTS.CONSOLE.CLEAR
|
|
77
|
+
}, {
|
|
78
|
+
action: this.handleFocusHistory,
|
|
79
|
+
shortcut: SHORTCUTS.CONSOLE.FOCUS_HISTORY
|
|
80
|
+
}]));
|
|
81
|
+
this.handleCommandResult = this.handleCommandResult.bind(this);
|
|
82
|
+
this.handleCommandStarted = this.handleCommandStarted.bind(this);
|
|
83
|
+
this.handleCommandSubmit = this.handleCommandSubmit.bind(this);
|
|
84
|
+
this.handleClearShortcut = this.handleClearShortcut.bind(this);
|
|
85
|
+
this.handleFocusHistory = this.handleFocusHistory.bind(this);
|
|
86
|
+
this.handleLogMessage = this.handleLogMessage.bind(this);
|
|
87
|
+
this.handleOverflowActions = this.handleOverflowActions.bind(this);
|
|
88
|
+
this.handleScrollPaneScroll = this.handleScrollPaneScroll.bind(this);
|
|
89
|
+
this.handleToggleAutoLaunchPanels = this.handleToggleAutoLaunchPanels.bind(this);
|
|
90
|
+
this.handleToggleClosePanelsOnDisconnect = this.handleToggleClosePanelsOnDisconnect.bind(this);
|
|
91
|
+
this.handleTogglePrintStdout = this.handleTogglePrintStdout.bind(this);
|
|
92
|
+
this.handleUploadCsv = this.handleUploadCsv.bind(this);
|
|
93
|
+
this.handleHideCsv = this.handleHideCsv.bind(this);
|
|
94
|
+
this.handleCsvFileCanceled = this.handleCsvFileCanceled.bind(this);
|
|
95
|
+
this.handleCsvFileOpened = this.handleCsvFileOpened.bind(this);
|
|
96
|
+
this.handleCsvPaste = this.handleCsvPaste.bind(this);
|
|
97
|
+
this.handleDragEnter = this.handleDragEnter.bind(this);
|
|
98
|
+
this.handleDragLeave = this.handleDragLeave.bind(this);
|
|
99
|
+
this.handleClearDragError = this.handleClearDragError.bind(this);
|
|
100
|
+
this.handleOpenCsvTable = this.handleOpenCsvTable.bind(this);
|
|
101
|
+
this.handleCsvUpdate = this.handleCsvUpdate.bind(this);
|
|
102
|
+
this.handleCsvError = this.handleCsvError.bind(this);
|
|
103
|
+
this.handleCsvInProgress = this.handleCsvInProgress.bind(this);
|
|
104
|
+
this.consolePane = /*#__PURE__*/React.createRef();
|
|
105
|
+
this.consoleInput = /*#__PURE__*/React.createRef();
|
|
106
|
+
this.consoleHistoryScrollPane = /*#__PURE__*/React.createRef();
|
|
107
|
+
this.pending = new Pending();
|
|
108
|
+
this.queuedLogMessages = [];
|
|
109
|
+
var {
|
|
110
|
+
objectMap: _objectMap,
|
|
111
|
+
settings
|
|
112
|
+
} = this.props;
|
|
113
|
+
this.state = _objectSpread(_objectSpread({
|
|
114
|
+
// Need separate histories as console history has stdout/stderr output
|
|
115
|
+
consoleHistory: [],
|
|
116
|
+
// Height of the viewport of the console input and history
|
|
117
|
+
consoleHeight: 0,
|
|
118
|
+
isScrollDecorationShown: false,
|
|
119
|
+
// Location of objects in the console history
|
|
120
|
+
objectHistoryMap: new Map(),
|
|
121
|
+
// The object definitions, name/type
|
|
122
|
+
objectMap: new Map(_objectMap),
|
|
123
|
+
showCsvOverlay: false,
|
|
124
|
+
csvFile: null,
|
|
125
|
+
csvPaste: null,
|
|
126
|
+
dragError: null,
|
|
127
|
+
csvUploadInProgress: false
|
|
128
|
+
}, DEFAULT_SETTINGS), settings);
|
|
129
|
+
}
|
|
130
|
+
componentDidMount() {
|
|
131
|
+
this.initConsoleLogging();
|
|
132
|
+
var {
|
|
133
|
+
dh,
|
|
134
|
+
session
|
|
135
|
+
} = this.props;
|
|
136
|
+
session.addEventListener(dh.IdeSession.EVENT_COMMANDSTARTED, this.handleCommandStarted);
|
|
137
|
+
this.updateDimensions();
|
|
138
|
+
}
|
|
139
|
+
componentDidUpdate(prevProps, prevState) {
|
|
140
|
+
var {
|
|
141
|
+
props,
|
|
142
|
+
state
|
|
143
|
+
} = this;
|
|
144
|
+
this.sendSettingsChange(prevState, state);
|
|
145
|
+
if (props.objectMap !== prevProps.objectMap) {
|
|
146
|
+
this.updateObjectMap();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
componentWillUnmount() {
|
|
150
|
+
var {
|
|
151
|
+
dh,
|
|
152
|
+
session
|
|
153
|
+
} = this.props;
|
|
154
|
+
session.removeEventListener(dh.IdeSession.EVENT_COMMANDSTARTED, this.handleCommandStarted);
|
|
155
|
+
this.pending.cancel();
|
|
156
|
+
this.processLogMessageQueue.cancel();
|
|
157
|
+
this.deinitConsoleLogging();
|
|
158
|
+
}
|
|
159
|
+
initConsoleLogging() {
|
|
160
|
+
var {
|
|
161
|
+
session
|
|
162
|
+
} = this.props;
|
|
163
|
+
this.cancelListener = session.onLogMessage(this.handleLogMessage);
|
|
164
|
+
}
|
|
165
|
+
deinitConsoleLogging() {
|
|
166
|
+
if (this.cancelListener != null) {
|
|
167
|
+
this.cancelListener();
|
|
168
|
+
this.cancelListener = undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
handleClearShortcut(event) {
|
|
172
|
+
var _this$consoleInput$cu;
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
event.stopPropagation();
|
|
175
|
+
(_this$consoleInput$cu = this.consoleInput.current) === null || _this$consoleInput$cu === void 0 ? void 0 : _this$consoleInput$cu.clear();
|
|
176
|
+
}
|
|
177
|
+
handleCommandStarted(event) {
|
|
178
|
+
var {
|
|
179
|
+
code,
|
|
180
|
+
result
|
|
181
|
+
} = event.detail;
|
|
182
|
+
var wrappedResult = this.pending.add(result);
|
|
183
|
+
var historyItem = {
|
|
184
|
+
command: code,
|
|
185
|
+
disabledObjects: [],
|
|
186
|
+
startTime: Date.now(),
|
|
187
|
+
cancelResult: () => {
|
|
188
|
+
result.cancel();
|
|
189
|
+
},
|
|
190
|
+
wrappedResult
|
|
191
|
+
};
|
|
192
|
+
var {
|
|
193
|
+
commandHistoryStorage,
|
|
194
|
+
language,
|
|
195
|
+
scope
|
|
196
|
+
} = this.props;
|
|
197
|
+
var workspaceItemPromise = commandHistoryStorage.addItem(language, scope, code, {
|
|
198
|
+
command: code,
|
|
199
|
+
startTime: new Date().toJSON()
|
|
200
|
+
});
|
|
201
|
+
workspaceItemPromise.catch(err => {
|
|
202
|
+
log.debug('Error adding workspace item', err);
|
|
203
|
+
});
|
|
204
|
+
this.setState(state => ({
|
|
205
|
+
consoleHistory: state.consoleHistory.concat(historyItem)
|
|
206
|
+
}), () => {
|
|
207
|
+
this.scrollConsoleHistoryToBottom(true);
|
|
208
|
+
});
|
|
209
|
+
wrappedResult.then(resolved => {
|
|
210
|
+
this.handleCommandResult(resolved, historyItem, workspaceItemPromise);
|
|
211
|
+
}).catch(error => {
|
|
212
|
+
this.handleCommandError(error, historyItem, workspaceItemPromise);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
handleCommandResult(result, historyItem, workspaceItemPromise) {
|
|
216
|
+
var newHistoryItem = _objectSpread(_objectSpread({}, historyItem), {}, {
|
|
217
|
+
wrappedResult: undefined,
|
|
218
|
+
cancelResult: undefined,
|
|
219
|
+
result: result !== null && result !== void 0 ? result : historyItem.result
|
|
220
|
+
});
|
|
221
|
+
this.setState(_ref => {
|
|
222
|
+
var {
|
|
223
|
+
consoleHistory
|
|
224
|
+
} = _ref;
|
|
225
|
+
var itemIndex = consoleHistory.lastIndexOf(historyItem);
|
|
226
|
+
if (itemIndex < 0) {
|
|
227
|
+
log.error("historyItem not found in consoleHistory");
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
var newHistory = consoleHistory.concat();
|
|
231
|
+
newHistory[itemIndex] = newHistoryItem;
|
|
232
|
+
return {
|
|
233
|
+
consoleHistory: newHistory
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
if (!result) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.updateHistory(result, newHistoryItem);
|
|
240
|
+
this.updateKnownObjects(newHistoryItem);
|
|
241
|
+
this.updateWorkspaceHistoryItem({
|
|
242
|
+
error: result.error
|
|
243
|
+
}, workspaceItemPromise);
|
|
244
|
+
this.closeRemovedItems(result.changes);
|
|
245
|
+
this.openUpdatedItems(result.changes);
|
|
246
|
+
}
|
|
247
|
+
handleCommandError(error, historyItem, workspaceItemPromise) {
|
|
248
|
+
if (PromiseUtils.isCanceled(error)) {
|
|
249
|
+
log.debug('Called handleCommandError on a cancelled promise result');
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.updateWorkspaceHistoryItem({
|
|
253
|
+
error: "".concat(error)
|
|
254
|
+
}, workspaceItemPromise);
|
|
255
|
+
this.setState(state => {
|
|
256
|
+
var history = state.consoleHistory.concat();
|
|
257
|
+
var index = history.lastIndexOf(historyItem);
|
|
258
|
+
var newHistoryItem = _objectSpread({}, historyItem);
|
|
259
|
+
newHistoryItem.wrappedResult = undefined;
|
|
260
|
+
newHistoryItem.cancelResult = undefined;
|
|
261
|
+
newHistoryItem.endTime = Date.now();
|
|
262
|
+
newHistoryItem.result = {
|
|
263
|
+
error
|
|
264
|
+
};
|
|
265
|
+
history[index] = newHistoryItem;
|
|
266
|
+
return {
|
|
267
|
+
consoleHistory: history
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
handleFocusHistory(event) {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
var {
|
|
275
|
+
focusCommandHistory
|
|
276
|
+
} = this.props;
|
|
277
|
+
focusCommandHistory();
|
|
278
|
+
}
|
|
279
|
+
handleLogMessage(message) {
|
|
280
|
+
var {
|
|
281
|
+
isPrintStdOutEnabled
|
|
282
|
+
} = this.state;
|
|
283
|
+
if (!isPrintStdOutEnabled) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (Console.isOutputLevel(message.logLevel)) {
|
|
287
|
+
this.queueLogMessage(message.message, message.logLevel);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
queueLogMessage(message, logLevel) {
|
|
291
|
+
var result = {};
|
|
292
|
+
if (Console.isErrorLevel(logLevel)) {
|
|
293
|
+
result.error = message;
|
|
294
|
+
} else {
|
|
295
|
+
result.message = message;
|
|
296
|
+
}
|
|
297
|
+
var historyItem = {
|
|
298
|
+
command: undefined,
|
|
299
|
+
result
|
|
300
|
+
};
|
|
301
|
+
this.queuedLogMessages.push(historyItem);
|
|
302
|
+
this.processLogMessageQueue();
|
|
303
|
+
}
|
|
304
|
+
openUpdatedItems(changes) {
|
|
305
|
+
var {
|
|
306
|
+
isAutoLaunchPanelsEnabled
|
|
307
|
+
} = this.state;
|
|
308
|
+
if (changes == null || !isAutoLaunchPanelsEnabled) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
var {
|
|
312
|
+
openObject
|
|
313
|
+
} = this.props;
|
|
314
|
+
[...changes.created, ...changes.updated].forEach(object => openObject(object));
|
|
315
|
+
}
|
|
316
|
+
closeRemovedItems(changes) {
|
|
317
|
+
if (changes == null || changes.removed == null || changes.removed.length === 0) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
var {
|
|
321
|
+
closeObject
|
|
322
|
+
} = this.props;
|
|
323
|
+
var {
|
|
324
|
+
removed
|
|
325
|
+
} = changes;
|
|
326
|
+
removed.forEach(object => closeObject(object));
|
|
327
|
+
}
|
|
328
|
+
updateHistory(result, historyItemParam) {
|
|
329
|
+
var historyItem = historyItemParam;
|
|
330
|
+
if (result == null || result.changes == null || historyItem == null) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
historyItem.endTime = Date.now();
|
|
334
|
+
this.scrollConsoleHistoryToBottom();
|
|
335
|
+
|
|
336
|
+
// Update history to re-render items as necessary
|
|
337
|
+
this.setState(state => {
|
|
338
|
+
var consoleHistory = state.consoleHistory.concat();
|
|
339
|
+
return {
|
|
340
|
+
consoleHistory
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
updateKnownObjects(historyItem) {
|
|
345
|
+
var changes;
|
|
346
|
+
if (historyItem.result) {
|
|
347
|
+
changes = historyItem.result.changes;
|
|
348
|
+
}
|
|
349
|
+
if (!changes || (changes.created == null || changes.created.length === 0) && (changes.updated == null || changes.updated.length === 0) && (changes.removed == null || changes.removed.length === 0)) {
|
|
350
|
+
log.debug2('updateKnownObjects no changes');
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.setState(state => {
|
|
354
|
+
var _changes, _changes2, _changes3;
|
|
355
|
+
var {
|
|
356
|
+
consoleHistory
|
|
357
|
+
} = state;
|
|
358
|
+
var itemIndex = consoleHistory.lastIndexOf(historyItem);
|
|
359
|
+
if (itemIndex < 0) {
|
|
360
|
+
log.error("historyItem not found in state.consoleHistory");
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
var objectHistoryMap = new Map(state.objectHistoryMap);
|
|
364
|
+
var objectMap = new Map(state.objectMap);
|
|
365
|
+
var disableOldObject = function disableOldObject(object) {
|
|
366
|
+
var isRemoved = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
367
|
+
var {
|
|
368
|
+
title
|
|
369
|
+
} = object;
|
|
370
|
+
assertNotNull(title);
|
|
371
|
+
var oldIndex = objectHistoryMap.get(title);
|
|
372
|
+
// oldIndex can be -1 if a object is active but doesn't have a command in consoleHistory
|
|
373
|
+
// this can happen after clearing the console using 'clear' or 'cls' command
|
|
374
|
+
|
|
375
|
+
if (oldIndex != null && oldIndex >= 0) {
|
|
376
|
+
var _consoleHistory$oldIn;
|
|
377
|
+
// disable outdated object variable in the old consoleHistory item
|
|
378
|
+
if (consoleHistory === state.consoleHistory) {
|
|
379
|
+
// First item in the history being updated,
|
|
380
|
+
consoleHistory = consoleHistory.concat();
|
|
381
|
+
}
|
|
382
|
+
var newHistoryItem = _objectSpread(_objectSpread({}, consoleHistory[oldIndex]), {}, {
|
|
383
|
+
disabledObjects: [...((_consoleHistory$oldIn = consoleHistory[oldIndex].disabledObjects) !== null && _consoleHistory$oldIn !== void 0 ? _consoleHistory$oldIn : []), title]
|
|
384
|
+
});
|
|
385
|
+
consoleHistory[oldIndex] = newHistoryItem;
|
|
386
|
+
}
|
|
387
|
+
objectHistoryMap.set(title, itemIndex);
|
|
388
|
+
if (isRemoved) {
|
|
389
|
+
objectMap.delete(title);
|
|
390
|
+
} else {
|
|
391
|
+
objectMap.set(title, object);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
(_changes = changes) === null || _changes === void 0 ? void 0 : _changes.updated.forEach(object => disableOldObject(object));
|
|
395
|
+
(_changes2 = changes) === null || _changes2 === void 0 ? void 0 : _changes2.removed.forEach(object => disableOldObject(object, true));
|
|
396
|
+
|
|
397
|
+
// Created objects have to be processed after removed
|
|
398
|
+
// in case the same object name is present in both removed and created
|
|
399
|
+
(_changes3 = changes) === null || _changes3 === void 0 ? void 0 : _changes3.created.forEach(object => {
|
|
400
|
+
var {
|
|
401
|
+
title
|
|
402
|
+
} = object;
|
|
403
|
+
assertNotNull(title);
|
|
404
|
+
objectHistoryMap.set(title, itemIndex);
|
|
405
|
+
objectMap.set(title, object);
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
objectHistoryMap,
|
|
409
|
+
objectMap,
|
|
410
|
+
consoleHistory
|
|
411
|
+
};
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
updateObjectMap() {
|
|
415
|
+
var {
|
|
416
|
+
objectMap
|
|
417
|
+
} = this.props;
|
|
418
|
+
this.setState({
|
|
419
|
+
objectMap
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Updates an existing workspace CommandHistoryItem
|
|
425
|
+
* @param result The result to store with the history item. Could be empty object for success
|
|
426
|
+
* @param workspaceItemPromise The workspace data row promise for the workspace item to be updated
|
|
427
|
+
*/
|
|
428
|
+
updateWorkspaceHistoryItem(result, workspaceItemPromise) {
|
|
429
|
+
var promise = this.pending.add(workspaceItemPromise);
|
|
430
|
+
var endTime = new Date().toJSON();
|
|
431
|
+
promise.then(workspaceItem => {
|
|
432
|
+
var updatedItem = _objectSpread(_objectSpread({}, workspaceItem), {}, {
|
|
433
|
+
data: _objectSpread(_objectSpread({}, workspaceItem.data), {}, {
|
|
434
|
+
endTime,
|
|
435
|
+
result
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
var {
|
|
439
|
+
commandHistoryStorage,
|
|
440
|
+
language
|
|
441
|
+
} = this.props;
|
|
442
|
+
commandHistoryStorage.updateItem(language, updatedItem).catch(err => {
|
|
443
|
+
log.warn('Error updating command history storage', err);
|
|
444
|
+
});
|
|
445
|
+
}).catch(err => {
|
|
446
|
+
log.debug('Error updating workspace history item', err);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
scrollConsoleHistoryToBottom() {
|
|
450
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
451
|
+
var pane = this.consoleHistoryScrollPane.current;
|
|
452
|
+
assertNotNull(pane);
|
|
453
|
+
if (!force && pane.scrollTop < pane.scrollHeight - pane.offsetHeight) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
window.requestAnimationFrame(() => {
|
|
457
|
+
pane.scrollTop = pane.scrollHeight;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
handleScrollPaneScroll() {
|
|
461
|
+
var scrollPane = this.consoleHistoryScrollPane.current;
|
|
462
|
+
assertNotNull(scrollPane);
|
|
463
|
+
if (scrollPane.scrollTop > 0 && scrollPane.scrollHeight > scrollPane.clientHeight) {
|
|
464
|
+
this.setState({
|
|
465
|
+
isScrollDecorationShown: true
|
|
466
|
+
});
|
|
467
|
+
} else {
|
|
468
|
+
this.setState({
|
|
469
|
+
isScrollDecorationShown: false
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
handleToggleAutoLaunchPanels() {
|
|
474
|
+
this.setState(state => ({
|
|
475
|
+
isAutoLaunchPanelsEnabled: !state.isAutoLaunchPanelsEnabled
|
|
476
|
+
}));
|
|
477
|
+
}
|
|
478
|
+
handleToggleClosePanelsOnDisconnect() {
|
|
479
|
+
this.setState(state => ({
|
|
480
|
+
isClosePanelsOnDisconnectEnabled: !state.isClosePanelsOnDisconnectEnabled
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
handleTogglePrintStdout() {
|
|
484
|
+
this.setState(state => ({
|
|
485
|
+
isPrintStdOutEnabled: !state.isPrintStdOutEnabled
|
|
486
|
+
}));
|
|
487
|
+
}
|
|
488
|
+
handleUploadCsv() {
|
|
489
|
+
this.setState({
|
|
490
|
+
showCsvOverlay: true,
|
|
491
|
+
dragError: null,
|
|
492
|
+
csvUploadInProgress: false
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
handleHideCsv() {
|
|
496
|
+
this.setState({
|
|
497
|
+
showCsvOverlay: false,
|
|
498
|
+
csvFile: null,
|
|
499
|
+
csvPaste: null,
|
|
500
|
+
dragError: null,
|
|
501
|
+
csvUploadInProgress: false
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
handleCsvFileCanceled() {
|
|
505
|
+
this.setState({
|
|
506
|
+
csvFile: null,
|
|
507
|
+
csvPaste: null
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
handleCsvFileOpened(file) {
|
|
511
|
+
this.setState({
|
|
512
|
+
csvFile: file,
|
|
513
|
+
csvPaste: null
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
handleCsvPaste(value) {
|
|
517
|
+
this.setState({
|
|
518
|
+
csvFile: null,
|
|
519
|
+
csvPaste: value
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
handleDragEnter(e) {
|
|
523
|
+
if (e.dataTransfer == null || e.dataTransfer.items == null || e.dataTransfer.items.length === 0 || e.dataTransfer.items[0].kind === 'string') {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
e.preventDefault();
|
|
527
|
+
e.stopPropagation();
|
|
528
|
+
this.setState({
|
|
529
|
+
showCsvOverlay: true
|
|
530
|
+
});
|
|
531
|
+
var {
|
|
532
|
+
items
|
|
533
|
+
} = e.dataTransfer;
|
|
534
|
+
if (items.length > 1) {
|
|
535
|
+
this.setState({
|
|
536
|
+
dragError: CsvOverlay.MULTIPLE_FILE_ERROR
|
|
537
|
+
});
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
var item = items[0];
|
|
541
|
+
if (CsvOverlay.isValidDropItem(item)) {
|
|
542
|
+
this.setState({
|
|
543
|
+
dragError: null
|
|
544
|
+
});
|
|
545
|
+
} else {
|
|
546
|
+
this.setState({
|
|
547
|
+
dragError: CsvOverlay.FILE_TYPE_ERROR
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
handleDragLeave(e) {
|
|
552
|
+
// DragLeave gets fired for every child element, so make sure we're actually leaving the drop zone
|
|
553
|
+
if (e.currentTarget == null || e.currentTarget instanceof Element && e.relatedTarget instanceof Element && e.currentTarget.contains(e.relatedTarget)) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
e.preventDefault();
|
|
557
|
+
e.stopPropagation();
|
|
558
|
+
this.setState({
|
|
559
|
+
showCsvOverlay: false,
|
|
560
|
+
dragError: null
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
handleClearDragError() {
|
|
564
|
+
this.setState({
|
|
565
|
+
dragError: null
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
handleOpenCsvTable(title) {
|
|
569
|
+
var {
|
|
570
|
+
dh,
|
|
571
|
+
openObject,
|
|
572
|
+
commandHistoryStorage,
|
|
573
|
+
language,
|
|
574
|
+
scope
|
|
575
|
+
} = this.props;
|
|
576
|
+
var {
|
|
577
|
+
consoleHistory,
|
|
578
|
+
objectMap
|
|
579
|
+
} = this.state;
|
|
580
|
+
var object = {
|
|
581
|
+
name: title,
|
|
582
|
+
title,
|
|
583
|
+
type: dh.VariableType.TABLE
|
|
584
|
+
};
|
|
585
|
+
var isExistingObject = objectMap.has(title);
|
|
586
|
+
var historyItem = {
|
|
587
|
+
startTime: Date.now(),
|
|
588
|
+
endTime: Date.now(),
|
|
589
|
+
disabledObjects: [],
|
|
590
|
+
result: {
|
|
591
|
+
changes: {
|
|
592
|
+
created: [],
|
|
593
|
+
updated: [],
|
|
594
|
+
removed: [],
|
|
595
|
+
[isExistingObject ? 'updated' : 'created']: [object]
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
var history = consoleHistory.concat(historyItem);
|
|
600
|
+
this.setState({
|
|
601
|
+
consoleHistory: history
|
|
602
|
+
});
|
|
603
|
+
this.scrollConsoleHistoryToBottom(true);
|
|
604
|
+
this.updateKnownObjects(historyItem);
|
|
605
|
+
openObject({
|
|
606
|
+
name: title,
|
|
607
|
+
title,
|
|
608
|
+
type: dh.VariableType.TABLE
|
|
609
|
+
});
|
|
610
|
+
commandHistoryStorage.addItem(language, scope, title, {
|
|
611
|
+
command: title,
|
|
612
|
+
startTime: new Date().toJSON(),
|
|
613
|
+
endTime: new Date().toJSON()
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
addConsoleHistoryMessage(message, error) {
|
|
617
|
+
var {
|
|
618
|
+
consoleHistory
|
|
619
|
+
} = this.state;
|
|
620
|
+
var historyItem = {
|
|
621
|
+
command: '',
|
|
622
|
+
startTime: Date.now(),
|
|
623
|
+
endTime: Date.now(),
|
|
624
|
+
result: {
|
|
625
|
+
message,
|
|
626
|
+
error
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var history = consoleHistory.concat(historyItem);
|
|
630
|
+
this.setState({
|
|
631
|
+
consoleHistory: history
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
handleCsvUpdate(message) {
|
|
635
|
+
this.addConsoleHistoryMessage(message);
|
|
636
|
+
}
|
|
637
|
+
handleCsvError(error) {
|
|
638
|
+
this.addConsoleHistoryMessage(undefined, error != null ? "".concat(error) : undefined);
|
|
639
|
+
}
|
|
640
|
+
handleCsvInProgress(csvUploadInProgress) {
|
|
641
|
+
this.setState({
|
|
642
|
+
csvUploadInProgress
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
handleOverflowActions() {
|
|
646
|
+
var {
|
|
647
|
+
isAutoLaunchPanelsEnabled,
|
|
648
|
+
isClosePanelsOnDisconnectEnabled,
|
|
649
|
+
isPrintStdOutEnabled
|
|
650
|
+
} = this.state;
|
|
651
|
+
var {
|
|
652
|
+
actions
|
|
653
|
+
} = this.props;
|
|
654
|
+
return [...actions, {
|
|
655
|
+
title: 'Print Stdout',
|
|
656
|
+
action: this.handleTogglePrintStdout,
|
|
657
|
+
group: ContextActions.groups.high,
|
|
658
|
+
icon: isPrintStdOutEnabled ? vsCheck : undefined,
|
|
659
|
+
order: 10
|
|
660
|
+
}, {
|
|
661
|
+
title: 'Auto Launch Panels',
|
|
662
|
+
action: this.handleToggleAutoLaunchPanels,
|
|
663
|
+
group: ContextActions.groups.high,
|
|
664
|
+
icon: isAutoLaunchPanelsEnabled ? vsCheck : undefined,
|
|
665
|
+
order: 20
|
|
666
|
+
}, {
|
|
667
|
+
title: 'Close Panels on Disconnect',
|
|
668
|
+
action: this.handleToggleClosePanelsOnDisconnect,
|
|
669
|
+
group: ContextActions.groups.high,
|
|
670
|
+
icon: isClosePanelsOnDisconnectEnabled ? vsCheck : undefined,
|
|
671
|
+
order: 30
|
|
672
|
+
}, {
|
|
673
|
+
title: 'Upload Table from File',
|
|
674
|
+
action: this.handleUploadCsv,
|
|
675
|
+
group: ContextActions.groups.high + 10,
|
|
676
|
+
order: 40
|
|
677
|
+
}];
|
|
678
|
+
}
|
|
679
|
+
handleCommandSubmit(command) {
|
|
680
|
+
if (command === 'clear' || command === 'cls') {
|
|
681
|
+
this.clearConsoleHistory();
|
|
682
|
+
} else if (command.length > 0) {
|
|
683
|
+
// Result is handled in this.handleCommandStarted
|
|
684
|
+
var {
|
|
685
|
+
session
|
|
686
|
+
} = this.props;
|
|
687
|
+
session.runCode(command).catch(error => {
|
|
688
|
+
log.error('There was an error initiating the command', error);
|
|
689
|
+
});
|
|
690
|
+
} else {
|
|
691
|
+
// Empty command, just pump a blank line out to history
|
|
692
|
+
var historyItem = {
|
|
693
|
+
command: ' ',
|
|
694
|
+
result: {},
|
|
695
|
+
startTime: Date.now(),
|
|
696
|
+
endTime: Date.now()
|
|
697
|
+
};
|
|
698
|
+
this.scrollConsoleHistoryToBottom(true);
|
|
699
|
+
this.setState(state => ({
|
|
700
|
+
consoleHistory: state.consoleHistory.concat(historyItem)
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
clearConsoleHistory() {
|
|
705
|
+
this.pending.cancel();
|
|
706
|
+
this.setState(state => {
|
|
707
|
+
// Replace all values with -1 to indicate that table references are still active
|
|
708
|
+
// but don't have corresponding command indexes in consoleHistory
|
|
709
|
+
var objectHistoryMap = new Map([...state.objectHistoryMap.keys()].map(name => [name, -1]));
|
|
710
|
+
return {
|
|
711
|
+
consoleHistory: [],
|
|
712
|
+
objectHistoryMap
|
|
713
|
+
};
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
addCommand(command) {
|
|
717
|
+
var focus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
718
|
+
var execute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
719
|
+
if (!this.consoleInput.current) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
this.consoleInput.current.setConsoleText(command, focus, execute);
|
|
723
|
+
if (focus) {
|
|
724
|
+
this.scrollConsoleHistoryToBottom(true);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
focus() {
|
|
728
|
+
var _this$consoleInput$cu2;
|
|
729
|
+
(_this$consoleInput$cu2 = this.consoleInput.current) === null || _this$consoleInput$cu2 === void 0 ? void 0 : _this$consoleInput$cu2.focus();
|
|
730
|
+
}
|
|
731
|
+
sendSettingsChange(prevState, state) {
|
|
732
|
+
var checkIfChanged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
733
|
+
var keys = Object.keys(DEFAULT_SETTINGS);
|
|
734
|
+
var settings = {};
|
|
735
|
+
var hasChanges = false;
|
|
736
|
+
for (var i = 0; i < keys.length; i += 1) {
|
|
737
|
+
var key = keys[i];
|
|
738
|
+
var {
|
|
739
|
+
[key]: setting
|
|
740
|
+
} = state;
|
|
741
|
+
var {
|
|
742
|
+
[key]: prevSetting
|
|
743
|
+
} = prevState;
|
|
744
|
+
if (setting !== prevSetting) {
|
|
745
|
+
hasChanges = true;
|
|
746
|
+
}
|
|
747
|
+
settings[key] = setting;
|
|
748
|
+
}
|
|
749
|
+
if (checkIfChanged && !hasChanges) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
var {
|
|
753
|
+
onSettingsChange
|
|
754
|
+
} = this.props;
|
|
755
|
+
onSettingsChange(settings);
|
|
756
|
+
}
|
|
757
|
+
updateDimensions() {
|
|
758
|
+
if (this.consolePane.current) {
|
|
759
|
+
this.setState({
|
|
760
|
+
consoleHeight: this.consolePane.current.clientHeight
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
if (this.consoleInput.current) {
|
|
764
|
+
this.consoleInput.current.updateDimensions();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
render() {
|
|
768
|
+
var {
|
|
769
|
+
actions,
|
|
770
|
+
dh,
|
|
771
|
+
historyChildren,
|
|
772
|
+
language,
|
|
773
|
+
statusBarChildren,
|
|
774
|
+
openObject,
|
|
775
|
+
session,
|
|
776
|
+
scope,
|
|
777
|
+
commandHistoryStorage,
|
|
778
|
+
timeZone,
|
|
779
|
+
disabled,
|
|
780
|
+
unzip
|
|
781
|
+
} = this.props;
|
|
782
|
+
var {
|
|
783
|
+
consoleHeight,
|
|
784
|
+
consoleHistory,
|
|
785
|
+
isScrollDecorationShown,
|
|
786
|
+
objectMap,
|
|
787
|
+
showCsvOverlay,
|
|
788
|
+
csvFile,
|
|
789
|
+
csvPaste,
|
|
790
|
+
dragError,
|
|
791
|
+
csvUploadInProgress
|
|
792
|
+
} = this.state;
|
|
793
|
+
var consoleMenuObjects = this.getObjects(objectMap);
|
|
794
|
+
var inputMaxHeight = Math.round(consoleHeight * 0.7);
|
|
795
|
+
var contextActions = this.getContextActions(actions);
|
|
796
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
797
|
+
role: "presentation",
|
|
798
|
+
className: classNames('iris-console', 'h-100', 'w-100', {
|
|
799
|
+
disabled
|
|
800
|
+
})
|
|
801
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
802
|
+
className: "console-pane",
|
|
803
|
+
ref: this.consolePane
|
|
804
|
+
}, /*#__PURE__*/React.createElement(ConsoleStatusBar, {
|
|
805
|
+
dh: dh,
|
|
806
|
+
session: session,
|
|
807
|
+
overflowActions: this.handleOverflowActions,
|
|
808
|
+
openObject: openObject,
|
|
809
|
+
objects: consoleMenuObjects
|
|
810
|
+
}, statusBarChildren), /*#__PURE__*/React.createElement("div", {
|
|
811
|
+
className: "console-csv-container",
|
|
812
|
+
onDragOver: CsvOverlay.handleDragOver,
|
|
813
|
+
onDragEnter: this.handleDragEnter,
|
|
814
|
+
onDragLeave: this.handleDragLeave
|
|
815
|
+
}, showCsvOverlay && /*#__PURE__*/React.createElement(CsvOverlay, {
|
|
816
|
+
onCancel: this.handleCsvFileCanceled,
|
|
817
|
+
onFileOpened: this.handleCsvFileOpened,
|
|
818
|
+
onPaste: this.handleCsvPaste,
|
|
819
|
+
clearDragError: this.handleClearDragError,
|
|
820
|
+
dragError: dragError,
|
|
821
|
+
onError: this.handleCsvError,
|
|
822
|
+
uploadInProgress: csvUploadInProgress,
|
|
823
|
+
allowZip: unzip != null
|
|
824
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
825
|
+
role: "presentation",
|
|
826
|
+
className: classNames('scroll-pane no-scroll-x', {
|
|
827
|
+
'scroll-decoration': isScrollDecorationShown
|
|
828
|
+
}),
|
|
829
|
+
onScroll: this.handleScrollPaneScroll,
|
|
830
|
+
ref: this.consoleHistoryScrollPane
|
|
831
|
+
}, /*#__PURE__*/React.createElement(ConsoleHistory, {
|
|
832
|
+
items: consoleHistory,
|
|
833
|
+
openObject: openObject,
|
|
834
|
+
language: language,
|
|
835
|
+
disabled: disabled
|
|
836
|
+
}), historyChildren)), !showCsvOverlay && /*#__PURE__*/React.createElement(ConsoleInput, {
|
|
837
|
+
ref: this.consoleInput,
|
|
838
|
+
session: session,
|
|
839
|
+
language: language,
|
|
840
|
+
scope: scope,
|
|
841
|
+
onSubmit: this.handleCommandSubmit,
|
|
842
|
+
maxHeight: inputMaxHeight,
|
|
843
|
+
commandHistoryStorage: commandHistoryStorage
|
|
844
|
+
}), showCsvOverlay && /*#__PURE__*/React.createElement(CsvInputBar, {
|
|
845
|
+
session: session,
|
|
846
|
+
onOpenTable: this.handleOpenCsvTable,
|
|
847
|
+
onClose: this.handleHideCsv,
|
|
848
|
+
onUpdate: this.handleCsvUpdate,
|
|
849
|
+
onError: this.handleCsvError,
|
|
850
|
+
file: csvFile !== null && csvFile !== void 0 ? csvFile : undefined,
|
|
851
|
+
paste: csvPaste !== null && csvPaste !== void 0 ? csvPaste : undefined,
|
|
852
|
+
onInProgress: this.handleCsvInProgress,
|
|
853
|
+
timeZone: timeZone,
|
|
854
|
+
unzip: unzip
|
|
855
|
+
})), /*#__PURE__*/React.createElement(ContextActions, {
|
|
856
|
+
actions: contextActions,
|
|
857
|
+
ignoreClassNames: [ConsoleInput.INPUT_CLASS_NAME]
|
|
858
|
+
}));
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
_defineProperty(Console, "defaultProps", {
|
|
862
|
+
statusBarChildren: null,
|
|
863
|
+
settings: {},
|
|
864
|
+
onSettingsChange: () => undefined,
|
|
865
|
+
scope: null,
|
|
866
|
+
actions: [],
|
|
867
|
+
historyChildren: null,
|
|
868
|
+
timeZone: 'America/New_York',
|
|
869
|
+
objectMap: new Map(),
|
|
870
|
+
disabled: false,
|
|
871
|
+
unzip: null
|
|
872
|
+
});
|
|
873
|
+
_defineProperty(Console, "LOG_THROTTLE", 500);
|
|
874
|
+
export default Console;
|
|
875
|
+
//# sourceMappingURL=Console.js.map
|