From 21f2f94360a36ae8b58fe182a81cad99588d96b5 Mon Sep 17 00:00:00 2001 From: GREENRAT-K405 Date: Fri, 24 Apr 2026 11:20:19 +0530 Subject: [PATCH 1/2] auto-fill Contribute form from active graph metadata --- src/component/modals/ContributeDetails.jsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/component/modals/ContributeDetails.jsx b/src/component/modals/ContributeDetails.jsx index 8f4649d..0131c61 100644 --- a/src/component/modals/ContributeDetails.jsx +++ b/src/component/modals/ContributeDetails.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { toast } from 'react-toastify'; import axios from 'axios'; import { EXECUTION_ENGINE_URL } from '../../serverCon/config'; @@ -10,13 +10,25 @@ const ContributeDetails = ({ 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 curGraph = superState.graphs[superState.curGraphIndex] ?? {}; + + const [study, setStudy] = useState(curGraph.projectName ?? ''); + const [path, setPath] = useState(superState.uploadedDirName ?? ''); + const [auth, setAuth] = useState(curGraph.authorName ?? ''); const [title, setTitle] = useState(''); const [desc, setDesc] = useState(''); const [branch, setBranch] = useState(''); const [showAdvanceOptions, setShowAdvanceOptions] = useState(false); + + useEffect(() => { + if (superState.contributeModal) { + const activeGraph = superState.graphs[superState.curGraphIndex] ?? {}; + setStudy(activeGraph.projectName ?? ''); + setPath(superState.uploadedDirName ?? ''); + setAuth(activeGraph.authorName ?? ''); + } + }, [superState.contributeModal]); const submit = async (e) => { if (study === '' || path === '' || auth === '') { toast.info('Please Provide necessary inputs'); From 941ad357920501bb5501853df33043c9bb22e5d8 Mon Sep 17 00:00:00 2001 From: GREENRAT-K405 Date: Fri, 24 Apr 2026 11:39:20 +0530 Subject: [PATCH 2/2] improve react hygine in contribute details section --- src/component/modals/ContributeDetails.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/component/modals/ContributeDetails.jsx b/src/component/modals/ContributeDetails.jsx index 0131c61..d718b68 100644 --- a/src/component/modals/ContributeDetails.jsx +++ b/src/component/modals/ContributeDetails.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { toast } from 'react-toastify'; import axios from 'axios'; import { EXECUTION_ENGINE_URL } from '../../serverCon/config'; @@ -20,15 +20,26 @@ const ContributeDetails = ({ superState, dispatcher }) => { const [desc, setDesc] = useState(''); const [branch, setBranch] = useState(''); const [showAdvanceOptions, setShowAdvanceOptions] = useState(false); + const prevOpenRef = useRef(false); useEffect(() => { - if (superState.contributeModal) { + if (superState.contributeModal && !prevOpenRef.current) { const activeGraph = superState.graphs[superState.curGraphIndex] ?? {}; setStudy(activeGraph.projectName ?? ''); setPath(superState.uploadedDirName ?? ''); setAuth(activeGraph.authorName ?? ''); + setTitle(''); + setDesc(''); + setBranch(''); + setShowAdvanceOptions(false); } - }, [superState.contributeModal]); + prevOpenRef.current = superState.contributeModal; + }, [ + superState.contributeModal, + superState.graphs, + superState.curGraphIndex, + superState.uploadedDirName, + ]); const submit = async (e) => { if (study === '' || path === '' || auth === '') { toast.info('Please Provide necessary inputs');