Skip to content

Commit 6ce22e5

Browse files
authored
Merge pull request #25 from Aviral09/dev
Bug fixes and issues solved
2 parents eabf5a9 + 936b0ea commit 6ce22e5

9 files changed

Lines changed: 139 additions & 22 deletions

File tree

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const app = () => {
2929
<FileDragDrop dispatcher={dispatcher} />
3030
<Header superState={superState} dispatcher={dispatcher} />
3131
<section className="body" style={{ display: 'flex', overflow: 'hidden' }}>
32-
<div style={{ display: 'flex' }}>
32+
<div style={{ display: 'flex', overflow: 'auto' }}>
3333
<LocalFileBrowser dispatcher={dispatcher} />
3434
</div>
3535
<div className="graph" style={{ display: 'flex', overflow: 'hidden' }}>

src/component/Header.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const setHotKeys = (actions) => {
3030
};
3131

3232
const Header = ({ superState, dispatcher }) => {
33-
const actions = toolbarList(superState);
33+
const actions = toolbarList(superState, dispatcher);
3434
React.useEffect(() => {
3535
setHotKeys(actions, superState, dispatcher);
3636
}, []);

src/component/fileBrowser.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ div.rendered-react-keyed-file-browser div.action-bar {
4343
margin-right: 0.5rem; }
4444

4545
div.rendered-react-keyed-file-browser div.files {
46-
overflow: auto;
46+
/* overflow: auto; */
4747
width: 30vw;
4848
}
4949

src/component/header.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
height: auto;
88
display: flex;
99
box-sizing: border-box;
10-
overflow: auto;
10+
overflow-x: auto;
11+
overflow-y: hidden;
1112
}
1213

1314
.toolbar .tool {

src/component/modals/NodeDetails.jsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const NodeDetails = ({
2626
}
2727
}, [!widthSet && data.label]);
2828

29+
useEffect(() => {
30+
setLabelName(data.label.split(':')[0]);
31+
}, [data.label]);
32+
2933
return (
3034
<div className="nodeform" onSubmit={submit}>
3135
<div className="parent-div" style={{ height: data.style.height }}>
@@ -96,7 +100,6 @@ const NodeDetails = ({
96100
required
97101
label="Node Label file"
98102
placeholder="Select file"
99-
// value={data.label.split(':')[1]}
100103
onChange={(e) => {
101104
setLabelFile(e.target.value.split('/').pop());
102105
if (labelName) {
@@ -106,16 +109,24 @@ const NodeDetails = ({
106109
lname += ':';
107110
}
108111
setData({ ...data, label: lname + e.target.value.split('/').pop() });
109-
}
110-
setData({ ...data, label: labelName + e.target.value.split('/').pop() });
112+
} else setData({ ...data, label: `:${e.target.value.split('/').pop()}` });
111113
}}
112114
list="files"
113115
/>
114116
<datalist id="files">
115117
{
116118
localStorageManager.getFileList()
117-
// eslint-disable-next-line max-len, jsx-a11y/control-has-associated-label
118-
? JSON.parse(localStorageManager.getFileList()).map((item) => <option value={`${item.key.toString()}`} />)
119+
// eslint-disable-next-line max-len, prefer-arrow-callback
120+
? JSON.parse(localStorageManager.getFileList()).map(function fn(item, index) {
121+
const acceptedTypes = ['.v', '.c', '.cpp', '.py', '.m', '.sh'];
122+
const list = [];
123+
// eslint-disable-next-line max-len
124+
if ((acceptedTypes.some((substring) => item.key.toString().includes(substring)))) {
125+
list.push(item.key.toString());
126+
}
127+
// eslint-disable-next-line jsx-a11y/control-has-associated-label, react/no-array-index-key
128+
return <option value={list} key={index} />;
129+
})
119130
: ''
120131
}
121132
</datalist>

src/component/modals/ProjectDetails.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ const ProjectDetails = ({ superState, dispatcher }) => {
2424
useEffect(() => {
2525
if (superState.editDetailsModal && curGraph) {
2626
setProjectName(curGraph.projectName);
27-
} else setProjectName('');
27+
}
2828
}, [superState.authorName, superState.editDetailsModal, curGraph]);
29+
2930
useEffect(() => {
3031
if (superState.authorName) setAuthorName(superState.authorName);
3132
else {

src/graph-builder/graph-core/6-server.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,36 @@ class GraphServer extends GraphLoadSave {
6464
// }
6565
// }
6666

67+
build() {
68+
// TODO
69+
if (this.serverID);
70+
}
71+
72+
debug() {
73+
// TODO
74+
if (this.serverID);
75+
}
76+
77+
run() {
78+
// TODO
79+
if (this.serverID);
80+
}
81+
82+
clear() {
83+
// TODO
84+
if (this.serverID);
85+
}
86+
87+
stop() {
88+
// TODO
89+
if (this.serverID);
90+
}
91+
92+
destroy() {
93+
// TODO
94+
if (this.serverID);
95+
}
96+
6797
setCurStatus() {
6898
super.setCurStatus();
6999
this.dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: Boolean(this.serverID) });

src/toolbarActions/toolbarFunctions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,17 @@ const viewHistory = (state, setState) => {
142142
setState({ type: T.SET_HISTORY_MODAL, payload: true });
143143
};
144144

145+
const toggleServer = (state, dispatcher) => {
146+
if (state.isWorkflowOnServer) {
147+
dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: false });
148+
} else {
149+
dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: true });
150+
}
151+
};
152+
145153
export {
146154
createNode, editElement, deleteElem, downloadImg, saveAction,
147155
readFile, readTextFile, newProject, clearAll, editDetails, undo, redo,
148156
openShareModal, openSettingModal, viewHistory,
157+
toggleServer,
149158
};

src/toolbarActions/toolbarList.js

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/* eslint-disable no-alert */
22
import {
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

1112
import {
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

Comments
 (0)