From 5e3ef2078586aff1a5115c747a85c34c48007b9a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 17 May 2021 15:48:27 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Fix=20race=20condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/utils/goToOnSuccess.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 } } From 2b13ef41d6609f3fde025799fe1c5bd1b911dff1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 17 May 2021 15:58:24 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A7=20Use=20loading=20in=20BoxRepo?= =?UTF-8?q?sitoryCreate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/components/interactive/BoxRepositoryCreate.js | 5 ++++- nest_frontend/components/providers/RepositoryEditor.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nest_frontend/components/interactive/BoxRepositoryCreate.js b/nest_frontend/components/interactive/BoxRepositoryCreate.js index 9e63c57..c9997a0 100644 --- a/nest_frontend/components/interactive/BoxRepositoryCreate.js +++ b/nest_frontend/components/interactive/BoxRepositoryCreate.js @@ -19,7 +19,7 @@ import { useHistory } from "react-router" * @returns {JSX.Element} * @constructor */ -export default function BoxRepositoryCreate({ ...props }) { +export default function BoxRepositoryCreate({ running, ...props }) { const { id, evaluationMode, @@ -80,6 +80,7 @@ export default function BoxRepositoryCreate({ ...props }) { icon={faBackward} color={"Red"} onClick={() => revert()} + disabled={running} > Annulla modifiche @@ -88,6 +89,7 @@ export default function BoxRepositoryCreate({ ...props }) { icon={faPencilAlt} color={"Green"} onClick={_ => goToOnSuccess(save, history, "/repositories")()} + disabled={running} > Salva modifiche @@ -98,6 +100,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({ - + ) From 556cb327d2df0ec339cf84c5320073aae35b87ce Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 17 May 2021 16:11:58 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=94=20Document=20BoxRepositoryCrea?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/components/interactive/BoxRepositoryCreate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nest_frontend/components/interactive/BoxRepositoryCreate.js b/nest_frontend/components/interactive/BoxRepositoryCreate.js index c9997a0..b46f1f6 100644 --- a/nest_frontend/components/interactive/BoxRepositoryCreate.js +++ b/nest_frontend/components/interactive/BoxRepositoryCreate.js @@ -15,7 +15,8 @@ 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 */