Files

1 line
3.3 KiB
JavaScript
Raw Permalink Normal View History

2026-03-22 03:21:45 +02:00
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=e(require("react")),n=e(require("../atom-react/components/jibo-combo-box-unidirectional")),i=e(require("./run-configuration.js")),o=e(require("../launcher/launcher")),a=require("atom").CompositeDisposable,r=e(require("lodash")),s=t.createClass({displayName:"Editor",render:function(){return t.createElement("atom-text-editor",{className:"inline-block",ref:"editor",style:{width:300},mini:!0},this.props.initValue)},componentDidMount:function(){var e=this,n=t.findDOMNode(this.refs.editor);if(n){var i=n.getModel();this.props.onSetValue(i.getText()),i.onDidChange(function(){e.props.onSetValue(i.getText())})}}});module.exports=t.createClass({displayName:"toolbar",componentDidMount:function(){var e=this,n=this;this.disposable=new a;var i=["RunConfiguration.type","RunConfiguration.host","RunConfiguration.run-dir"];i.forEach(function(i){var o="jibo-sdk."+i;e.disposable.add(atom.config.observe(o,function(){"jibo-sdk.RunConfiguration.run-dir"===o&&n.refs.rundir?t.findDOMNode(n.refs.rundir).getModel().setText(atom.config.get(o)):"jibo-sdk.RunConfiguration.host"===o&&n.refs.host?t.findDOMNode(n.refs.host).getModel().setText(atom.config.get(o)):n.forceUpdate()}))})},componentWillUnmount:function(){this.disposable.dispose()},getInitialState:function(){return o.on("exit",this.onExit.bind(this)),o.on("start",this.onStart.bind(this)),{isPlaying:o.isPlaying}},onExit:function(){this.state.isPlaying=!1,this.setState(this.state)},onStart:function(){this.state.isPlaying=!0,this.setState(this.state)},render:function(){var e=[{label:"Run Locally",display:"local",value:"local"},{label:"Run Remotely",display:"remote",value:"remote"}],o=null,a=r.find(e,function(e){return i.type===e.value});"remote"===i.type&&(o=[t.createElement("p",{style:{margin:5,whiteSpace:"nowrap"}},"Robot Host URL\xa0"),t.createElement(s,{tabIndex:1,ref:"host",initValue:i.host,onSetValue:function(e){i.host=e}})]);var l={toolbar:{display:"flex",minWidth:664},logo:{width:48,height:27,margin:"1px 0px auto 10px"},beta:{color:"#e2c08d",margin:"0px 10px 0px 0px"},close:{padding:7,cursor:"pointer",fontSize:"1.1em"}},c=this.state.isPlaying?"fa fa-stop":"fa fa-play";return t.createElement("div",{className:"inline-block jibo-tool-bar",style:l.toolbar},t.createElement("img",{style:l.logo,src:"atom://jibo-sdk/images/jibo.png"}),t.createElement("p",{style:l.beta},"(Beta)\xa0"),t.createElement("div",{className:"btn inline-block",onClick:this.state.isPlaying?this.onStop:this.onPlay},t.createElement("i",{className:c,style:{color:this.state.isPlaying?"red":"green",fontSize:15}})),t.createElement(n,{data:e,current:a,onSelected:this.onChangeConfiguration}),o,t.createElement("p",{style:{margin:5,whiteSpace:"nowrap"}},"Run Directory\xa0"),t.createElement(s,{tabIndex:2,ref:"rundir",initValue:i.runDir,onSetValue:function(e){i.runDir=e}}),t.createElement("span",{className:"btn inline-block",onClick:this.onOpenPackageSettings},t.createElement("span",null,"Settings\xa0"),t.createElement("i",{className:"fa fa-edit"})))},onOpenPackageSettings:function(){atom.workspace.open("atom://config/packages/jibo-sdk").then(function(){var e=document.querySelector(".package-detail.panels-item");e&&(e.scrollTop=380)})},onPlay:function(){o.play()},onStop:function(){o.stop()},onChangeConfiguration:function(e){i.type=e.value}});