Skip to content

Commit d4c4204

Browse files
committed
Options button added
1 parent 5f4e67a commit d4c4204

11 files changed

Lines changed: 84 additions & 9 deletions

File tree

src/App.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import HistoryModal from './component/modals/History';
1515
import LocalFileBrowser from './component/fileBrowser';
1616
import FileEditModal from './component/modals/FileEdit';
1717
import MarkDown from './component/modals/markDown';
18+
import OptionsModal from './component/modals/OptionsModal';
1819

1920
const app = () => {
2021
const [superState, dispatcher] = useReducer(reducer, initialState);
@@ -35,6 +36,7 @@ const app = () => {
3536
<SettingsModal superState={superState} dispatcher={dispatcher} />
3637
<HistoryModal superState={superState} dispatcher={dispatcher} />
3738
<FileEditModal superState={superState} dispatcher={dispatcher} />
39+
<OptionsModal superState={superState} dispatcher={dispatcher} />
3840
<GraphCompDetails
3941
closeModal={() => dispatcher({ type: T.Model_Close })}
4042
superState={superState}

src/component/modals/GraphCompDetails.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ const ModalComp = ({ closeModal, superState, dispatcher }) => {
9696
if (matchingElement) {
9797
const fr = new FileReader();
9898
fr.onload = (x) => {
99-
dispatcher({ type: T.SET_INPUT_FILE, payload: x.target.result });
99+
// eslint-disable-next-line max-len
100+
dispatcher({ type: T.SET_INPUT_FILE, payload: { content: x.target.result, fname: matchingElement.key.split('/')[1] } });
100101
};
101102
if (matchingElement.fileHandle) {
102103
fr.readAsText(await matchingElement.fileHandle.getFile());

src/component/modals/NodeDetails.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,16 @@ const NodeDetails = ({
170170
}
171171
indexOfFile.push(indexOfFile[indexOfFile.length - 1] + 1);
172172
index = indexOfFile[indexOfFile.length - 1] + 1;
173-
// eslint-disable-next-line jsx-a11y/control-has-associated-label
174-
return <option value={list} key={index} />;
173+
/* eslint-disable */
174+
return (
175+
<>
176+
<label htmlFor="dropdown">
177+
Hi
178+
<option value={list} key={index} />
179+
</label>
180+
</>
181+
);
182+
/* eslint-enable */
175183
}
176184
return null;
177185
})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import ParentModal from './ParentModal';
3+
import { actionType as T } from '../../reducer';
4+
import './optionsModal.css';
5+
6+
const OptionsModal = ({ superState, dispatcher }) => {
7+
const close = () => {
8+
dispatcher({ type: T.SET_OPTIONS_MODAL, payload: false });
9+
};
10+
const Options = 'Options';
11+
return (
12+
<ParentModal closeModal={close} ModelOpen={superState.optionsModal} title={Options}>
13+
<div className="main-div">
14+
<label htmlFor="Docker">
15+
Docker
16+
<input type="checkbox" />
17+
</label>
18+
<label htmlFor="Unlock" className="main-div-comp">
19+
Unlock
20+
<input type="checkbox" />
21+
</label>
22+
<label htmlFor="Maxtime" className="main-div-comp">
23+
Max Time&nbsp;
24+
<input type="text" />
25+
</label>
26+
<br />
27+
<br />
28+
<br />
29+
<span>Params:</span>
30+
<br />
31+
<textarea name="" id="" cols="80" rows="10" />
32+
</div>
33+
</ParentModal>
34+
);
35+
};
36+
37+
export default OptionsModal;

src/component/modals/markDown.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import ParentModal from './ParentModal';
44
import { actionType as T } from '../../reducer';
55

66
const MarkDown = ({ superState, dispatcher }) => {
7-
const title = 'Demo';
87
const close = () => {
98
dispatcher({ type: T.SET_MARKDOWN_MODAL, payload: false });
9+
dispatcher({ type: T.SET_INPUT_FILE, payload: { inputFile: '', fname: '' } });
1010
};
1111
return (
12-
<ParentModal closeModal={close} ModelOpen={superState.markDownModal} title={title}>
12+
<ParentModal closeModal={close} ModelOpen={superState.markDownModal} title={superState.inputFileName}>
1313
<ReactMarkdown>{superState.inputFile}</ReactMarkdown>
1414
</ParentModal>
1515
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.main-div {
2+
padding: 30px;
3+
}
4+
.main-div-comp {
5+
margin: 20px;
6+
}

src/reducer/actionType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const actionType = {
3232
SET_ZOOM_LEVEL: 'SET_ZOOM_LEVEL',
3333
SET_EDIT_DETAILS_MODAL: 'SET_EDIT_DETAILS_MODAL',
3434
SET_NEW_GRAPH_MODAL: 'SET_NEW_GRAPH_MODAL',
35+
SET_OPTIONS_MODAL: 'SET_OPTIONS_MODAL',
3536
EDIT_TEXTFILE: 'EDIT_TEXTFILE',
3637
SET_FILE_HANDLE: 'SET_FILE_HANDLE',
3738
SET_DIR_NAME: 'SET_DIR_NAME',

src/reducer/initialState.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const initialState = {
1313
settingsModal: false,
1414
editDetailsModal: false,
1515
newGraphModal: false,
16+
optionsModal: false,
1617
markDownModal: false,
1718
eleSelected: false,
1819
drawModeOn: true,

src/reducer/reducer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ const reducer = (state, action) => {
134134
return { ...state, shareModal: action.payload };
135135
}
136136

137+
case T.SET_OPTIONS_MODAL: {
138+
return { ...state, optionsModal: action.payload };
139+
}
140+
137141
case T.SET_FILE_STATE: {
138142
return { ...state, fileState: action.payload };
139143
}
@@ -147,7 +151,7 @@ const reducer = (state, action) => {
147151
}
148152

149153
case T.SET_INPUT_FILE: {
150-
return { ...state, inputFile: action.payload };
154+
return { ...state, inputFile: action.payload.content, inputFileName: action.payload.fname };
151155
}
152156

153157
case T.SET_FILE_REF: {

src/toolbarActions/toolbarFunctions.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ const readTextFile = (state, setState, file, fileHandle) => {
130130
}
131131
};
132132

133+
const optionModalToggle = (state, setState) => {
134+
setState({
135+
type: T.SET_OPTIONS_MODAL,
136+
payload: true,
137+
});
138+
};
139+
133140
const createFile = (state, setState) => {
134141
setState({
135142
type: T.EDIT_TEXTFILE,
@@ -187,5 +194,5 @@ export {
187194
createNode, editElement, deleteElem, downloadImg, saveAction, saveGraphMLFile,
188195
createFile, readFile, readTextFile, newProject, clearAll, editDetails, undo, redo,
189196
openShareModal, openSettingModal, viewHistory, resetAfterClear,
190-
toggleServer,
197+
toggleServer, optionModalToggle,
191198
};

0 commit comments

Comments
 (0)