@mongodb-js/compass-shell 3.10.0 → 3.11.1
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/508.index.js +1 -12
- package/dist/716.browser.js +1 -12
- package/dist/766.browser.js +11 -11
- package/dist/766.index.js +6 -6
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +24 -24
package/dist/508.index.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
(global.webpackChunkCompassShellPlugin=global.webpackChunkCompassShellPlugin||[]).push([[508],{49945:(e,t,o)=>{"use strict";o.r(t),o.d(t,{CompassShell:()=>
|
|
2
|
-
0% { color: ${S}; }
|
|
3
|
-
10% { color: ${E}; }
|
|
4
|
-
20% { color: ${w}; }
|
|
5
|
-
30% { color: ${E}; }
|
|
6
|
-
40% { color: ${w}; }
|
|
7
|
-
50% { color: ${E}; }
|
|
8
|
-
60% { color: ${w}; }
|
|
9
|
-
70% { color: ${E}; }
|
|
10
|
-
80% { color: ${w}; }
|
|
11
|
-
100% { color: ${S}; }
|
|
12
|
-
`,v=(0,c.css)({background:"none",border:"none",cursor:"pointer",color:S,padding:`0px ${c.spacing[2]}px`,height:"100%",display:"flex",verticalAlign:"middle",flexDirection:"row",alignItems:"center",margin:"auto 0",fontWeight:"bold",fontSize:1.5*c.spacing[2],lineHeight:`${c.spacing[5]}px`,transition:"all 200ms",userSelect:"none",textTransform:"uppercase",animation:`${C} 2s linear`,"&:hover":{color:c.palette.gray.light3}}),O=(0,c.css)({display:"flex",paddingTop:c.spacing[1]/2,paddingRight:c.spacing[2]}),x=(0,c.css)({marginRight:c.spacing[2]}),M=(0,c.css)({color:c.palette.green.light2,marginLeft:c.spacing[2]}),I=({darkMode:e,isExpanded:t,isOperationInProgress:o,onShellToggleClicked:i,showInfoModal:r})=>((0,c.useHotkeys)("ctrl + `",i),n().createElement("div",{className:(0,c.cx)(f,e&&k)},n().createElement("div",{className:b},n().createElement("button",{type:"button","data-testid":"shell-expand-button",className:v,"aria-label":t?"Close Shell":"Open Shell",onClick:i,"aria-pressed":t},">_MONGOSH",!t&&o&&n().createElement("span",{className:M},n().createElement(c.SpinLoader,{darkMode:!0})," Command in progress…"))),n().createElement("div",{className:O},t&&n().createElement(c.IconButton,{"data-testid":"shell-info-button",className:x,variant:"dark","aria-label":"Shell Info","aria-haspopup":"dialog",onClick:r},n().createElement(c.Icon,{glyph:"InfoWithCircle",size:"small"})),n().createElement(c.IconButton,{variant:"dark","aria-label":t?"Close Shell":"Open Shell",onClick:i,"aria-pressed":t},n().createElement(c.Icon,{glyph:t?"ChevronDown":"ChevronUp",size:"small"})))));I.propTypes={darkMode:s().bool,isExpanded:s().bool.isRequired,isOperationInProgress:s().bool.isRequired,onShellToggleClicked:s().func.isRequired,showInfoModal:s().func.isRequired};const H=(0,c.withDarkMode)(I),{Shell:R}=o(72519),T=(0,c.css)({backgroundColor:c.palette.gray.dark4,display:"flex",flexBasis:"auto",position:"relative",flexDirection:"column",width:"100vw"},(0,c.getScrollbarStyles)(!0)),D=(0,c.css)({flexGrow:1,display:"none",overflow:"auto",borderTop:`1px solid ${c.palette.gray.dark2}`}),$=(0,c.css)({display:"flex"}),P=100;function N(){return Math.max(240,window.innerHeight-100)}class U extends i.Component{static propTypes={emitShellPluginOpened:s().func,runtime:s().object,shellOutput:s().array,historyStorage:s().object,enableShell:s().bool};static defaultProps={emitShellPluginOpened:()=>{},runtime:null};constructor(e){super(e),this.shellRef=n().createRef(),this.shellOutput=this.props.shellOutput||[],this.state={height:32,prevHeight:240,initialHistory:this.props.historyStorage?null:[],isOperationInProgress:!1,showInfoModal:!1}}componentDidMount(){this.loadHistory(),window.addEventListener("beforeunload",this.terminateRuntime)}componentDidUpdate(e,t){const{height:o}=this.state;t.height<P&&o>P&&this.props.emitShellPluginOpened()}componentWillUnmount(){window.removeEventListener("beforeunload",this.terminateRuntime)}onShellOutputChanged=e=>{this.shellOutput=e};onOperationStarted=()=>{this.setState({isOperationInProgress:!0})};onOperationEnd=()=>{this.setState({isOperationInProgress:!1})};terminateRuntime=()=>{this.props.runtime&&this.props.runtime.terminate()};saveHistory=async e=>{if(this.props.historyStorage)try{await this.props.historyStorage.save(e)}catch(e){console.error(e)}};loadHistory=async()=>{if(this.props.historyStorage)try{const e=await this.props.historyStorage.load();this.setState({initialHistory:e})}catch(e){console.error(e),this.setState({initialHistory:[]})}};updateHeight(e){this.setState(e>P?{height:e,prevHeight:e}:{height:e})}hideInfoModal(){this.setState({showInfoModal:!1})}focusEditor(){this.shellRef.current&&"Range"!==window.getSelection()?.type&&this.shellRef.current.focusEditor()}render(){const{height:e,prevHeight:t,isOperationInProgress:o,showInfoModal:r}=this.state;if(!this.props.enableShell||!this.props.runtime||!this.state.initialHistory)return n().createElement("div",null);const s=e>P,a=s?function(e){const t=N();return Math.min(t,Math.max(P,e))}(e):32;return n().createElement(i.Fragment,null,n().createElement(y,{show:r,hideInfoModal:this.hideInfoModal.bind(this)}),n().createElement("div",{"data-testid":"shell-section",className:T,style:{height:a},id:"content",onClick:this.focusEditor.bind(this)},n().createElement(c.ResizeHandle,{direction:c.ResizeDirection.TOP,onChange:e=>this.updateHeight(e),value:e,minValue:32,maxValue:N(),title:"MongoDB Shell"}),n().createElement(H,{isExpanded:s,onShellToggleClicked:()=>s?this.updateHeight(32):this.updateHeight(t),isOperationInProgress:o,showInfoModal:()=>this.setState({showInfoModal:!0})}),n().createElement("div",{"data-testid":"shell-content",className:(0,c.cx)(D,s&&$)},n().createElement(R,{ref:this.shellRef,runtime:this.props.runtime,initialHistory:this.state.initialHistory,initialOutput:this.shellOutput,onHistoryChanged:this.saveHistory,onOutputChanged:this.onShellOutputChanged,onOperationStarted:this.onOperationStarted,onOperationEnd:this.onOperationEnd}))))}}const B=(0,a.$j)((e=>({emitShellPluginOpened:()=>{e.appRegistry&&e.appRegistry.globalAppRegistry&&e.appRegistry.globalAppRegistry.emit("compass:compass-shell:opened")},runtime:e.runtime?e.runtime.runtime:null})))((0,l.withPreferences)(U,["enableShell"],n()))},54039:e=>{function t(e){return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}))}t.keys=()=>[],t.resolve=t,t.id=54039,e.exports=t},98953:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=98953,e.exports=t},70648:()=>{}}]);
|
|
1
|
+
(global.webpackChunkCompassShellPlugin=global.webpackChunkCompassShellPlugin||[]).push([[508],{49945:(e,t,o)=>{"use strict";o.r(t),o.d(t,{CompassShell:()=>P,default:()=>N});var n=o(99497),i=o.n(n),r=o(13980),s=o.n(r),a=o(86993),l=o(39662),c=o(30709),h=o(25378);const d=[{key:"Ctrl+`",description:"Toggle shell."},{key:"Ctrl+A",description:"Moves the cursor to the beginning of the line."},{key:"Ctrl+B",description:"Moves the cursor Backward one character."},{key:"Ctrl+C",description:"Stop currently running command."},{key:"Ctrl+D",description:"Deletes the next character."},{key:"Ctrl+E",description:"Moves the cursor to the end of the line."},{key:"Ctrl+F",description:"Moves the cursor Forward one character."},{key:"Ctrl+H",description:"Erases one character, similar to hitting backspace."},{key:"mod+L",description:"Clears the screen, similar to the clear command."},{key:"Ctrl+T",description:"Swap the last two characters before the cursor."},{key:"Ctrl+U",description:"Changes the line to Uppercase."},{key:"ArrowUp",description:"Cycle backwards through command history."},{key:"ArrowDown",description:"Cycle forwards through command history."}];function p(){return i().createElement(c.Table,{data:d,columns:[i().createElement(c.TableHeader,{key:"name",label:"Key"}),i().createElement(c.TableHeader,{key:"value",label:"Description"})]},(({datum:e})=>i().createElement(c.Row,{key:e.key},i().createElement(c.Cell,null,i().createElement(c.Body,{weight:"medium"},i().createElement(c.KeyboardShortcut,{hotkey:e.key}))),i().createElement(c.Cell,null,i().createElement(c.Description,null,e.description)))))}const u=`v${o(74841).i8}`,m=(0,c.css)({marginTop:c.spacing[2],maxHeight:"50vh",overflow:"auto"}),g=(0,c.css)({marginTop:c.spacing[4]});function y({hideInfoModal:e,show:t}){(0,h.useTrackOnChange)("COMPASS-SHELL",(e=>{t&&e("Screen",{name:"shell_info_modal"})}),[t],void 0,i());const o=(0,n.useCallback)((()=>{e()}),[e]);return i().createElement(c.InfoModal,{open:t,title:`mongosh ${u}`,"data-testid":"shell-info-modal",onClose:o},i().createElement(c.Banner,null,"For more information please visit the ",i().createElement(c.Link,{id:"mongosh-info-link",href:"https://docs.mongodb.com/compass/beta/embedded-shell/",target:"_blank"},"MongoDB Shell Documentation"),"."),i().createElement(c.Subtitle,{className:g},"Keyboard Shortcuts"),i().createElement("div",{className:m},i().createElement(p,null)))}y.propTypes={hideInfoModal:s().func.isRequired,show:s().bool.isRequired};const f=y,b=(0,c.css)({height:c.spacing[5],display:"flex",color:c.palette.gray.light1}),E=(0,c.css)({borderTop:`1px solid ${c.palette.gray.dark2}`}),S=(0,c.css)({flexGrow:1,display:"flex",alignItems:"center"}),k=c.palette.gray.light1,w=(0,c.css)({background:"none",border:"none",cursor:"pointer",color:k,padding:`0px ${c.spacing[2]}px`,height:"100%",display:"flex",verticalAlign:"middle",flexDirection:"row",alignItems:"center",margin:"auto 0",fontWeight:"bold",fontSize:1.5*c.spacing[2],lineHeight:`${c.spacing[5]}px`,transition:"all 200ms",userSelect:"none",textTransform:"uppercase","&:hover":{color:c.palette.gray.light3}}),C=(0,c.css)({display:"flex",paddingTop:c.spacing[1]/2,paddingRight:c.spacing[2],gap:c.spacing[2]}),v=(0,c.css)({color:c.palette.green.light2,marginLeft:c.spacing[2]}),O=({darkMode:e,isExpanded:t,isOperationInProgress:o,onShellToggleClicked:n,showInfoModal:r})=>((0,c.useHotkeys)("ctrl + `",n),i().createElement("div",{className:(0,c.cx)(b,e&&E)},i().createElement("div",{className:S},i().createElement("button",{type:"button","data-testid":"shell-expand-button",className:w,"aria-label":t?"Close Shell":"Open Shell",onClick:n,"aria-pressed":t},i().createElement(c.GuideCue,{cueId:"shell-title",title:"Using the embedded MongoDB Shell",description:i().createElement(i().Fragment,null,"Compass includes an embedded mongosh, allowing you to test queries and operations in your databases.",i().createElement(c.Link,{href:"https://www.mongodb.com/docs/compass/beta/embedded-shell/#embedded-mongodb-shell",hideExternalIcon:!0},"Learn more about running operations in mongosh.")),trigger:({ref:e})=>i().createElement("span",{ref:e},">_MONGOSH")}),!t&&o&&i().createElement("span",{className:v},i().createElement(c.SpinLoader,{darkMode:!0})," Command in progress…"))),i().createElement("div",{className:C},t&&i().createElement(c.GuideCue,{cueId:"shell-info",title:"Using the embedded MongoDB Shell",description:"When expanded, mongosh enables you to run commands on your data. Click on the info icon to learn more about the keyboard shortcuts available to you when using mongosh.",trigger:({ref:e})=>i().createElement(c.IconButton,{ref:e,"data-testid":"shell-info-button",variant:"dark","aria-label":"Shell Info","aria-haspopup":"dialog",onClick:r},i().createElement(c.Icon,{glyph:"InfoWithCircle",size:"small"}))}),i().createElement(c.IconButton,{variant:"dark","aria-label":t?"Close Shell":"Open Shell",onClick:n,"aria-pressed":t},i().createElement(c.Icon,{glyph:t?"ChevronDown":"ChevronUp",size:"small"})))));O.propTypes={darkMode:s().bool,isExpanded:s().bool.isRequired,isOperationInProgress:s().bool.isRequired,onShellToggleClicked:s().func.isRequired,showInfoModal:s().func.isRequired};const x=(0,c.withDarkMode)(O),{Shell:M}=o(72519),I=(0,c.css)({backgroundColor:c.palette.gray.dark4,display:"flex",flexBasis:"auto",position:"relative",flexDirection:"column",width:"100vw"},(0,c.getScrollbarStyles)(!0)),H=(0,c.css)({flexGrow:1,display:"none",overflow:"auto",borderTop:`1px solid ${c.palette.gray.dark2}`}),R=(0,c.css)({display:"flex"}),D=100;function T(){return Math.max(240,window.innerHeight-100)}class P extends n.Component{static propTypes={emitShellPluginOpened:s().func,runtime:s().object,shellOutput:s().array,historyStorage:s().object,enableShell:s().bool};static defaultProps={emitShellPluginOpened:()=>{},runtime:null};constructor(e){super(e),this.shellRef=i().createRef(),this.shellOutput=this.props.shellOutput||[],this.state={height:32,prevHeight:240,initialHistory:this.props.historyStorage?null:[],isOperationInProgress:!1,showInfoModal:!1}}componentDidMount(){this.loadHistory(),window.addEventListener("beforeunload",this.terminateRuntime)}componentDidUpdate(e,t){const{height:o}=this.state;t.height<D&&o>D&&this.props.emitShellPluginOpened()}componentWillUnmount(){window.removeEventListener("beforeunload",this.terminateRuntime)}onShellOutputChanged=e=>{this.shellOutput=e};onOperationStarted=()=>{this.setState({isOperationInProgress:!0})};onOperationEnd=()=>{this.setState({isOperationInProgress:!1})};terminateRuntime=()=>{this.props.runtime&&this.props.runtime.terminate()};saveHistory=async e=>{if(this.props.historyStorage)try{await this.props.historyStorage.save(e)}catch(e){console.error(e)}};loadHistory=async()=>{if(this.props.historyStorage)try{const e=await this.props.historyStorage.load();this.setState({initialHistory:e})}catch(e){console.error(e),this.setState({initialHistory:[]})}};updateHeight(e){this.setState(e>D?{height:e,prevHeight:e}:{height:e})}hideInfoModal(){this.setState({showInfoModal:!1})}focusEditor(){this.shellRef.current&&"Range"!==window.getSelection()?.type&&this.shellRef.current.focusEditor()}render(){const{height:e,prevHeight:t,isOperationInProgress:o,showInfoModal:r}=this.state;if(!this.props.enableShell||!this.props.runtime||!this.state.initialHistory)return i().createElement("div",null);const s=e>D,a=s?function(e){const t=T();return Math.min(t,Math.max(D,e))}(e):32;return i().createElement(n.Fragment,null,i().createElement(f,{show:r,hideInfoModal:this.hideInfoModal.bind(this)}),i().createElement("div",{"data-testid":"shell-section",className:I,style:{height:a},id:"content",onClick:this.focusEditor.bind(this)},i().createElement(c.ResizeHandle,{direction:c.ResizeDirection.TOP,onChange:e=>this.updateHeight(e),value:e,minValue:32,maxValue:T(),title:"MongoDB Shell"}),i().createElement(x,{isExpanded:s,onShellToggleClicked:()=>s?this.updateHeight(32):this.updateHeight(t),isOperationInProgress:o,showInfoModal:()=>this.setState({showInfoModal:!0})}),i().createElement("div",{"data-testid":"shell-content",className:(0,c.cx)(H,s&&R)},i().createElement(M,{ref:this.shellRef,runtime:this.props.runtime,initialHistory:this.state.initialHistory,initialOutput:this.shellOutput,onHistoryChanged:this.saveHistory,onOutputChanged:this.onShellOutputChanged,onOperationStarted:this.onOperationStarted,onOperationEnd:this.onOperationEnd}))))}}const N=(0,a.$j)((e=>({emitShellPluginOpened:()=>{e.appRegistry&&e.appRegistry.globalAppRegistry&&e.appRegistry.globalAppRegistry.emit("compass:compass-shell:opened")},runtime:e.runtime?e.runtime.runtime:null})))((0,l.withPreferences)(P,["enableShell"],i()))},54039:e=>{function t(e){return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}))}t.keys=()=>[],t.resolve=t,t.id=54039,e.exports=t},98953:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=98953,e.exports=t},70648:()=>{}}]);
|
package/dist/716.browser.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
(self.webpackChunkCompassShellPlugin=self.webpackChunkCompassShellPlugin||[]).push([[716],{49945:(e,t,
|
|
2
|
-
0% { color: ${b}; }
|
|
3
|
-
10% { color: ${E}; }
|
|
4
|
-
20% { color: ${C}; }
|
|
5
|
-
30% { color: ${E}; }
|
|
6
|
-
40% { color: ${C}; }
|
|
7
|
-
50% { color: ${E}; }
|
|
8
|
-
60% { color: ${C}; }
|
|
9
|
-
70% { color: ${E}; }
|
|
10
|
-
80% { color: ${C}; }
|
|
11
|
-
100% { color: ${b}; }
|
|
12
|
-
`,v=(0,c.css)({background:"none",border:"none",cursor:"pointer",color:b,padding:`0px ${c.spacing[2]}px`,height:"100%",display:"flex",verticalAlign:"middle",flexDirection:"row",alignItems:"center",margin:"auto 0",fontWeight:"bold",fontSize:1.5*c.spacing[2],lineHeight:`${c.spacing[5]}px`,transition:"all 200ms",userSelect:"none",textTransform:"uppercase",animation:`${w} 2s linear`,"&:hover":{color:c.palette.gray.light3}}),O=(0,c.css)({display:"flex",paddingTop:c.spacing[1]/2,paddingRight:c.spacing[2]}),x=(0,c.css)({marginRight:c.spacing[2]}),I=(0,c.css)({color:c.palette.green.light2,marginLeft:c.spacing[2]}),M=e=>{let{darkMode:t,isExpanded:o,isOperationInProgress:i,onShellToggleClicked:r,showInfoModal:s}=e;return(0,c.useHotkeys)("ctrl + `",r),n().createElement("div",{className:(0,c.cx)(f,t&&k)},n().createElement("div",{className:S},n().createElement("button",{type:"button","data-testid":"shell-expand-button",className:v,"aria-label":o?"Close Shell":"Open Shell",onClick:r,"aria-pressed":o},">_MONGOSH",!o&&i&&n().createElement("span",{className:I},n().createElement(c.SpinLoader,{darkMode:!0})," Command in progress…"))),n().createElement("div",{className:O},o&&n().createElement(c.IconButton,{"data-testid":"shell-info-button",className:x,variant:"dark","aria-label":"Shell Info","aria-haspopup":"dialog",onClick:s},n().createElement(c.Icon,{glyph:"InfoWithCircle",size:"small"})),n().createElement(c.IconButton,{variant:"dark","aria-label":o?"Close Shell":"Open Shell",onClick:r,"aria-pressed":o},n().createElement(c.Icon,{glyph:o?"ChevronDown":"ChevronUp",size:"small"}))))};M.propTypes={darkMode:s().bool,isExpanded:s().bool.isRequired,isOperationInProgress:s().bool.isRequired,onShellToggleClicked:s().func.isRequired,showInfoModal:s().func.isRequired};const H=(0,c.withDarkMode)(M),{Shell:R}=o(72519),T=(0,c.css)({backgroundColor:c.palette.gray.dark4,display:"flex",flexBasis:"auto",position:"relative",flexDirection:"column",width:"100vw"},(0,c.getScrollbarStyles)(!0)),$=(0,c.css)({flexGrow:1,display:"none",overflow:"auto",borderTop:`1px solid ${c.palette.gray.dark2}`}),P=(0,c.css)({display:"flex"}),D=100;function N(){return Math.max(240,window.innerHeight-100)}class B extends i.Component{static propTypes={emitShellPluginOpened:s().func,runtime:s().object,shellOutput:s().array,historyStorage:s().object,enableShell:s().bool};static defaultProps={emitShellPluginOpened:()=>{},runtime:null};constructor(e){super(e),this.shellRef=n().createRef(),this.shellOutput=this.props.shellOutput||[],this.state={height:32,prevHeight:240,initialHistory:this.props.historyStorage?null:[],isOperationInProgress:!1,showInfoModal:!1}}componentDidMount(){this.loadHistory(),window.addEventListener("beforeunload",this.terminateRuntime)}componentDidUpdate(e,t){const{height:o}=this.state;t.height<D&&o>D&&this.props.emitShellPluginOpened()}componentWillUnmount(){window.removeEventListener("beforeunload",this.terminateRuntime)}onShellOutputChanged=e=>{this.shellOutput=e};onOperationStarted=()=>{this.setState({isOperationInProgress:!0})};onOperationEnd=()=>{this.setState({isOperationInProgress:!1})};terminateRuntime=()=>{this.props.runtime&&this.props.runtime.terminate()};saveHistory=async e=>{if(this.props.historyStorage)try{await this.props.historyStorage.save(e)}catch(e){console.error(e)}};loadHistory=async()=>{if(this.props.historyStorage)try{const e=await this.props.historyStorage.load();this.setState({initialHistory:e})}catch(e){console.error(e),this.setState({initialHistory:[]})}};updateHeight(e){this.setState(e>D?{height:e,prevHeight:e}:{height:e})}hideInfoModal(){this.setState({showInfoModal:!1})}focusEditor(){this.shellRef.current&&"Range"!==window.getSelection()?.type&&this.shellRef.current.focusEditor()}render(){const{height:e,prevHeight:t,isOperationInProgress:o,showInfoModal:r}=this.state;if(!this.props.enableShell||!this.props.runtime||!this.state.initialHistory)return n().createElement("div",null);const s=e>D,l=s?function(e){const t=N();return Math.min(t,Math.max(D,e))}(e):32;return n().createElement(i.Fragment,null,n().createElement(y,{show:r,hideInfoModal:this.hideInfoModal.bind(this)}),n().createElement("div",{"data-testid":"shell-section",className:T,style:{height:l},id:"content",onClick:this.focusEditor.bind(this)},n().createElement(c.ResizeHandle,{direction:c.ResizeDirection.TOP,onChange:e=>this.updateHeight(e),value:e,minValue:32,maxValue:N(),title:"MongoDB Shell"}),n().createElement(H,{isExpanded:s,onShellToggleClicked:()=>s?this.updateHeight(32):this.updateHeight(t),isOperationInProgress:o,showInfoModal:()=>this.setState({showInfoModal:!0})}),n().createElement("div",{"data-testid":"shell-content",className:(0,c.cx)($,s&&P)},n().createElement(R,{ref:this.shellRef,runtime:this.props.runtime,initialHistory:this.state.initialHistory,initialOutput:this.shellOutput,onHistoryChanged:this.saveHistory,onOutputChanged:this.onShellOutputChanged,onOperationStarted:this.onOperationStarted,onOperationEnd:this.onOperationEnd}))))}}const q=(0,l.$j)((e=>({emitShellPluginOpened:()=>{e.appRegistry&&e.appRegistry.globalAppRegistry&&e.appRegistry.globalAppRegistry.emit("compass:compass-shell:opened")},runtime:e.runtime?e.runtime.runtime:null})))((0,a.withPreferences)(B,["enableShell"],n()))},70648:()=>{}}]);
|
|
1
|
+
(self.webpackChunkCompassShellPlugin=self.webpackChunkCompassShellPlugin||[]).push([[716],{49945:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CompassShell:()=>P,default:()=>B});var o=n(99497),i=n.n(o),s=n(13980),r=n.n(s),a=n(86993),l=n(39662),c=n(30709),h=n(25378);const d=[{key:"Ctrl+`",description:"Toggle shell."},{key:"Ctrl+A",description:"Moves the cursor to the beginning of the line."},{key:"Ctrl+B",description:"Moves the cursor Backward one character."},{key:"Ctrl+C",description:"Stop currently running command."},{key:"Ctrl+D",description:"Deletes the next character."},{key:"Ctrl+E",description:"Moves the cursor to the end of the line."},{key:"Ctrl+F",description:"Moves the cursor Forward one character."},{key:"Ctrl+H",description:"Erases one character, similar to hitting backspace."},{key:"mod+L",description:"Clears the screen, similar to the clear command."},{key:"Ctrl+T",description:"Swap the last two characters before the cursor."},{key:"Ctrl+U",description:"Changes the line to Uppercase."},{key:"ArrowUp",description:"Cycle backwards through command history."},{key:"ArrowDown",description:"Cycle forwards through command history."}];function p(){return i().createElement(c.Table,{data:d,columns:[i().createElement(c.TableHeader,{key:"name",label:"Key"}),i().createElement(c.TableHeader,{key:"value",label:"Description"})]},(e=>{let{datum:t}=e;return i().createElement(c.Row,{key:t.key},i().createElement(c.Cell,null,i().createElement(c.Body,{weight:"medium"},i().createElement(c.KeyboardShortcut,{hotkey:t.key}))),i().createElement(c.Cell,null,i().createElement(c.Description,null,t.description)))}))}const u=`v${n(74841).i8}`,m=(0,c.css)({marginTop:c.spacing[2],maxHeight:"50vh",overflow:"auto"}),g=(0,c.css)({marginTop:c.spacing[4]});function y(e){let{hideInfoModal:t,show:n}=e;(0,h.useTrackOnChange)("COMPASS-SHELL",(e=>{n&&e("Screen",{name:"shell_info_modal"})}),[n],void 0,i());const s=(0,o.useCallback)((()=>{t()}),[t]);return i().createElement(c.InfoModal,{open:n,title:`mongosh ${u}`,"data-testid":"shell-info-modal",onClose:s},i().createElement(c.Banner,null,"For more information please visit the ",i().createElement(c.Link,{id:"mongosh-info-link",href:"https://docs.mongodb.com/compass/beta/embedded-shell/",target:"_blank"},"MongoDB Shell Documentation"),"."),i().createElement(c.Subtitle,{className:g},"Keyboard Shortcuts"),i().createElement("div",{className:m},i().createElement(p,null)))}y.propTypes={hideInfoModal:r().func.isRequired,show:r().bool.isRequired};const f=y,b=(0,c.css)({height:c.spacing[5],display:"flex",color:c.palette.gray.light1}),S=(0,c.css)({borderTop:`1px solid ${c.palette.gray.dark2}`}),k=(0,c.css)({flexGrow:1,display:"flex",alignItems:"center"}),E=c.palette.gray.light1,C=(0,c.css)({background:"none",border:"none",cursor:"pointer",color:E,padding:`0px ${c.spacing[2]}px`,height:"100%",display:"flex",verticalAlign:"middle",flexDirection:"row",alignItems:"center",margin:"auto 0",fontWeight:"bold",fontSize:1.5*c.spacing[2],lineHeight:`${c.spacing[5]}px`,transition:"all 200ms",userSelect:"none",textTransform:"uppercase","&:hover":{color:c.palette.gray.light3}}),w=(0,c.css)({display:"flex",paddingTop:c.spacing[1]/2,paddingRight:c.spacing[2],gap:c.spacing[2]}),v=(0,c.css)({color:c.palette.green.light2,marginLeft:c.spacing[2]}),O=e=>{let{darkMode:t,isExpanded:n,isOperationInProgress:o,onShellToggleClicked:s,showInfoModal:r}=e;return(0,c.useHotkeys)("ctrl + `",s),i().createElement("div",{className:(0,c.cx)(b,t&&S)},i().createElement("div",{className:k},i().createElement("button",{type:"button","data-testid":"shell-expand-button",className:C,"aria-label":n?"Close Shell":"Open Shell",onClick:s,"aria-pressed":n},i().createElement(c.GuideCue,{cueId:"shell-title",title:"Using the embedded MongoDB Shell",description:i().createElement(i().Fragment,null,"Compass includes an embedded mongosh, allowing you to test queries and operations in your databases.",i().createElement(c.Link,{href:"https://www.mongodb.com/docs/compass/beta/embedded-shell/#embedded-mongodb-shell",hideExternalIcon:!0},"Learn more about running operations in mongosh.")),trigger:e=>{let{ref:t}=e;return i().createElement("span",{ref:t},">_MONGOSH")}}),!n&&o&&i().createElement("span",{className:v},i().createElement(c.SpinLoader,{darkMode:!0})," Command in progress…"))),i().createElement("div",{className:w},n&&i().createElement(c.GuideCue,{cueId:"shell-info",title:"Using the embedded MongoDB Shell",description:"When expanded, mongosh enables you to run commands on your data. Click on the info icon to learn more about the keyboard shortcuts available to you when using mongosh.",trigger:e=>{let{ref:t}=e;return i().createElement(c.IconButton,{ref:t,"data-testid":"shell-info-button",variant:"dark","aria-label":"Shell Info","aria-haspopup":"dialog",onClick:r},i().createElement(c.Icon,{glyph:"InfoWithCircle",size:"small"}))}}),i().createElement(c.IconButton,{variant:"dark","aria-label":n?"Close Shell":"Open Shell",onClick:s,"aria-pressed":n},i().createElement(c.Icon,{glyph:n?"ChevronDown":"ChevronUp",size:"small"}))))};O.propTypes={darkMode:r().bool,isExpanded:r().bool.isRequired,isOperationInProgress:r().bool.isRequired,onShellToggleClicked:r().func.isRequired,showInfoModal:r().func.isRequired};const x=(0,c.withDarkMode)(O),{Shell:I}=n(72519),M=(0,c.css)({backgroundColor:c.palette.gray.dark4,display:"flex",flexBasis:"auto",position:"relative",flexDirection:"column",width:"100vw"},(0,c.getScrollbarStyles)(!0)),H=(0,c.css)({flexGrow:1,display:"none",overflow:"auto",borderTop:`1px solid ${c.palette.gray.dark2}`}),R=(0,c.css)({display:"flex"}),T=100;function D(){return Math.max(240,window.innerHeight-100)}class P extends o.Component{static propTypes={emitShellPluginOpened:r().func,runtime:r().object,shellOutput:r().array,historyStorage:r().object,enableShell:r().bool};static defaultProps={emitShellPluginOpened:()=>{},runtime:null};constructor(e){super(e),this.shellRef=i().createRef(),this.shellOutput=this.props.shellOutput||[],this.state={height:32,prevHeight:240,initialHistory:this.props.historyStorage?null:[],isOperationInProgress:!1,showInfoModal:!1}}componentDidMount(){this.loadHistory(),window.addEventListener("beforeunload",this.terminateRuntime)}componentDidUpdate(e,t){const{height:n}=this.state;t.height<T&&n>T&&this.props.emitShellPluginOpened()}componentWillUnmount(){window.removeEventListener("beforeunload",this.terminateRuntime)}onShellOutputChanged=e=>{this.shellOutput=e};onOperationStarted=()=>{this.setState({isOperationInProgress:!0})};onOperationEnd=()=>{this.setState({isOperationInProgress:!1})};terminateRuntime=()=>{this.props.runtime&&this.props.runtime.terminate()};saveHistory=async e=>{if(this.props.historyStorage)try{await this.props.historyStorage.save(e)}catch(e){console.error(e)}};loadHistory=async()=>{if(this.props.historyStorage)try{const e=await this.props.historyStorage.load();this.setState({initialHistory:e})}catch(e){console.error(e),this.setState({initialHistory:[]})}};updateHeight(e){this.setState(e>T?{height:e,prevHeight:e}:{height:e})}hideInfoModal(){this.setState({showInfoModal:!1})}focusEditor(){this.shellRef.current&&"Range"!==window.getSelection()?.type&&this.shellRef.current.focusEditor()}render(){const{height:e,prevHeight:t,isOperationInProgress:n,showInfoModal:s}=this.state;if(!this.props.enableShell||!this.props.runtime||!this.state.initialHistory)return i().createElement("div",null);const r=e>T,a=r?function(e){const t=D();return Math.min(t,Math.max(T,e))}(e):32;return i().createElement(o.Fragment,null,i().createElement(f,{show:s,hideInfoModal:this.hideInfoModal.bind(this)}),i().createElement("div",{"data-testid":"shell-section",className:M,style:{height:a},id:"content",onClick:this.focusEditor.bind(this)},i().createElement(c.ResizeHandle,{direction:c.ResizeDirection.TOP,onChange:e=>this.updateHeight(e),value:e,minValue:32,maxValue:D(),title:"MongoDB Shell"}),i().createElement(x,{isExpanded:r,onShellToggleClicked:()=>r?this.updateHeight(32):this.updateHeight(t),isOperationInProgress:n,showInfoModal:()=>this.setState({showInfoModal:!0})}),i().createElement("div",{"data-testid":"shell-content",className:(0,c.cx)(H,r&&R)},i().createElement(I,{ref:this.shellRef,runtime:this.props.runtime,initialHistory:this.state.initialHistory,initialOutput:this.shellOutput,onHistoryChanged:this.saveHistory,onOutputChanged:this.onShellOutputChanged,onOperationStarted:this.onOperationStarted,onOperationEnd:this.onOperationEnd}))))}}const B=(0,a.$j)((e=>({emitShellPluginOpened:()=>{e.appRegistry&&e.appRegistry.globalAppRegistry&&e.appRegistry.globalAppRegistry.emit("compass:compass-shell:opened")},runtime:e.runtime?e.runtime.runtime:null})))((0,l.withPreferences)(P,["enableShell"],i()))},70648:()=>{}}]);
|