diff --git a/nest_frontend/components/interactive/BoxRepositoryCreate.js b/nest_frontend/components/interactive/BoxRepositoryCreate.js index 9e63c57..b46f1f6 100644 --- a/nest_frontend/components/interactive/BoxRepositoryCreate.js +++ b/nest_frontend/components/interactive/BoxRepositoryCreate.js @@ -15,11 +15,12 @@ import { useHistory } from "react-router" /** * A {@link BoxFull} allowing the user to save the changes made in the current {@link RepositoryEditor}. * - * @param props + * @param running - If a request is running, disabling the buttons. + * @param props - Additional props to pass to the box. * @returns {JSX.Element} * @constructor */ -export default function BoxRepositoryCreate({ ...props }) { +export default function BoxRepositoryCreate({ running, ...props }) { const { id, evaluationMode, @@ -80,6 +81,7 @@ export default function BoxRepositoryCreate({ ...props }) { icon={faBackward} color={"Red"} onClick={() => revert()} + disabled={running} > Annulla modifiche @@ -88,6 +90,7 @@ export default function BoxRepositoryCreate({ ...props }) { icon={faPencilAlt} color={"Green"} onClick={_ => goToOnSuccess(save, history, "/repositories")()} + disabled={running} > Salva modifiche @@ -98,6 +101,7 @@ export default function BoxRepositoryCreate({ ...props }) { icon={faPlus} color={"Green"} onClick={_ => goToOnSuccess(save, history, "/repositories")()} + disabled={running} > Crea repository diff --git a/nest_frontend/components/providers/RepositoryEditor.js b/nest_frontend/components/providers/RepositoryEditor.js index 51b940b..248b00a 100644 --- a/nest_frontend/components/providers/RepositoryEditor.js +++ b/nest_frontend/components/providers/RepositoryEditor.js @@ -147,7 +147,7 @@ export default function RepositoryEditor({ - + ) diff --git a/nest_frontend/utils/goToOnSuccess.js b/nest_frontend/utils/goToOnSuccess.js index 23388c0..2095a28 100644 --- a/nest_frontend/utils/goToOnSuccess.js +++ b/nest_frontend/utils/goToOnSuccess.js @@ -7,16 +7,17 @@ * @returns {(function(): void)|*} */ export default function goToOnSuccess(func, history, destination) { - return (...args) => { + return async (...args) => { let result try { - console.debug("Provando ad eseguire: ", func) - result = func(...args) + console.debug("Executing: ", func) + result = await func(...args) + console.debug("Executed successfully: ", func, " moving to a different page.") history.push(destination) return result } catch(e) { - console.debug("Esecuzione fallita: ", func, ", non ha fatto nulla.") + console.debug("Execution failed: ", func, ", not doing anything.") throw e } }