@mongodb-js/compass-shell 3.2.0 → 3.4.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.
Files changed (4) hide show
  1. package/lib/1.js +7556 -10177
  2. package/lib/2.js +44 -90
  3. package/lib/index.js +261 -297
  4. package/package.json +13 -12
package/lib/2.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (window["webpackJsonpCompassShellPlugin"] = window["webpackJsonpCompassShellPlugin"] || []).push([[2],{
2
2
 
3
- /***/ 480:
3
+ /***/ 474:
4
4
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5
5
 
6
6
  "use strict";
@@ -15,19 +15,22 @@ var external_react_ = __webpack_require__(2);
15
15
  var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
16
16
 
17
17
  // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/prop-types/index.js
18
- var prop_types = __webpack_require__(244);
18
+ var prop_types = __webpack_require__(245);
19
19
  var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
20
20
 
21
21
  // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/react-redux/es/index.js + 26 modules
22
22
  var es = __webpack_require__(128);
23
23
 
24
+ // EXTERNAL MODULE: external "compass-preferences-model"
25
+ var external_compass_preferences_model_ = __webpack_require__(243);
26
+
24
27
  // EXTERNAL MODULE: /home/runner/work/compass/compass/node_modules/@mongosh/browser-repl/lib/mongosh-browser-repl.js
25
- var mongosh_browser_repl = __webpack_require__(285);
28
+ var mongosh_browser_repl = __webpack_require__(282);
26
29
 
27
30
  // EXTERNAL MODULE: external "@mongodb-js/compass-components"
28
31
  var compass_components_ = __webpack_require__(242);
29
32
 
30
- // CONCATENATED MODULE: ./src/components/info-modal/keyboard-shortcuts-table.jsx
33
+ // CONCATENATED MODULE: ./src/components/shell-info-modal/keyboard-shortcuts-table.jsx
31
34
 
32
35
 
33
36
  const rowStyles = Object(compass_components_["css"])({
@@ -75,7 +78,6 @@ const hotkeys = [{
75
78
  key: '\u2193',
76
79
  description: 'Cycle forwards through command history.'
77
80
  }];
78
-
79
81
  function KeyboardShortcutsTable() {
80
82
  return /*#__PURE__*/external_react_default.a.createElement(compass_components_["Table"], {
81
83
  data: hotkeys,
@@ -96,16 +98,12 @@ function KeyboardShortcutsTable() {
96
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))));
97
99
  }
98
100
 
101
+ // CONCATENATED MODULE: ./src/components/shell-info-modal/shell-info-modal.jsx
99
102
 
100
- // CONCATENATED MODULE: ./src/components/info-modal/info-modal.jsx
101
103
 
102
104
 
103
105
 
104
-
105
- const mongoshVersion = `v${__webpack_require__(476).version}`;
106
- const modalContentWrapperStyles = Object(compass_components_["css"])({
107
- padding: 'initial'
108
- });
106
+ const mongoshVersion = `v${__webpack_require__(470).version}`;
109
107
  const shortcutsTableContainerStyles = Object(compass_components_["css"])({
110
108
  marginTop: compass_components_["spacing"][2],
111
109
  maxHeight: '50vh',
@@ -114,30 +112,20 @@ const shortcutsTableContainerStyles = Object(compass_components_["css"])({
114
112
  const shortcutsTitleStyles = Object(compass_components_["css"])({
115
113
  marginTop: compass_components_["spacing"][4]
116
114
  });
117
- const modalContentStyles = Object(compass_components_["css"])({
118
- padding: compass_components_["spacing"][5]
119
- });
120
- /**
121
- * Show information on how to use the shell in compass.
122
- */
123
-
124
- function InfoModal({
115
+ function ShellInfoModal({
125
116
  hideInfoModal,
126
117
  show
127
118
  }) {
128
- const onSetOpen = Object(external_react_["useCallback"])(open => {
129
- if (!open) {
130
- hideInfoModal();
131
- }
119
+ const onClose = Object(external_react_["useCallback"])(() => {
120
+ hideInfoModal();
132
121
  }, [hideInfoModal]);
133
- return /*#__PURE__*/external_react_default.a.createElement(compass_components_["Modal"], {
122
+ return /*#__PURE__*/external_react_default.a.createElement(compass_components_["InfoModal"], {
134
123
  open: show,
124
+ title: `mongosh ${mongoshVersion}`,
135
125
  trackingId: "shell_info_modal",
136
- setOpen: onSetOpen,
137
- contentClassName: modalContentWrapperStyles
138
- }, /*#__PURE__*/external_react_default.a.createElement("div", {
139
- className: modalContentStyles
140
- }, /*#__PURE__*/external_react_default.a.createElement(compass_components_["ModalTitle"], null, "mongosh ", mongoshVersion), /*#__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"], {
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"], {
141
129
  id: "mongosh-info-link",
142
130
  href: "https://docs.mongodb.com/compass/beta/embedded-shell/",
143
131
  target: "_blank"
@@ -145,39 +133,35 @@ function InfoModal({
145
133
  className: shortcutsTitleStyles
146
134
  }, "Keyboard Shortcuts"), /*#__PURE__*/external_react_default.a.createElement("div", {
147
135
  className: shortcutsTableContainerStyles
148
- }, /*#__PURE__*/external_react_default.a.createElement(KeyboardShortcutsTable, null))), /*#__PURE__*/external_react_default.a.createElement(compass_components_["ModalFooter"], null, /*#__PURE__*/external_react_default.a.createElement(compass_components_["Button"], {
149
- onClick: hideInfoModal
150
- }, "Close")));
136
+ }, /*#__PURE__*/external_react_default.a.createElement(KeyboardShortcutsTable, null)));
151
137
  }
152
-
153
- InfoModal.propTypes = {
138
+ ShellInfoModal.propTypes = {
154
139
  hideInfoModal: prop_types_default.a.func.isRequired,
155
140
  show: prop_types_default.a.bool.isRequired
156
141
  };
157
- /* harmony default export */ var info_modal = (InfoModal);
158
- // CONCATENATED MODULE: ./src/components/info-modal/index.js
142
+ /* harmony default export */ var shell_info_modal = (ShellInfoModal);
143
+ // CONCATENATED MODULE: ./src/components/shell-info-modal/index.js
159
144
 
160
- /* harmony default export */ var components_info_modal = (info_modal);
145
+ /* harmony default export */ var components_shell_info_modal = (shell_info_modal);
161
146
  // CONCATENATED MODULE: ./src/components/shell-header/shell-header.jsx
162
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; }
163
148
 
164
149
 
165
150
 
166
151
 
167
-
168
152
  const shellHeaderStyles = Object(compass_components_["css"])({
169
153
  height: compass_components_["spacing"][5],
170
154
  display: 'flex',
171
- color: compass_components_["uiColors"].gray.light1
155
+ color: compass_components_["palette"].gray.light1
172
156
  });
173
157
  const shellHeaderLeftStyles = Object(compass_components_["css"])({
174
158
  flexGrow: 1,
175
159
  display: 'flex',
176
160
  alignItems: 'center'
177
161
  });
178
- const shellHeaderDefaultColor = compass_components_["uiColors"].gray.light1;
179
- const shellHeaderFlashColorDark = compass_components_["uiColors"].gray.base;
180
- const shellHeaderFlashColorLight = compass_components_["uiColors"].gray.light2;
162
+ const shellHeaderDefaultColor = compass_components_["palette"].gray.light1;
163
+ const shellHeaderFlashColorDark = compass_components_["palette"].gray.base;
164
+ const shellHeaderFlashColorLight = compass_components_["palette"].gray.light2;
181
165
  const shellLoaderFlash = compass_components_["keyframes"]`
182
166
  0% { color: ${shellHeaderDefaultColor}; }
183
167
  10% { color: ${shellHeaderFlashColorDark}; }
@@ -210,7 +194,7 @@ const shellHeaderToggleStyles = Object(compass_components_["css"])({
210
194
  textTransform: 'uppercase',
211
195
  animation: `${shellLoaderFlash} 2s linear`,
212
196
  '&:hover': {
213
- color: compass_components_["uiColors"].gray.light3
197
+ color: compass_components_["palette"].gray.light3
214
198
  }
215
199
  });
216
200
  const shellHeaderRightStyles = Object(compass_components_["css"])({
@@ -222,18 +206,16 @@ const infoButtonStyles = Object(compass_components_["css"])({
222
206
  marginRight: compass_components_["spacing"][2]
223
207
  });
224
208
  const operationInProgressStyles = Object(compass_components_["css"])({
225
- color: compass_components_["uiColors"].green.light2,
209
+ color: compass_components_["palette"].green.light2,
226
210
  marginLeft: compass_components_["spacing"][2]
227
211
  });
228
212
  class shell_header_ShellHeader extends external_react_["Component"] {
229
213
  componentDidMount() {
230
214
  document.addEventListener('keydown', this.handleKeyboardToggle.bind(this));
231
215
  }
232
-
233
216
  componentWillUnmount() {
234
217
  document.removeEventListener('keydown', this.handleKeyboardToggle.bind(this));
235
218
  }
236
-
237
219
  handleKeyboardToggle({
238
220
  ctrlKey,
239
221
  key
@@ -242,13 +224,12 @@ class shell_header_ShellHeader extends external_react_["Component"] {
242
224
  this.props.onShellToggleClicked();
243
225
  }
244
226
  }
227
+
245
228
  /**
246
229
  * Render ShellHeader component.
247
230
  *
248
231
  * @returns {React.Component} The rendered component.
249
232
  */
250
-
251
-
252
233
  render() {
253
234
  const {
254
235
  isExpanded,
@@ -261,6 +242,7 @@ class shell_header_ShellHeader extends external_react_["Component"] {
261
242
  }, /*#__PURE__*/external_react_default.a.createElement("div", {
262
243
  className: shellHeaderLeftStyles
263
244
  }, /*#__PURE__*/external_react_default.a.createElement("button", {
245
+ type: "button",
264
246
  "data-testid": "shell-expand-button",
265
247
  className: shellHeaderToggleStyles,
266
248
  "aria-label": isExpanded ? 'Close Shell' : 'Open Shell',
@@ -273,6 +255,7 @@ class shell_header_ShellHeader extends external_react_["Component"] {
273
255
  }), "\xA0Command in progress\u2026"))), /*#__PURE__*/external_react_default.a.createElement("div", {
274
256
  className: shellHeaderRightStyles
275
257
  }, isExpanded && /*#__PURE__*/external_react_default.a.createElement(compass_components_["IconButton"], {
258
+ "data-testid": "shell-info-button",
276
259
  className: infoButtonStyles,
277
260
  variant: "dark",
278
261
  "aria-label": "Shell Info",
@@ -291,16 +274,13 @@ class shell_header_ShellHeader extends external_react_["Component"] {
291
274
  size: "small"
292
275
  }))));
293
276
  }
294
-
295
277
  }
296
-
297
278
  _defineProperty(shell_header_ShellHeader, "propTypes", {
298
279
  isExpanded: prop_types_default.a.bool.isRequired,
299
280
  isOperationInProgress: prop_types_default.a.bool.isRequired,
300
281
  onShellToggleClicked: prop_types_default.a.func.isRequired,
301
282
  showInfoModal: prop_types_default.a.func.isRequired
302
283
  });
303
-
304
284
  /* harmony default export */ var shell_header = (shell_header_ShellHeader);
305
285
  // CONCATENATED MODULE: ./src/components/shell-header/index.js
306
286
 
@@ -317,20 +297,19 @@ function compass_shell_defineProperty(obj, key, value) { if (key in obj) { Objec
317
297
 
318
298
 
319
299
  const compassShellStyles = Object(compass_components_["css"])({
320
- backgroundColor: compass_components_["uiColors"].gray.dark3,
300
+ backgroundColor: compass_components_["palette"].gray.dark3,
321
301
  display: 'flex',
322
302
  flexBasis: 'auto',
323
303
  position: 'relative',
324
- flexDirection: 'column',
325
- maxHeight: '95%'
304
+ flexDirection: 'column'
326
305
  });
327
306
  const compassShellContainerStyles = Object(compass_components_["css"])({
328
307
  flexGrow: 1,
329
308
  display: 'none',
330
309
  overflow: 'auto',
331
- borderTop: `1px solid ${compass_components_["uiColors"].gray.dark2}`,
310
+ borderTop: `1px solid ${compass_components_["palette"].gray.dark2}`,
332
311
  '*::-webkit-scrollbar-thumb': {
333
- background: 'rgba(180, 180, 180, 0.5)'
312
+ background: Object(compass_components_["rgba"])(compass_components_["palette"].gray.light1, 0.5)
334
313
  }
335
314
  });
336
315
  const compassShellContainerVisibleStyles = Object(compass_components_["css"])({
@@ -339,49 +318,41 @@ const compassShellContainerVisibleStyles = Object(compass_components_["css"])({
339
318
  const defaultShellHeightOpened = 240;
340
319
  const shellHeightClosed = 32;
341
320
  const shellMinHeightOpened = 100;
342
-
343
321
  function getMaxShellHeight() {
344
322
  return Math.max(defaultShellHeightOpened, window.innerHeight - 100);
345
- } // Apply bounds to the shell height when resizing to ensure it's always
346
- // visible and usable to the user.
347
-
323
+ }
348
324
 
325
+ // Apply bounds to the shell height when resizing to ensure it's always
326
+ // visible and usable to the user.
349
327
  function boundShellHeight(attemptedHeight) {
350
328
  const maxHeight = getMaxShellHeight();
351
329
  return Math.min(maxHeight, Math.max(shellMinHeightOpened, attemptedHeight));
352
330
  }
353
-
354
331
  class compass_shell_CompassShell extends external_react_["Component"] {
355
332
  constructor(props) {
356
333
  super(props);
357
-
358
334
  compass_shell_defineProperty(this, "onShellOutputChanged", output => {
359
335
  this.shellOutput = output;
360
336
  });
361
-
362
337
  compass_shell_defineProperty(this, "onOperationStarted", () => {
363
338
  this.setState({
364
339
  isOperationInProgress: true
365
340
  });
366
341
  });
367
-
368
342
  compass_shell_defineProperty(this, "onOperationEnd", () => {
369
343
  this.setState({
370
344
  isOperationInProgress: false
371
345
  });
372
346
  });
373
-
374
347
  compass_shell_defineProperty(this, "terminateRuntime", () => {
375
348
  if (this.props.runtime) {
376
349
  this.props.runtime.terminate();
377
350
  }
378
351
  });
379
-
380
352
  compass_shell_defineProperty(this, "saveHistory", async history => {
381
353
  if (!this.props.historyStorage) {
382
354
  return;
383
355
  }
384
-
385
356
  try {
386
357
  await this.props.historyStorage.save(history);
387
358
  } catch (error) {
@@ -389,12 +360,10 @@ class compass_shell_CompassShell extends external_react_["Component"] {
389
360
  console.error(error);
390
361
  }
391
362
  });
392
-
393
363
  compass_shell_defineProperty(this, "loadHistory", async () => {
394
364
  if (!this.props.historyStorage) {
395
365
  return;
396
366
  }
397
-
398
367
  try {
399
368
  const history = await this.props.historyStorage.load();
400
369
  this.setState({
@@ -408,7 +377,6 @@ class compass_shell_CompassShell extends external_react_["Component"] {
408
377
  });
409
378
  }
410
379
  });
411
-
412
380
  this.shellRef = /*#__PURE__*/external_react_default.a.createRef();
413
381
  this.shellOutput = this.props.shellOutput || [];
414
382
  this.state = {
@@ -419,26 +387,21 @@ class compass_shell_CompassShell extends external_react_["Component"] {
419
387
  showInfoModal: false
420
388
  };
421
389
  }
422
-
423
390
  componentDidMount() {
424
391
  this.loadHistory();
425
392
  window.addEventListener('beforeunload', this.terminateRuntime);
426
393
  }
427
-
428
394
  componentDidUpdate(prevProps, prevState) {
429
395
  const {
430
396
  height
431
397
  } = this.state;
432
-
433
398
  if (prevState.height < shellMinHeightOpened && height > shellMinHeightOpened) {
434
399
  this.props.emitShellPluginOpened();
435
400
  }
436
401
  }
437
-
438
402
  componentWillUnmount() {
439
403
  window.removeEventListener('beforeunload', this.terminateRuntime);
440
404
  }
441
-
442
405
  updateHeight(height) {
443
406
  this.setState(height > shellMinHeightOpened ? {
444
407
  height,
@@ -449,27 +412,23 @@ class compass_shell_CompassShell extends external_react_["Component"] {
449
412
  height
450
413
  });
451
414
  }
452
-
453
415
  hideInfoModal() {
454
416
  this.setState({
455
417
  showInfoModal: false
456
418
  });
457
419
  }
458
-
459
420
  focusEditor() {
460
421
  var _window$getSelection;
461
-
462
422
  if (this.shellRef.current && ((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) !== 'Range') {
463
423
  this.shellRef.current.focusEditor();
464
424
  }
465
425
  }
426
+
466
427
  /**
467
428
  * Render CompassShell component.
468
429
  *
469
430
  * @returns {React.Component} The rendered component.
470
431
  */
471
-
472
-
473
432
  render() {
474
433
  const {
475
434
  height,
@@ -477,14 +436,12 @@ class compass_shell_CompassShell extends external_react_["Component"] {
477
436
  isOperationInProgress,
478
437
  showInfoModal
479
438
  } = this.state;
480
-
481
- if (!this.props.runtime || !this.state.initialHistory) {
439
+ if (!this.props.enableShell || !this.props.runtime || !this.state.initialHistory) {
482
440
  return /*#__PURE__*/external_react_default.a.createElement("div", null);
483
441
  }
484
-
485
442
  const isExpanded = height > shellMinHeightOpened;
486
443
  const renderedHeight = isExpanded ? boundShellHeight(height) : shellHeightClosed;
487
- return /*#__PURE__*/external_react_default.a.createElement(external_react_["Fragment"], null, /*#__PURE__*/external_react_default.a.createElement(components_info_modal, {
444
+ return /*#__PURE__*/external_react_default.a.createElement(external_react_["Fragment"], null, /*#__PURE__*/external_react_default.a.createElement(components_shell_info_modal, {
488
445
  show: showInfoModal,
489
446
  hideInfoModal: this.hideInfoModal.bind(this)
490
447
  }), /*#__PURE__*/external_react_default.a.createElement("div", {
@@ -525,21 +482,18 @@ class compass_shell_CompassShell extends external_react_["Component"] {
525
482
  onOperationEnd: this.onOperationEnd
526
483
  }))));
527
484
  }
528
-
529
485
  }
530
-
531
486
  compass_shell_defineProperty(compass_shell_CompassShell, "propTypes", {
532
487
  emitShellPluginOpened: prop_types_default.a.func,
533
488
  runtime: prop_types_default.a.object,
534
489
  shellOutput: prop_types_default.a.array,
535
- historyStorage: prop_types_default.a.object
490
+ historyStorage: prop_types_default.a.object,
491
+ enableShell: prop_types_default.a.bool
536
492
  });
537
-
538
493
  compass_shell_defineProperty(compass_shell_CompassShell, "defaultProps", {
539
494
  emitShellPluginOpened: () => {},
540
495
  runtime: null
541
496
  });
542
-
543
497
  /* harmony default export */ var compass_shell = (Object(es["b" /* connect */])(state => ({
544
498
  emitShellPluginOpened: () => {
545
499
  if (state.appRegistry && state.appRegistry.globalAppRegistry) {
@@ -547,7 +501,7 @@ compass_shell_defineProperty(compass_shell_CompassShell, "defaultProps", {
547
501
  }
548
502
  },
549
503
  runtime: state.runtime ? state.runtime.runtime : null
550
- }))(compass_shell_CompassShell));
504
+ }))(Object(external_compass_preferences_model_["withPreferences"])(compass_shell_CompassShell, ['enableShell'], external_react_default.a)));
551
505
  // CONCATENATED MODULE: ./src/components/compass-shell/index.js
552
506
 
553
507
  /* harmony default export */ var components_compass_shell = __webpack_exports__["default"] = (compass_shell);