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