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