-
Notifications
You must be signed in to change notification settings - Fork 13
Make it harder to forget to submit targets/filters subform #2634
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
What if instead of disabling the form completely we require a confirmation press? Like "You have an unsaved target entry, are you sure you want to continue?". The design would require a little work. |
I kind of like it feeling like a validation error and auto-scrolling to the offending field. In the confirmation version, I think you'd be curious what you left hanging, so you'd hit "no I don't want to continue" and go looking for it, which is the same thing with a lot more steps. Unless we put it right in the modal like "here, you dropped this", which is a weird thing to do, because if you do want to go back and add that thing, you still have to close the confirmation and go find it in the form. Implementation-wise, I think we can do a lot better than manually tracking the subform dirty states: we already have a canonical spot for that that state, namely the subforms. function useSubformsDirtyState() {
return {
target: !!useWatch({ control: targetControl, name: 'value' }).trim(),
host: !!useWatch({ control: hostControl, name: 'value' }).trim(),
port: !!useWatch({ control: portControl, name: 'portRange' }).trim(),
}
} This would require some refactoring because the console/app/forms/firewall-rules-common.tsx Lines 87 to 108 in 9de391c
This might be a little tough, though, because moving them up one level to console/app/forms/firewall-rules-common.tsx Lines 299 to 301 in 9de391c
isn't enough if what we need is to make the data available up here: ![]() Manually tracking the state is a reasonable hack but I'd rather just get the hierarchy right and have access to the source of truth where we need it. It wouldn't be a big deal to init all the subforms here next to the top level console/app/forms/firewall-rules-create.tsx Lines 106 to 139 in 9de391c
|
Summary: This PR makes it harder to accidentally drop firewall targets/filters when creating/editing a firewall.
Context: It is not uncommon that a user trying to set up a new firewall rule will accidentally submit the overall form without having fully submitted sub-elements — the target, port filter, or host filter — within the form. You can imagine a user having filled in the Targets part of the form below, then moving their attention to Filters (and beyond), not knowing that they haven't actually added the target to their firewall rule:

This PR updates the firewall rules form so that if any of the three subforms have data entered-but-not-submitted, the overall form has its submit function disabled, with copy in a tooltip that directs the user to the appropriate spot on the form

Still writing a few tests for it.
Closes #2627