diff --git a/package-lock.json b/package-lock.json index 6ff72b4..480e196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "axios": "^1.4.0", "chokidar": "^3.5.3", "cytoscape": "^3.19.0", "cytoscape-edgehandles": "^3.6.0", @@ -3124,6 +3125,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -7368,11 +7392,22 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], "engines": { "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } } }, "node_modules/for-in": { @@ -13072,6 +13107,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -21271,6 +21311,28 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.1.tgz", "integrity": "sha512-evY7DN8qSIbsW2H/TWQ1bX3sXN1d4MNb5Vb4n7BzPuCwRHdkZ1H2eNLuSh73EoQqkGKUtju2G2HCcjCfhvZIAA==" }, + "axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -24873,9 +24935,9 @@ } }, "follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==" + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" }, "for-in": { "version": "1.0.2", @@ -29563,6 +29625,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", diff --git a/package.json b/package.json index 716ed17..1f935e5 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "axios": "^1.4.0", "chokidar": "^3.5.3", "cytoscape": "^3.19.0", "cytoscape-edgehandles": "^3.6.0", diff --git a/src/App.jsx b/src/App.jsx index ffb631b..4345ca3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,6 +12,7 @@ import FileDragDrop from './component/File-drag-drop'; import HistoryModal from './component/modals/History'; import LocalFileBrowser from './component/fileBrowser'; import FileEditModal from './component/modals/FileEdit'; +import ContributeModal from './component/modals/ContributeDetails'; const app = () => { const [superState, dispatcher] = useReducer(reducer, initialState); @@ -21,6 +22,7 @@ const app = () => { + dispatcher({ type: T.Model_Close })} diff --git a/src/component/modals/ContributeDetails.jsx b/src/component/modals/ContributeDetails.jsx new file mode 100644 index 0000000..bbec1b3 --- /dev/null +++ b/src/component/modals/ContributeDetails.jsx @@ -0,0 +1,80 @@ +import React, { useState } from 'react'; +import axios from 'axios'; +import Modal from './ParentModal'; +import { actionType as T } from '../../reducer'; +import './contributeDetails.css'; + +const ContributeModal = ({ superState, dispatcher }) => { + const closeModal = () => { + dispatcher({ type: T.SET_CONTRIBUTE_MODAL, payload: false }); + }; + const [study, setStudy] = useState(''); + const [path, setPath] = useState(''); + const [auth, setAuth] = useState(''); + const [title, setTitle] = useState(''); + const [desc, setDesc] = useState(''); + const [branch, setBranch] = useState(''); + const submit = async (e) => { + try { + e.preventDefault(); + const result = await axios.post(`http://127.0.0.1:5000/contribute?study=${study}&auth=${auth}&desc=${desc}&title=${title}&path=${path}&branch=${branch}`); + console.log(result.data); + // eslint-disable-next-line + alert("Still in Development"); + closeModal(); + } catch (error) { + console.log(error); + } + }; + return ( + +
+ Study Name + setStudy(e.target.value)} + /> + Study Path + setPath(e.target.value)} + required + /> + Author Name + setAuth(e.target.value)} + required + /> + Branch Name + setBranch(e.target.value)} + required + /> + PR Title + setTitle(e.target.value)} + required + /> + PR Description + setDesc(e.target.value)} + required + /> +
+ +
+
+
+ ); +}; +export default ContributeModal; diff --git a/src/component/modals/contributeDetails.css b/src/component/modals/contributeDetails.css new file mode 100644 index 0000000..2ba3d25 --- /dev/null +++ b/src/component/modals/contributeDetails.css @@ -0,0 +1,20 @@ +.contribute-details{ + padding: 20px; + display: grid; + grid-template-columns: auto auto; + gap: 20px; +} + +.contribute-details *{ + padding: 10px 5px; + text-align: center; +} + +.contribute-details .expand{ + grid-column: 1 / span 2; + padding: 0; +} + +.contribute-details .btn{ + width: 100%; +} \ No newline at end of file diff --git a/src/reducer/actionType.js b/src/reducer/actionType.js index 0230c89..5e8b449 100644 --- a/src/reducer/actionType.js +++ b/src/reducer/actionType.js @@ -22,6 +22,7 @@ const actionType = { NEW_GRAPH: 'NEW_GRAPH', SET_SHARE_MODAL: 'SET_SHARE_MODAL', SET_SETTING_MODAL: 'SET_SETTING_MODAL', + SET_CONTRIBUTE_MODAL: 'SET_CONTRIBUTE_MODAL', SET_FILE_REF: 'SET_FILE_REF', SET_HISTORY_MODAL: 'SET_HISTORY_MODAL', SET_AUTHOR: 'SET_AUTHOR', diff --git a/src/reducer/initialState.js b/src/reducer/initialState.js index d09278b..0e840cf 100644 --- a/src/reducer/initialState.js +++ b/src/reducer/initialState.js @@ -13,6 +13,7 @@ const initialState = { settingsModal: false, editDetailsModal: false, newGraphModal: false, + contributeModal: false, eleSelected: false, drawModeOn: true, diff --git a/src/reducer/reducer.js b/src/reducer/reducer.js index d2c16e4..8788da4 100644 --- a/src/reducer/reducer.js +++ b/src/reducer/reducer.js @@ -64,6 +64,9 @@ const reducer = (state, action) => { }, }; } + case T.SET_CONTRIBUTE_MODAL: { + return { ...state, contributeModal: action.payload }; + } case T.Model_Close: return { ...state, ModelOpen: false }; case T.ELE_SELECTED: return { ...state, eleSelected: true, eleSelectedPayload: action.payload }; case T.ELE_UNSELECTED: return { ...state, eleSelected: false }; diff --git a/src/toolbarActions/toolbarFunctions.js b/src/toolbarActions/toolbarFunctions.js index da41975..311626c 100644 --- a/src/toolbarActions/toolbarFunctions.js +++ b/src/toolbarActions/toolbarFunctions.js @@ -139,6 +139,10 @@ const clearAll = (state) => { getGraphFun(state).clearAll(); }; +const contribute = (state, setState) => { + setState({ type: T.SET_CONTRIBUTE_MODAL, payload: true }); +}; + const editDetails = (state, setState) => { setState({ type: T.SET_EDIT_DETAILS_MODAL, @@ -177,5 +181,5 @@ export { createNode, editElement, deleteElem, downloadImg, saveAction, saveGraphMLFile, createFile, readFile, readTextFile, newProject, clearAll, editDetails, undo, redo, openShareModal, openSettingModal, viewHistory, - toggleServer, + toggleServer, contribute, }; diff --git a/src/toolbarActions/toolbarList.js b/src/toolbarActions/toolbarList.js index 9ba565e..2ec3150 100644 --- a/src/toolbarActions/toolbarList.js +++ b/src/toolbarActions/toolbarList.js @@ -12,7 +12,7 @@ import { import { createNode, editElement, deleteElem, downloadImg, saveAction, saveGraphMLFile, createFile, readFile, clearAll, undo, redo, openShareModal, viewHistory, - toggleServer, + toggleServer, contribute, // openSettingModal, } from './toolbarFunctions'; @@ -218,7 +218,7 @@ const toolbarList = (state, dispatcher) => [ type: 'action', text: 'Contribute', icon: FiTriangle, - action: () => { window.open('https://github.com/ControlCore-Project/concore-editor', '_blank'); }, + action: contribute, active: true, visibility: true, },