Simplify IpPoolSelector and call sites#3032
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fe4f244 to
688f05e
Compare
| setValue(ipVersionFieldName, selectedPool.ipVersion) | ||
| } | ||
| } | ||
| }, [currentPool, sortedPools, ipVersionFieldName, setValue]) |
There was a problem hiding this comment.
this is not necessary at all if you derive it at submit time
| ipVersionFieldName, | ||
| setValue, | ||
| autoSelectDefault, | ||
| ]) |
There was a problem hiding this comment.
I think this is only really necessary for instance create because that's the only one where the stack can change. We calculate it for ephemeral IP modal but we can do it once up front because it's in the context of an instance where the stack is fixed.
| type: 'auto', | ||
| // v4 fallback here should maybe be an error instead because | ||
| // it probably won't work on the API side | ||
| ipVersion: hasV4Default ? 'v4' : hasV6Default ? 'v6' : 'v4', |
There was a problem hiding this comment.
Note v4 fallback where when there are no defaults doesn't really make sense because auto will fail in that case. What we should do is make the user pick. The simplest thing would be to always make the user pick and just not use the auto side here.
There was a problem hiding this comment.
I believe this is now how you have it, where the form is disabled with the No default compatible pool available; select a pool to continue message, so I don't know that anyone is going to end up hitting this.
There was a problem hiding this comment.
Ah, that's right. Insight applied here for more cleanup 72b671a
IpPoolSelectoris used on instance create, floating IP create, and ephemeral IP attach, but most of the logic inside only applied to instance create. Here I:IpPoolSelectorand into instance create (the only call site that cares)ipVersionFieldName,currentPool, andsetValueuseEffects and intouseFormdefaultValuesuseQueryipVersionat submit time instead of keeping track of it in the form stateI don't think any actual behavior should change here.