-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Add taskgroup when uploading binary (#1280)
- Improve handling of taskgroup state by using contextAPI - Async create the taskgroup before uploading the custom binary in the single app use case. This is currently broken because we require a task group to exist before navigating to the upload file screen. This regression was caused by the move away from useEffect here #1267 Resolves https://issues.redhat.com/browse/MTA-1175 Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
435b73a
commit 8ce3163
Showing
6 changed files
with
111 additions
and
68 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
34 changes: 34 additions & 0 deletions
34
client/src/app/pages/applications/analysis-wizard/components/TaskGroupContext.tsx
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,34 @@ | ||
import { Taskgroup } from "@app/api/models"; | ||
import React, { createContext, useContext, useState } from "react"; | ||
|
||
interface TaskGroupContext { | ||
updateTaskGroup: (taskGroup: Taskgroup | null) => void; | ||
taskGroup: Taskgroup | null; | ||
} | ||
|
||
const TaskGroupContext = createContext<TaskGroupContext>({ | ||
updateTaskGroup: () => {}, | ||
taskGroup: null, | ||
}); | ||
|
||
export const useTaskGroup = () => useContext(TaskGroupContext); | ||
|
||
interface TaskGroupProvider { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const TaskGroupProvider: React.FunctionComponent<TaskGroupProvider> = ({ | ||
children, | ||
}) => { | ||
const [taskGroup, setTaskGroup] = useState<Taskgroup | null>(null); | ||
|
||
const updateTaskGroup = (newTaskGroup: Taskgroup | null) => { | ||
setTaskGroup(newTaskGroup); | ||
}; | ||
|
||
return ( | ||
<TaskGroupContext.Provider value={{ taskGroup, updateTaskGroup }}> | ||
{children} | ||
</TaskGroupContext.Provider> | ||
); | ||
}; |
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
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