1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 22:44:19 +00:00

Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Lorenzo Balugani 2021-05-17 16:20:23 +02:00
commit 8b2080b8cd
3 changed files with 12 additions and 7 deletions

View file

@ -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}. * 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} * @returns {JSX.Element}
* @constructor * @constructor
*/ */
export default function BoxRepositoryCreate({ ...props }) { export default function BoxRepositoryCreate({ running, ...props }) {
const { const {
id, id,
evaluationMode, evaluationMode,
@ -80,6 +81,7 @@ export default function BoxRepositoryCreate({ ...props }) {
icon={faBackward} icon={faBackward}
color={"Red"} color={"Red"}
onClick={() => revert()} onClick={() => revert()}
disabled={running}
> >
Annulla modifiche Annulla modifiche
</Button> </Button>
@ -88,6 +90,7 @@ export default function BoxRepositoryCreate({ ...props }) {
icon={faPencilAlt} icon={faPencilAlt}
color={"Green"} color={"Green"}
onClick={_ => goToOnSuccess(save, history, "/repositories")()} onClick={_ => goToOnSuccess(save, history, "/repositories")()}
disabled={running}
> >
Salva modifiche Salva modifiche
</Button> </Button>
@ -98,6 +101,7 @@ export default function BoxRepositoryCreate({ ...props }) {
icon={faPlus} icon={faPlus}
color={"Green"} color={"Green"}
onClick={_ => goToOnSuccess(save, history, "/repositories")()} onClick={_ => goToOnSuccess(save, history, "/repositories")()}
disabled={running}
> >
Crea repository Crea repository
</Button> </Button>

View file

@ -147,7 +147,7 @@ export default function RepositoryEditor({
<BoxConditionUser className={Style.SearchByUser}/> <BoxConditionUser className={Style.SearchByUser}/>
<BoxConditionDatetime className={Style.SearchByTimePeriod}/> <BoxConditionDatetime className={Style.SearchByTimePeriod}/>
<BoxConditions className={Style.Conditions}/> <BoxConditions className={Style.Conditions}/>
<BoxRepositoryCreate className={Style.CreateDialog}/> <BoxRepositoryCreate running={loading} className={Style.CreateDialog}/>
</div> </div>
</ContextRepositoryEditor.Provider> </ContextRepositoryEditor.Provider>
) )

View file

@ -7,16 +7,17 @@
* @returns {(function(): void)|*} * @returns {(function(): void)|*}
*/ */
export default function goToOnSuccess(func, history, destination) { export default function goToOnSuccess(func, history, destination) {
return (...args) => { return async (...args) => {
let result let result
try { try {
console.debug("Provando ad eseguire: ", func) console.debug("Executing: ", func)
result = func(...args) result = await func(...args)
console.debug("Executed successfully: ", func, " moving to a different page.")
history.push(destination) history.push(destination)
return result return result
} }
catch(e) { catch(e) {
console.debug("Esecuzione fallita: ", func, ", non ha fatto nulla.") console.debug("Execution failed: ", func, ", not doing anything.")
throw e throw e
} }
} }