@mongodb-js/compass-shell 3.4.0 → 3.5.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/README.md +2 -43
- package/dist/281.index.js +1919 -0
- package/dist/281.index.js.LICENSE.txt +12 -0
- package/dist/766.browser.js +1919 -0
- package/dist/766.browser.js.LICENSE.txt +12 -0
- package/dist/945.browser.js +12 -0
- package/dist/996.index.js +12 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.LICENSE.txt +71 -0
- package/dist/index.html +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +71 -0
- package/package.json +74 -106
- package/.babelrc.js +0 -24
- package/.browserslistrc +0 -1
- package/.depcheckrc +0 -25
- package/AUTHORS +0 -9
- package/lib/1.js +0 -55967
- package/lib/2.js +0 -512
- package/lib/index.html +0 -9
- package/lib/index.js +0 -66070
package/lib/2.js
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
(window["webpackJsonpCompassShellPlugin"] = window["webpackJsonpCompassShellPlugin"] || []).push([[2],{
|
|
2
|
-
|
|
3
|
-
/***/ 474:
|
|
4
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
// ESM COMPAT FLAG
|
|
8
|
-
__webpack_require__.r(__webpack_exports__);
|
|
9
|
-
|
|
10
|
-
// EXPORTS
|
|
11
|
-
__webpack_require__.d(__webpack_exports__, "CompassShell", function() { return /* reexport */ compass_shell_CompassShell; });
|
|
12
|
-
|
|
13
|
-
// EXTERNAL MODULE: external "react"
|
|
14
|
-
var external_react_ = __webpack_require__(2);
|
|
15
|
-
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
16
|
-
|
|
17
|
-
// EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/prop-types/index.js
|
|
18
|
-
var prop_types = __webpack_require__(245);
|
|
19
|
-
var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
|
|
20
|
-
|
|
21
|
-
// EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/react-redux/es/index.js + 26 modules
|
|
22
|
-
var es = __webpack_require__(128);
|
|
23
|
-
|
|
24
|
-
// EXTERNAL MODULE: external "compass-preferences-model"
|
|
25
|
-
var external_compass_preferences_model_ = __webpack_require__(243);
|
|
26
|
-
|
|
27
|
-
// EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/@mongosh/browser-repl/lib/mongosh-browser-repl.js
|
|
28
|
-
var mongosh_browser_repl = __webpack_require__(282);
|
|
29
|
-
|
|
30
|
-
// EXTERNAL MODULE: external "@mongodb-js/compass-components"
|
|
31
|
-
var compass_components_ = __webpack_require__(242);
|
|
32
|
-
|
|
33
|
-
// CONCATENATED MODULE: ./src/components/shell-info-modal/keyboard-shortcuts-table.jsx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const rowStyles = Object(compass_components_["css"])({
|
|
37
|
-
td: {
|
|
38
|
-
padding: 0
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const hotkeys = [{
|
|
42
|
-
key: 'Ctrl+`',
|
|
43
|
-
description: 'Toggle shell.'
|
|
44
|
-
}, {
|
|
45
|
-
key: 'Ctrl+A',
|
|
46
|
-
description: 'Moves the cursor to the beginning of the line.'
|
|
47
|
-
}, {
|
|
48
|
-
key: 'Ctrl+B',
|
|
49
|
-
description: 'Moves the cursor Backward one character.'
|
|
50
|
-
}, {
|
|
51
|
-
key: 'Ctrl+C',
|
|
52
|
-
description: 'Stop currently running command.'
|
|
53
|
-
}, {
|
|
54
|
-
key: 'Ctrl+D',
|
|
55
|
-
description: 'Deletes the next character.'
|
|
56
|
-
}, {
|
|
57
|
-
key: 'Ctrl+E',
|
|
58
|
-
description: 'Moves the cursor to the end of the line.'
|
|
59
|
-
}, {
|
|
60
|
-
key: 'Ctrl+F',
|
|
61
|
-
description: 'Moves the cursor Forward one character.'
|
|
62
|
-
}, {
|
|
63
|
-
key: 'Ctrl+H',
|
|
64
|
-
description: 'Erases one character, similar to hitting backspace.'
|
|
65
|
-
}, {
|
|
66
|
-
key: 'Ctrl/Cmd+L',
|
|
67
|
-
description: 'Clears the screen, similar to the clear command.'
|
|
68
|
-
}, {
|
|
69
|
-
key: 'Ctrl+T',
|
|
70
|
-
description: 'Swap the last two characters before the cursor.'
|
|
71
|
-
}, {
|
|
72
|
-
key: 'Ctrl+U',
|
|
73
|
-
description: 'Changes the line to Uppercase.'
|
|
74
|
-
}, {
|
|
75
|
-
key: '\u2191',
|
|
76
|
-
description: 'Cycle backwards through command history.'
|
|
77
|
-
}, {
|
|
78
|
-
key: '\u2193',
|
|
79
|
-
description: 'Cycle forwards through command history.'
|
|
80
|
-
}];
|
|
81
|
-
function KeyboardShortcutsTable() {
|
|
82
|
-
return /*#__PURE__*/external_react_default.a.createElement(compass_components_["Table"], {
|
|
83
|
-
data: hotkeys,
|
|
84
|
-
columns: [/*#__PURE__*/external_react_default.a.createElement(compass_components_["TableHeader"], {
|
|
85
|
-
key: 'name',
|
|
86
|
-
label: "Key"
|
|
87
|
-
}), /*#__PURE__*/external_react_default.a.createElement(compass_components_["TableHeader"], {
|
|
88
|
-
key: 'value',
|
|
89
|
-
label: "Description"
|
|
90
|
-
})]
|
|
91
|
-
}, ({
|
|
92
|
-
datum
|
|
93
|
-
}) => /*#__PURE__*/external_react_default.a.createElement(compass_components_["Row"], {
|
|
94
|
-
className: rowStyles,
|
|
95
|
-
key: datum.key
|
|
96
|
-
}, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Cell"], null, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Body"], {
|
|
97
|
-
weight: "medium"
|
|
98
|
-
}, datum.key)), /*#__PURE__*/external_react_default.a.createElement(compass_components_["Cell"], null, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Description"], null, datum.description))));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// CONCATENATED MODULE: ./src/components/shell-info-modal/shell-info-modal.jsx
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const mongoshVersion = `v${__webpack_require__(470).version}`;
|
|
107
|
-
const shortcutsTableContainerStyles = Object(compass_components_["css"])({
|
|
108
|
-
marginTop: compass_components_["spacing"][2],
|
|
109
|
-
maxHeight: '50vh',
|
|
110
|
-
overflow: 'auto'
|
|
111
|
-
});
|
|
112
|
-
const shortcutsTitleStyles = Object(compass_components_["css"])({
|
|
113
|
-
marginTop: compass_components_["spacing"][4]
|
|
114
|
-
});
|
|
115
|
-
function ShellInfoModal({
|
|
116
|
-
hideInfoModal,
|
|
117
|
-
show
|
|
118
|
-
}) {
|
|
119
|
-
const onClose = Object(external_react_["useCallback"])(() => {
|
|
120
|
-
hideInfoModal();
|
|
121
|
-
}, [hideInfoModal]);
|
|
122
|
-
return /*#__PURE__*/external_react_default.a.createElement(compass_components_["InfoModal"], {
|
|
123
|
-
open: show,
|
|
124
|
-
title: `mongosh ${mongoshVersion}`,
|
|
125
|
-
trackingId: "shell_info_modal",
|
|
126
|
-
"data-testid": "shell-info-modal",
|
|
127
|
-
onClose: onClose
|
|
128
|
-
}, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Banner"], null, "For more information please visit the\xA0", /*#__PURE__*/external_react_default.a.createElement(compass_components_["Link"], {
|
|
129
|
-
id: "mongosh-info-link",
|
|
130
|
-
href: "https://docs.mongodb.com/compass/beta/embedded-shell/",
|
|
131
|
-
target: "_blank"
|
|
132
|
-
}, "MongoDB Shell Documentation"), "."), /*#__PURE__*/external_react_default.a.createElement(compass_components_["Subtitle"], {
|
|
133
|
-
className: shortcutsTitleStyles
|
|
134
|
-
}, "Keyboard Shortcuts"), /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
135
|
-
className: shortcutsTableContainerStyles
|
|
136
|
-
}, /*#__PURE__*/external_react_default.a.createElement(KeyboardShortcutsTable, null)));
|
|
137
|
-
}
|
|
138
|
-
ShellInfoModal.propTypes = {
|
|
139
|
-
hideInfoModal: prop_types_default.a.func.isRequired,
|
|
140
|
-
show: prop_types_default.a.bool.isRequired
|
|
141
|
-
};
|
|
142
|
-
/* harmony default export */ var shell_info_modal = (ShellInfoModal);
|
|
143
|
-
// CONCATENATED MODULE: ./src/components/shell-info-modal/index.js
|
|
144
|
-
|
|
145
|
-
/* harmony default export */ var components_shell_info_modal = (shell_info_modal);
|
|
146
|
-
// CONCATENATED MODULE: ./src/components/shell-header/shell-header.jsx
|
|
147
|
-
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; }
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const shellHeaderStyles = Object(compass_components_["css"])({
|
|
153
|
-
height: compass_components_["spacing"][5],
|
|
154
|
-
display: 'flex',
|
|
155
|
-
color: compass_components_["palette"].gray.light1
|
|
156
|
-
});
|
|
157
|
-
const shellHeaderLeftStyles = Object(compass_components_["css"])({
|
|
158
|
-
flexGrow: 1,
|
|
159
|
-
display: 'flex',
|
|
160
|
-
alignItems: 'center'
|
|
161
|
-
});
|
|
162
|
-
const shellHeaderDefaultColor = compass_components_["palette"].gray.light1;
|
|
163
|
-
const shellHeaderFlashColorDark = compass_components_["palette"].gray.base;
|
|
164
|
-
const shellHeaderFlashColorLight = compass_components_["palette"].gray.light2;
|
|
165
|
-
const shellLoaderFlash = compass_components_["keyframes"]`
|
|
166
|
-
0% { color: ${shellHeaderDefaultColor}; }
|
|
167
|
-
10% { color: ${shellHeaderFlashColorDark}; }
|
|
168
|
-
20% { color: ${shellHeaderFlashColorLight}; }
|
|
169
|
-
30% { color: ${shellHeaderFlashColorDark}; }
|
|
170
|
-
40% { color: ${shellHeaderFlashColorLight}; }
|
|
171
|
-
50% { color: ${shellHeaderFlashColorDark}; }
|
|
172
|
-
60% { color: ${shellHeaderFlashColorLight}; }
|
|
173
|
-
70% { color: ${shellHeaderFlashColorDark}; }
|
|
174
|
-
80% { color: ${shellHeaderFlashColorLight}; }
|
|
175
|
-
100% { color: ${shellHeaderDefaultColor}; }
|
|
176
|
-
`;
|
|
177
|
-
const shellHeaderToggleStyles = Object(compass_components_["css"])({
|
|
178
|
-
background: 'none',
|
|
179
|
-
border: 'none',
|
|
180
|
-
cursor: 'pointer',
|
|
181
|
-
color: shellHeaderDefaultColor,
|
|
182
|
-
padding: `0px ${compass_components_["spacing"][2]}px`,
|
|
183
|
-
height: '100%',
|
|
184
|
-
display: 'flex',
|
|
185
|
-
verticalAlign: 'middle',
|
|
186
|
-
flexDirection: 'row',
|
|
187
|
-
alignItems: 'center',
|
|
188
|
-
margin: 'auto 0',
|
|
189
|
-
fontWeight: 'bold',
|
|
190
|
-
fontSize: compass_components_["spacing"][2] * 1.5,
|
|
191
|
-
lineHeight: `${compass_components_["spacing"][5]}px`,
|
|
192
|
-
transition: 'all 200ms',
|
|
193
|
-
userSelect: 'none',
|
|
194
|
-
textTransform: 'uppercase',
|
|
195
|
-
animation: `${shellLoaderFlash} 2s linear`,
|
|
196
|
-
'&:hover': {
|
|
197
|
-
color: compass_components_["palette"].gray.light3
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
const shellHeaderRightStyles = Object(compass_components_["css"])({
|
|
201
|
-
display: 'flex',
|
|
202
|
-
paddingTop: compass_components_["spacing"][1] / 2,
|
|
203
|
-
paddingRight: compass_components_["spacing"][2]
|
|
204
|
-
});
|
|
205
|
-
const infoButtonStyles = Object(compass_components_["css"])({
|
|
206
|
-
marginRight: compass_components_["spacing"][2]
|
|
207
|
-
});
|
|
208
|
-
const operationInProgressStyles = Object(compass_components_["css"])({
|
|
209
|
-
color: compass_components_["palette"].green.light2,
|
|
210
|
-
marginLeft: compass_components_["spacing"][2]
|
|
211
|
-
});
|
|
212
|
-
class shell_header_ShellHeader extends external_react_["Component"] {
|
|
213
|
-
componentDidMount() {
|
|
214
|
-
document.addEventListener('keydown', this.handleKeyboardToggle.bind(this));
|
|
215
|
-
}
|
|
216
|
-
componentWillUnmount() {
|
|
217
|
-
document.removeEventListener('keydown', this.handleKeyboardToggle.bind(this));
|
|
218
|
-
}
|
|
219
|
-
handleKeyboardToggle({
|
|
220
|
-
ctrlKey,
|
|
221
|
-
key
|
|
222
|
-
}) {
|
|
223
|
-
if (ctrlKey && key === '`') {
|
|
224
|
-
this.props.onShellToggleClicked();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Render ShellHeader component.
|
|
230
|
-
*
|
|
231
|
-
* @returns {React.Component} The rendered component.
|
|
232
|
-
*/
|
|
233
|
-
render() {
|
|
234
|
-
const {
|
|
235
|
-
isExpanded,
|
|
236
|
-
isOperationInProgress,
|
|
237
|
-
onShellToggleClicked,
|
|
238
|
-
showInfoModal
|
|
239
|
-
} = this.props;
|
|
240
|
-
return /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
241
|
-
className: shellHeaderStyles
|
|
242
|
-
}, /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
243
|
-
className: shellHeaderLeftStyles
|
|
244
|
-
}, /*#__PURE__*/external_react_default.a.createElement("button", {
|
|
245
|
-
type: "button",
|
|
246
|
-
"data-testid": "shell-expand-button",
|
|
247
|
-
className: shellHeaderToggleStyles,
|
|
248
|
-
"aria-label": isExpanded ? 'Close Shell' : 'Open Shell',
|
|
249
|
-
onClick: onShellToggleClicked,
|
|
250
|
-
"aria-pressed": isExpanded
|
|
251
|
-
}, ">_MONGOSH", !isExpanded && isOperationInProgress && /*#__PURE__*/external_react_default.a.createElement("span", {
|
|
252
|
-
className: operationInProgressStyles
|
|
253
|
-
}, /*#__PURE__*/external_react_default.a.createElement(mongosh_browser_repl["ShellLoader"], {
|
|
254
|
-
size: "12px"
|
|
255
|
-
}), "\xA0Command in progress\u2026"))), /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
256
|
-
className: shellHeaderRightStyles
|
|
257
|
-
}, isExpanded && /*#__PURE__*/external_react_default.a.createElement(compass_components_["IconButton"], {
|
|
258
|
-
"data-testid": "shell-info-button",
|
|
259
|
-
className: infoButtonStyles,
|
|
260
|
-
variant: "dark",
|
|
261
|
-
"aria-label": "Shell Info",
|
|
262
|
-
"aria-haspopup": "dialog",
|
|
263
|
-
onClick: showInfoModal
|
|
264
|
-
}, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Icon"], {
|
|
265
|
-
glyph: "InfoWithCircle",
|
|
266
|
-
size: "small"
|
|
267
|
-
})), /*#__PURE__*/external_react_default.a.createElement(compass_components_["IconButton"], {
|
|
268
|
-
variant: "dark",
|
|
269
|
-
"aria-label": isExpanded ? 'Close Shell' : 'Open Shell',
|
|
270
|
-
onClick: onShellToggleClicked,
|
|
271
|
-
"aria-pressed": isExpanded
|
|
272
|
-
}, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Icon"], {
|
|
273
|
-
glyph: isExpanded ? 'ChevronDown' : 'ChevronUp',
|
|
274
|
-
size: "small"
|
|
275
|
-
}))));
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
_defineProperty(shell_header_ShellHeader, "propTypes", {
|
|
279
|
-
isExpanded: prop_types_default.a.bool.isRequired,
|
|
280
|
-
isOperationInProgress: prop_types_default.a.bool.isRequired,
|
|
281
|
-
onShellToggleClicked: prop_types_default.a.func.isRequired,
|
|
282
|
-
showInfoModal: prop_types_default.a.func.isRequired
|
|
283
|
-
});
|
|
284
|
-
/* harmony default export */ var shell_header = (shell_header_ShellHeader);
|
|
285
|
-
// CONCATENATED MODULE: ./src/components/shell-header/index.js
|
|
286
|
-
|
|
287
|
-
/* harmony default export */ var components_shell_header = (shell_header);
|
|
288
|
-
|
|
289
|
-
// CONCATENATED MODULE: ./src/components/compass-shell/compass-shell.jsx
|
|
290
|
-
function compass_shell_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; }
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const compassShellStyles = Object(compass_components_["css"])({
|
|
300
|
-
backgroundColor: compass_components_["palette"].gray.dark3,
|
|
301
|
-
display: 'flex',
|
|
302
|
-
flexBasis: 'auto',
|
|
303
|
-
position: 'relative',
|
|
304
|
-
flexDirection: 'column'
|
|
305
|
-
});
|
|
306
|
-
const compassShellContainerStyles = Object(compass_components_["css"])({
|
|
307
|
-
flexGrow: 1,
|
|
308
|
-
display: 'none',
|
|
309
|
-
overflow: 'auto',
|
|
310
|
-
borderTop: `1px solid ${compass_components_["palette"].gray.dark2}`,
|
|
311
|
-
'*::-webkit-scrollbar-thumb': {
|
|
312
|
-
background: Object(compass_components_["rgba"])(compass_components_["palette"].gray.light1, 0.5)
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
const compassShellContainerVisibleStyles = Object(compass_components_["css"])({
|
|
316
|
-
display: 'flex'
|
|
317
|
-
});
|
|
318
|
-
const defaultShellHeightOpened = 240;
|
|
319
|
-
const shellHeightClosed = 32;
|
|
320
|
-
const shellMinHeightOpened = 100;
|
|
321
|
-
function getMaxShellHeight() {
|
|
322
|
-
return Math.max(defaultShellHeightOpened, window.innerHeight - 100);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Apply bounds to the shell height when resizing to ensure it's always
|
|
326
|
-
// visible and usable to the user.
|
|
327
|
-
function boundShellHeight(attemptedHeight) {
|
|
328
|
-
const maxHeight = getMaxShellHeight();
|
|
329
|
-
return Math.min(maxHeight, Math.max(shellMinHeightOpened, attemptedHeight));
|
|
330
|
-
}
|
|
331
|
-
class compass_shell_CompassShell extends external_react_["Component"] {
|
|
332
|
-
constructor(props) {
|
|
333
|
-
super(props);
|
|
334
|
-
compass_shell_defineProperty(this, "onShellOutputChanged", output => {
|
|
335
|
-
this.shellOutput = output;
|
|
336
|
-
});
|
|
337
|
-
compass_shell_defineProperty(this, "onOperationStarted", () => {
|
|
338
|
-
this.setState({
|
|
339
|
-
isOperationInProgress: true
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
compass_shell_defineProperty(this, "onOperationEnd", () => {
|
|
343
|
-
this.setState({
|
|
344
|
-
isOperationInProgress: false
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
compass_shell_defineProperty(this, "terminateRuntime", () => {
|
|
348
|
-
if (this.props.runtime) {
|
|
349
|
-
this.props.runtime.terminate();
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
compass_shell_defineProperty(this, "saveHistory", async history => {
|
|
353
|
-
if (!this.props.historyStorage) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
try {
|
|
357
|
-
await this.props.historyStorage.save(history);
|
|
358
|
-
} catch (error) {
|
|
359
|
-
// eslint-disable-next-line no-console
|
|
360
|
-
console.error(error);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
compass_shell_defineProperty(this, "loadHistory", async () => {
|
|
364
|
-
if (!this.props.historyStorage) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
try {
|
|
368
|
-
const history = await this.props.historyStorage.load();
|
|
369
|
-
this.setState({
|
|
370
|
-
initialHistory: history
|
|
371
|
-
});
|
|
372
|
-
} catch (error) {
|
|
373
|
-
// eslint-disable-next-line no-console
|
|
374
|
-
console.error(error);
|
|
375
|
-
this.setState({
|
|
376
|
-
initialHistory: []
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
this.shellRef = /*#__PURE__*/external_react_default.a.createRef();
|
|
381
|
-
this.shellOutput = this.props.shellOutput || [];
|
|
382
|
-
this.state = {
|
|
383
|
-
height: shellHeightClosed,
|
|
384
|
-
prevHeight: defaultShellHeightOpened,
|
|
385
|
-
initialHistory: this.props.historyStorage ? null : [],
|
|
386
|
-
isOperationInProgress: false,
|
|
387
|
-
showInfoModal: false
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
componentDidMount() {
|
|
391
|
-
this.loadHistory();
|
|
392
|
-
window.addEventListener('beforeunload', this.terminateRuntime);
|
|
393
|
-
}
|
|
394
|
-
componentDidUpdate(prevProps, prevState) {
|
|
395
|
-
const {
|
|
396
|
-
height
|
|
397
|
-
} = this.state;
|
|
398
|
-
if (prevState.height < shellMinHeightOpened && height > shellMinHeightOpened) {
|
|
399
|
-
this.props.emitShellPluginOpened();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
componentWillUnmount() {
|
|
403
|
-
window.removeEventListener('beforeunload', this.terminateRuntime);
|
|
404
|
-
}
|
|
405
|
-
updateHeight(height) {
|
|
406
|
-
this.setState(height > shellMinHeightOpened ? {
|
|
407
|
-
height,
|
|
408
|
-
// Store the previous height to use when toggling open/close
|
|
409
|
-
// when we resize while the shell is expanded.
|
|
410
|
-
prevHeight: height
|
|
411
|
-
} : {
|
|
412
|
-
height
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
hideInfoModal() {
|
|
416
|
-
this.setState({
|
|
417
|
-
showInfoModal: false
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
focusEditor() {
|
|
421
|
-
var _window$getSelection;
|
|
422
|
-
if (this.shellRef.current && ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) !== 'Range') {
|
|
423
|
-
this.shellRef.current.focusEditor();
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Render CompassShell component.
|
|
429
|
-
*
|
|
430
|
-
* @returns {React.Component} The rendered component.
|
|
431
|
-
*/
|
|
432
|
-
render() {
|
|
433
|
-
const {
|
|
434
|
-
height,
|
|
435
|
-
prevHeight,
|
|
436
|
-
isOperationInProgress,
|
|
437
|
-
showInfoModal
|
|
438
|
-
} = this.state;
|
|
439
|
-
if (!this.props.enableShell || !this.props.runtime || !this.state.initialHistory) {
|
|
440
|
-
return /*#__PURE__*/external_react_default.a.createElement("div", null);
|
|
441
|
-
}
|
|
442
|
-
const isExpanded = height > shellMinHeightOpened;
|
|
443
|
-
const renderedHeight = isExpanded ? boundShellHeight(height) : shellHeightClosed;
|
|
444
|
-
return /*#__PURE__*/external_react_default.a.createElement(external_react_["Fragment"], null, /*#__PURE__*/external_react_default.a.createElement(components_shell_info_modal, {
|
|
445
|
-
show: showInfoModal,
|
|
446
|
-
hideInfoModal: this.hideInfoModal.bind(this)
|
|
447
|
-
}), /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
448
|
-
"data-testid": "shell-section",
|
|
449
|
-
className: compassShellStyles,
|
|
450
|
-
style: {
|
|
451
|
-
height: renderedHeight
|
|
452
|
-
},
|
|
453
|
-
id: "content",
|
|
454
|
-
onClick: this.focusEditor.bind(this)
|
|
455
|
-
}, /*#__PURE__*/external_react_default.a.createElement(compass_components_["ResizeHandle"], {
|
|
456
|
-
direction: compass_components_["ResizeDirection"].TOP,
|
|
457
|
-
onChange: newHeight => this.updateHeight(newHeight),
|
|
458
|
-
value: height,
|
|
459
|
-
minValue: shellHeightClosed,
|
|
460
|
-
maxValue: getMaxShellHeight(),
|
|
461
|
-
title: "MongoDB Shell"
|
|
462
|
-
}), /*#__PURE__*/external_react_default.a.createElement(components_shell_header, {
|
|
463
|
-
isExpanded: isExpanded,
|
|
464
|
-
onShellToggleClicked: () => isExpanded ? this.updateHeight(shellHeightClosed) : this.updateHeight(prevHeight),
|
|
465
|
-
isOperationInProgress: isOperationInProgress,
|
|
466
|
-
showInfoModal: () => this.setState({
|
|
467
|
-
showInfoModal: true
|
|
468
|
-
})
|
|
469
|
-
}), /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
470
|
-
"data-testid": "shell-content",
|
|
471
|
-
className: Object(compass_components_["cx"])(compassShellContainerStyles, {
|
|
472
|
-
[compassShellContainerVisibleStyles]: isExpanded
|
|
473
|
-
})
|
|
474
|
-
}, /*#__PURE__*/external_react_default.a.createElement(mongosh_browser_repl["Shell"], {
|
|
475
|
-
ref: this.shellRef,
|
|
476
|
-
runtime: this.props.runtime,
|
|
477
|
-
initialHistory: this.state.initialHistory,
|
|
478
|
-
initialOutput: this.shellOutput,
|
|
479
|
-
onHistoryChanged: this.saveHistory,
|
|
480
|
-
onOutputChanged: this.onShellOutputChanged,
|
|
481
|
-
onOperationStarted: this.onOperationStarted,
|
|
482
|
-
onOperationEnd: this.onOperationEnd
|
|
483
|
-
}))));
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
compass_shell_defineProperty(compass_shell_CompassShell, "propTypes", {
|
|
487
|
-
emitShellPluginOpened: prop_types_default.a.func,
|
|
488
|
-
runtime: prop_types_default.a.object,
|
|
489
|
-
shellOutput: prop_types_default.a.array,
|
|
490
|
-
historyStorage: prop_types_default.a.object,
|
|
491
|
-
enableShell: prop_types_default.a.bool
|
|
492
|
-
});
|
|
493
|
-
compass_shell_defineProperty(compass_shell_CompassShell, "defaultProps", {
|
|
494
|
-
emitShellPluginOpened: () => {},
|
|
495
|
-
runtime: null
|
|
496
|
-
});
|
|
497
|
-
/* harmony default export */ var compass_shell = (Object(es["b" /* connect */])(state => ({
|
|
498
|
-
emitShellPluginOpened: () => {
|
|
499
|
-
if (state.appRegistry && state.appRegistry.globalAppRegistry) {
|
|
500
|
-
state.appRegistry.globalAppRegistry.emit('compass:compass-shell:opened');
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
runtime: state.runtime ? state.runtime.runtime : null
|
|
504
|
-
}))(Object(external_compass_preferences_model_["withPreferences"])(compass_shell_CompassShell, ['enableShell'], external_react_default.a)));
|
|
505
|
-
// CONCATENATED MODULE: ./src/components/compass-shell/index.js
|
|
506
|
-
|
|
507
|
-
/* harmony default export */ var components_compass_shell = __webpack_exports__["default"] = (compass_shell);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/***/ })
|
|
511
|
-
|
|
512
|
-
}]);
|