1- import { useState , useEffect } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import {
3+ Button ,
34 Container ,
5+ Form ,
6+ Modal ,
47 Nav ,
5- Navbar ,
68 NavDropdown ,
7- Modal ,
8- Button ,
9+ Navbar ,
910 Tab ,
10- Tabs ,
1111 Table ,
12- Form
12+ Tabs
1313} from "react-bootstrap" ;
1414import { DropdownSubmenu , NavDropdownMenu } from "react-bootstrap-submenu" ;
15- import { FaToggleOn , FaToggleOff , FaInfoCircle } from "react-icons/fa" ;
16- import { FcRadarPlot , FcScatterPlot , FcHeatMap } from "react-icons/fc" ;
1715import "react-bootstrap-submenu/dist/index.css" ;
18- import logo from "../static/img/logo.png " ;
19- import { generateUUID } from "three/src/math/MathUtils " ;
20- import { PORT } from "../static/js/constants " ;
16+ import { FaInfoCircle , FaToggleOff , FaToggleOn } from "react-icons/fa " ;
17+ import { FcHeatMap , FcRadarPlot , FcScatterPlot } from "react-icons/fc " ;
18+ import { LuEdit , LuPlay } from "react-icons/lu " ;
2119import { ToastContainer , toast } from "react-toastify" ;
2220import "react-toastify/dist/ReactToastify.css" ;
21+ import { generateUUID } from "three/src/math/MathUtils" ;
22+ import logo from "../static/img/logo.png" ;
23+ import { PORT } from "../static/js/constants" ;
24+ import { defaultSettings } from "../views/Settings" ;
2325
2426function ToolBar ( {
2527 page,
@@ -287,9 +289,19 @@ function ToolBar({
287289 rows . push (
288290 < NavDropdown . Item
289291 key = { generateUUID ( ) }
290- onClick = { ( ) => runSequence ( seq_name ) }
292+ style = { { display : "flex" , justifyContent : "space-between" , alignItems : "center" } }
291293 >
292- { seq_name }
294+ < div > { seq_name } </ div >
295+
296+ < div className = "form-group" >
297+ < Button variant = "outline-success"
298+ onClick = { ( ) => runSequence ( seq_name ) }
299+ > < LuPlay /> </ Button >
300+
301+ < Button variant = "outline-outline"
302+ onClick = { ( ) => openFileWithEditor ( seq_name ) }
303+ > < LuEdit /> </ Button >
304+ </ div >
293305 </ NavDropdown . Item >
294306 ) ;
295307 } ) ;
@@ -316,13 +328,32 @@ function ToolBar({
316328 }
317329 ) . then ( ( res ) => res . json ( ) ) ;
318330
319- if ( response . ok ) toast . success ( `"${ name } " created successfully` ) ;
320- else toast . error ( response . err ) ;
331+ if ( response . ok ) {
332+ toast . success ( `"${ name } " created successfully` ) ;
333+ openFileWithEditor ( `${ name } .py` ) ;
334+ }
335+ else {
336+ toast . error ( response . err ) ;
337+ }
321338
322339 getSequences ( ) ;
323340 setShowCreateMessage ( false ) ;
324341 } ;
325342
343+ const openFileWithEditor = async ( sequenceName ) => {
344+ const general_settings = parseLocalStorage ( "general_settings" ) ;
345+ const externalEditor =
346+ general_settings . externalEditor ?? defaultSettings [ "externalEditor" ] ;
347+ const response = await fetch ( `http://localhost:${ PORT } /open_sequence_file` , {
348+ headers : {
349+ "Content-Type" : "application/json" ,
350+ } ,
351+ method : "POST" ,
352+ body : JSON . stringify ( { sequence : sequenceName , editorBinary : externalEditor } ) ,
353+ } ) . then ( ( res ) => res . json ( ) ) ;
354+ if ( ! response . ok ) toast . error ( response . err ) ;
355+ }
356+
326357 const paramSearch = ( query , dict ) => {
327358 const value = query . target . value ;
328359 setSearchQuery ( value ) ;
0 commit comments