Skip to content
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

🪟🎉 Connector form: Use proper validation in array section #20725

Merged
merged 82 commits into from
Jan 3, 2023

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Dec 20, 2022

What

Fixes #20234

Screenshot 2022-12-20 at 17 03 30

How

Instead of holding the state of the modal form in a separate place, edit in in-place so formik validation just works.
In order to keep the form behind the UI stable and to be able to roll back on the user hitting the Cancel button, the ArraySection pulls the item in edit into a local state and renders the list of items based on that.

On submitting the modal form, that local state is thrown away.

Based on top of the refactoring PR because I was running into weird issues with the unit tests which do not occur after the refactoring.

Joe Reuter and others added 30 commits December 5, 2022 11:06
….module.scss

Co-authored-by: Tim Roes <tim@airbyte.io>
…irbytehq/airbyte into flash1293/connector-form-loading-state
@flash1293 flash1293 added area/frontend Related to the Airbyte webapp ui/connectors labels Dec 20, 2022
@octavia-squidington-iv octavia-squidington-iv added the area/platform issues related to the platform label Dec 20, 2022
@flash1293 flash1293 changed the title Connector builder: Use proper validation in array section 🪟🎉 Connector builder: Use proper validation in array section Dec 20, 2022
@flash1293 flash1293 changed the base branch from master to flash1293/connector-form-remove-ui-widget-state December 20, 2022 17:29
@flash1293 flash1293 marked this pull request as ready for review December 20, 2022 19:30
@flash1293 flash1293 requested a review from a team as a code owner December 20, 2022 19:30
@lmossman
Copy link
Contributor

This PR title probably shouldn't start with Connector builder:, since it is modifying ArraySection which the connector builder does not use. Did you mean ConnectorForm?

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple small comments but neither blocking, LGTM. Tested locally and seems to work as expected

onStartEdit={setEditIndex}
onStartEdit={(n) => {
setEditIndex(n);
setItemInEdit(items[n]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to create a copy of this?

Copy link
Contributor Author

@flash1293 flash1293 Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, formik takes care of not mutating any objects in the form values, it's always shallow-copying.

const [editIndex, setEditIndex] = useState<number>();
const [field, , fieldHelper] = useField<Array<Record<string, string>>>(path);
const [editIndex, setEditIndex] = useState<number | undefined>();
const [itemInEdit, setItemInEdit] = useState<Record<string, string> | undefined>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I thought itemInEdit contained the new value of the item, and it took me a bit to understand that this is the old value of the item from before it was edited.
Maybe a name like uneditedItem, oldItem, prevItem would make this a bit more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changed

@flash1293 flash1293 changed the title 🪟🎉 Connector builder: Use proper validation in array section 🪟🎉 Connector form: Use proper validation in array section Dec 21, 2022
@flash1293
Copy link
Contributor Author

Did you mean ConnectorForm

I did, but I typed connector builder too many times in the last two weeks.

Base automatically changed from flash1293/connector-form-remove-ui-widget-state to master January 3, 2023 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connector form: Apply validation in array item modal form
3 participants