-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Add taskgroup when uploading binary #1280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
Check warning on line 23 in client/src/app/pages/applications/analysis-wizard/components/TaskGroupContext.tsx Codecov / codecov/patchclient/src/app/pages/applications/analysis-wizard/components/TaskGroupContext.tsx#L22-L23
|
||
|
||
const updateTaskGroup = (newTaskGroup: Taskgroup | null) => { | ||
setTaskGroup(newTaskGroup); | ||
Check warning on line 26 in client/src/app/pages/applications/analysis-wizard/components/TaskGroupContext.tsx Codecov / codecov/patchclient/src/app/pages/applications/analysis-wizard/components/TaskGroupContext.tsx#L25-L26
|
||
}; | ||
|
||
return ( | ||
<TaskGroupContext.Provider value={{ taskGroup, updateTaskGroup }}> | ||
{children} | ||
</TaskGroupContext.Provider> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only bit that looks suspicious to me under brain compile.
What happens if the taskGroup changes? Maybe something like from
undefined
to{ id: 5 }
?I'll run through some smoke tests in a bit. Maybe that will clear up my confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Fair concern. The taskgroup should always exist by the time the user arrives at the custom-rules step as it is created either 1) when onMove to step 2 of the wizard or 2) user uploads a binary on step 1 of the wizard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://react.dev/learn/reusing-logic-with-custom-hooks#passing-reactive-values-between-hooks
Ok so I'm not concerned about that anymore. 😄