11/* eslint-disable no-alert */
22import {
33 FaSave , FaUndo , FaRedo , FaTrash , FaFileImport , FaPlus , FaDownload , FaEdit , FaRegTimesCircle , FaShare , FaHistory ,
4- // FaRegSun ,
4+ FaHammer , FaBug , FaBomb , FaToggleOn , FaThermometerEmpty ,
55} from 'react-icons/fa' ;
66
7- // import {
8- // FiChevronDown, FiChevronsDown, FiChevronsUp, FiChevronUp,
9- // } from 'react-icons/fi';
7+ import {
8+ // FiChevronDown, FiChevronsDown, FiChevronsUp, FiChevronUp,
9+ FiPlay , FiStopCircle , FiToggleLeft , FiTriangle ,
10+ } from 'react-icons/fi' ;
1011
1112import {
1213 createNode , editElement , deleteElem , downloadImg , saveAction ,
1314 readFile , clearAll , undo , redo , openShareModal , viewHistory ,
15+ toggleServer ,
1416 // openSettingModal,
1517} from './toolbarFunctions' ;
1618
17- const toolbarList = ( state ) => [
19+ const toolbarList = ( state , dispatcher ) => [
1820 {
1921 type : 'action' ,
2022 text : 'Node' ,
@@ -37,18 +39,23 @@ const toolbarList = (state) => [
3739 text : 'Save' ,
3840 icon : FaSave ,
3941 action : ( s , d ) => [
40- { fn : ( ) => state . curGraphInstance && state . curGraphInstance . pushToServer ( ) , name : 'Save on Server' } ,
41- { fn : ( ) => saveAction ( s , d ) , name : 'Save' } ,
42- { fn : ( ) => saveAction ( s , d , prompt ( 'File Name:' ) ) , name : 'Save As' } ,
43- // TODO
44- // { fn: () => saveLocal(s, d), name: 'Save Local' },
42+ { fn : ( ) => saveAction ( s , d ) , name : 'Save As' } ,
43+ ] ,
44+ active : false ,
45+ } ,
46+ {
47+ type : 'menu' ,
48+ text : 'Save As' ,
49+ icon : FaSave ,
50+ action : ( s , d ) => [
51+ { fn : ( ) => saveAction ( s , d ) , name : 'Save As' } ,
4552 ] ,
4653 active : true ,
4754 } ,
4855 {
4956 type : 'action' ,
50- text : 'Clear ' ,
51- icon : FaRegTimesCircle ,
57+ text : 'Empty ' ,
58+ icon : FaThermometerEmpty ,
5259 action : clearAll ,
5360 active : true ,
5461 hotkey : 'Ctrl+Backspace' ,
@@ -96,6 +103,57 @@ const toolbarList = (state) => [
96103 active : true ,
97104 } ,
98105 { type : 'vsep' } ,
106+ // server buttons
107+ {
108+ type : 'action' ,
109+ text : 'Server' ,
110+ icon : state . isWorkflowOnServer ? FaToggleOn : FiToggleLeft ,
111+ action : ( ) => toggleServer ( state , dispatcher ) ,
112+ active : true ,
113+ } ,
114+ {
115+ type : 'action' ,
116+ text : 'Build' ,
117+ icon : FaHammer ,
118+ action : ( ) => state . curGraphInstance && state . curGraphInstance . build ( ) ,
119+ active : state . isWorkflowOnServer ,
120+ } ,
121+ {
122+ type : 'action' ,
123+ text : 'Debug' ,
124+ icon : FaBug ,
125+ action : ( ) => state . curGraphInstance && state . curGraphInstance . debug ( ) ,
126+ active : state . isWorkflowOnServer ,
127+ } ,
128+ {
129+ type : 'action' ,
130+ text : 'Run' ,
131+ icon : FiPlay ,
132+ action : ( ) => state . curGraphInstance && state . curGraphInstance . run ( ) ,
133+ active : state . isWorkflowOnServer ,
134+ } ,
135+ {
136+ type : 'action' ,
137+ text : 'Clear' ,
138+ icon : FaRegTimesCircle ,
139+ action : ( ) => state . curGraphInstance && state . curGraphInstance . clear ( ) ,
140+ active : state . isWorkflowOnServer ,
141+ } ,
142+ {
143+ type : 'action' ,
144+ text : 'Stop' ,
145+ icon : FiStopCircle ,
146+ action : ( ) => state . curGraphInstance && state . curGraphInstance . stop ( ) ,
147+ active : state . isWorkflowOnServer ,
148+ } ,
149+ {
150+ type : 'action' ,
151+ text : 'Destroy' ,
152+ icon : FaBomb ,
153+ action : ( ) => state . curGraphInstance && state . curGraphInstance . destroy ( ) ,
154+ active : state . isWorkflowOnServer ,
155+ } ,
156+
99157 // Not being implemented in version 1
100158 // {
101159 // type: 'action',
@@ -135,6 +193,13 @@ const toolbarList = (state) => [
135193 // action: openSettingModal,
136194 // active: true,
137195 // },
196+ {
197+ type : 'action' ,
198+ text : 'Contribute' ,
199+ icon : FiTriangle ,
200+ action : ( ) => { window . open ( 'https://github.com/ControlCore-Project/concore-editor' , '_blank' ) ; } ,
201+ active : true ,
202+ } ,
138203 {
139204 type : 'action' ,
140205 text : 'Share' ,
0 commit comments