-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add recover option to workflows (#192)
* feat: add recover button to console Signed-off-by: csirius <[email protected]> * fix: unit testing wrapper to have react query provider Signed-off-by: csirius <[email protected]>
- Loading branch information
Showing
5 changed files
with
115 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/Executions/ExecutionDetails/useRecoverExecutionState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useAPIContext } from 'components/data/apiContext'; | ||
import { useContext } from 'react'; | ||
import { useMutation } from 'react-query'; | ||
import { ExecutionContext } from '../contexts'; | ||
import { WorkflowExecutionIdentifier } from 'models/Execution/types'; | ||
|
||
export function useRecoverExecutionState() { | ||
const { recoverWorkflowExecution } = useAPIContext(); | ||
const { | ||
execution: { id } | ||
} = useContext(ExecutionContext); | ||
|
||
const { mutate, ...recoverState } = useMutation< | ||
WorkflowExecutionIdentifier, | ||
Error | ||
>(async () => { | ||
const { id: recoveredId } = await recoverWorkflowExecution({ id }); | ||
if (!recoveredId) { | ||
throw new Error('API Response did not include new execution id'); | ||
} | ||
return recoveredId as WorkflowExecutionIdentifier; | ||
}); | ||
|
||
const recoverExecution = () => mutate(); | ||
|
||
return { | ||
recoverState, | ||
recoverExecution | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters