mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54:18 +00:00
Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
8b2080b8cd
3 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
</Button>
|
||||
|
@ -88,6 +90,7 @@ export default function BoxRepositoryCreate({ ...props }) {
|
|||
icon={faPencilAlt}
|
||||
color={"Green"}
|
||||
onClick={_ => goToOnSuccess(save, history, "/repositories")()}
|
||||
disabled={running}
|
||||
>
|
||||
Salva modifiche
|
||||
</Button>
|
||||
|
@ -98,6 +101,7 @@ export default function BoxRepositoryCreate({ ...props }) {
|
|||
icon={faPlus}
|
||||
color={"Green"}
|
||||
onClick={_ => goToOnSuccess(save, history, "/repositories")()}
|
||||
disabled={running}
|
||||
>
|
||||
Crea repository
|
||||
</Button>
|
||||
|
|
|
@ -147,7 +147,7 @@ export default function RepositoryEditor({
|
|||
<BoxConditionUser className={Style.SearchByUser}/>
|
||||
<BoxConditionDatetime className={Style.SearchByTimePeriod}/>
|
||||
<BoxConditions className={Style.Conditions}/>
|
||||
<BoxRepositoryCreate className={Style.CreateDialog}/>
|
||||
<BoxRepositoryCreate running={loading} className={Style.CreateDialog}/>
|
||||
</div>
|
||||
</ContextRepositoryEditor.Provider>
|
||||
)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue