Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
flyteorg/flyte#22
There will be a follow-up PR for unit tests. This is against a feature branch, so it doesn't need to be 100% complete to merge
inputConverters
toinputHelpers
and moved them into a separate folder with a file for each type. Input helpers export functionality for validating values as well as converting them toILiteral
s for submission.useLaunchWorkflowFormState
into a separate hook. The form state hook will communicate with the input state hook (to get values when submitting) via a ref.useFetchable
not fully resetting state when its cache key changes. This was causing any submission errors to persist after changing the workflow/launch plan.getCacheKey
can now also accept an arrayNote
The input rendering was moved into a separate component so that I could take advantage of component lifecycle to do something a little strange.
The logic for managing input values and validation gets a lot easier if each input is managed by its own nested state hook. However, the list of inputs is dynamic and changes every time the workflow/launch plan combination changes. This means that something like
inputs.map(input => useInputState(input))
will cause problems if the value ofinputs
changes at all within the same instance of a component.The solution I landed on was to generate a
key
value that's based on hashing the array of inputs, and use that with the component that renders the inputs. This has the effect of creating a new instance of the component any time the list of inputs changes. And it means that themap
we do will be guaranteed to run on the same list of inputs, in the same order, and result in the same ordering of hooks calls.