-
Notifications
You must be signed in to change notification settings - Fork 2.1k
initial run state change dialog #17704
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
Conversation
6414a7c to
d1f5509
Compare
flow-run-state-dialogued1f5509 to
2fc1660
Compare
2fc1660 to
586d5c7
Compare
40fc18d to
18dea08
Compare
CodSpeed Performance ReportMerging #17704 will not alter performanceComparing Summary
|
ui-v2/src/components/flow-runs/flow-run-state-dialog/use-flow-run-state-dialog.tsx
Outdated
Show resolved
Hide resolved
ui-v2/src/components/ui/run-state-change-dialog/run-state-change-dialog.tsx
Show resolved
Hide resolved
ui-v2/src/components/flow-runs/flow-run-state-dialog/use-flow-run-state-dialog.tsx
Outdated
Show resolved
Hide resolved
ui-v2/src/components/ui/run-state-change-dialog/run-state-change-dialog.tsx
Outdated
Show resolved
Hide resolved
ui-v2/src/components/ui/run-state-change-dialog/run-state-change-dialog.tsx
Outdated
Show resolved
Hide resolved
| export const useFlowRunStateDialog = () => { | ||
| const [open, setOpen] = useState(false); | ||
| const [flowRun, setFlowRun] = useState<FlowRun | null>(null); | ||
| const { mutateAsync: setFlowRunState } = useSetFlowRunState(); |
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.
| const { mutateAsync: setFlowRunState } = useSetFlowRunState(); | |
| const { setFlowRunState } = useSetFlowRunState(); |
suggestion: use the mutate version setFlowRunState
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.
done! 927ee96
927ee96 to
38e6e55
Compare
| setOpen(true); | ||
| }, []); | ||
|
|
||
| return { |
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.
IMO this return logic makes it complex because this hook will only work if flowRun.state is truthy, (which makes this hook do nothing.).
IMO it be more straightforward if you do something like:
{open && flowRun.state && flowRun.id && <FlowRunDialog id={flowRun.id} state ={flowRun.state} />}
and declare the mutations in the dialog
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.
disclaimer, just thinking out loud so that if I'm harboring any misunderstanding, it can be corrected!
it seems like this would suggest not having a general run state dialog component, is that right?
I see how using mutate fits if the mutation logic is directly inside the dialog component itself. I had initially separated it out into the reusable RunStateChangeDialog and useFlowRunStateDialog hook after talking w @desertaxle where he suggested a generic RunStateChangeDialog to live in src/components/ui
Since the RunStateChangeDialog awaits the onSubmitChange callback to manage its loading state, I was thinking the hook needed to provide a promise, so i used mutateAsync.
totally possible I'm just too fresh here and I'm only perceiving contention between the suggestions!
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.
I think your use of mutateAsync is valid since react-hook-form needs a promise to handle the isSubmitting state, and I think the form being agnostic to the mutation is important for reuse between flow runs and task runs.
I think we can simplify this return statement, but it'll be easier to talk about than to write it out, so let's sync up offline.
38e6e55 to
9c07a77
Compare
| const [open, setOpen] = useState(false); | ||
| const [flowRun, setFlowRun] = useState<FlowRun | null>(null); |
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.
nit: Isn't the the dialog being open derived from the flowRun state being set? Is the open state redundant?
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.
I did this because onOpenChange (which closes the dialog) just sets open to false without clearing the flowRun state variable inside the hook
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.
If you want to use that. Then does flowRun need to be a state? Can't that just be passed as a props?
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.
I kept the flowRun state in the hook to encapsulate all the dialog's context there, in my mind making it simpler for the parent component to just call openDialog but if this
Can't that just be passed as a props
would be preferred, I'm happy to make that change
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.
Ya, I think that would help simplify things
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.
cool, should be done in b3ae5d8!
| import { RunStateChangeDialog } from "@/components/ui/run-state-change-dialog"; | ||
| import { useFlowRunStateDialog } from "./use-flow-run-state-dialog"; | ||
|
|
||
| interface FlowRunStateDialogProps { |
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.
| interface FlowRunStateDialogProps { | |
| type FlowRunStateDialogProps { |
merge conflict
fix typing
e5d1761 to
001f822
Compare
rm old things
b26dd05 to
954d814
Compare
follow up to #17713 and #17743 that adds a generalized component for changing flow or task run states
flow-run-state-dialogue.mov