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

lib: Add validation to DynamicListForm #19251

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

skobyda
Copy link
Contributor

@skobyda skobyda commented Aug 28, 2023

@skobyda skobyda force-pushed the validationDynamicListForm branch from b25ddde to fb5912c Compare August 28, 2023 10:59
@skobyda skobyda changed the title Add validation handlers do DynamicListForm lib: Add validation handlers do DynamicListForm Aug 28, 2023
@skobyda skobyda force-pushed the validationDynamicListForm branch from fb5912c to bf0fb9f Compare August 28, 2023 11:05
@skobyda skobyda requested a review from martinpitt August 29, 2023 08:56
@skobyda skobyda force-pushed the validationDynamicListForm branch from 53dcbde to bf0fb9f Compare August 29, 2023 08:59
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! As someone who has no context about this change, the API is a bit hard to grasp. Please document the data type, usage, and example of the new properties in a comment at the top.

pkg/lib/DynamicListForm.jsx Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
@skobyda skobyda force-pushed the validationDynamicListForm branch 2 times, most recently from 231c740 to a7edca6 Compare September 6, 2023 15:10
@skobyda
Copy link
Contributor Author

skobyda commented Sep 7, 2023

In the end I decided not to introduce some very abstract, general helper functions (as seen in previous version of the PR), because I realized they would be hard to understand and hard to mantain

@skobyda skobyda requested a review from martinpitt September 7, 2023 08:17
@skobyda skobyda force-pushed the validationDynamicListForm branch from a7edca6 to 017b61c Compare September 7, 2023 09:48
@martinpitt martinpitt changed the title lib: Add validation handlers do DynamicListForm lib: Add validation to DynamicListForm Sep 12, 2023
@martinpitt martinpitt added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Sep 12, 2023
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! The code looks okay, just the documentation could use some improvements. I added no-test, as this code isn't being used anywhere in cockpit -- so you can land it faster in the next round.

pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
pkg/lib/DynamicListForm.jsx Outdated Show resolved Hide resolved
@skobyda skobyda force-pushed the validationDynamicListForm branch from 017b61c to 5d572fe Compare September 18, 2023 10:05
@skobyda skobyda requested a review from martinpitt September 18, 2023 10:06
@skobyda skobyda force-pushed the validationDynamicListForm branch from 5d572fe to 8e33bf6 Compare September 18, 2023 10:06
@skobyda skobyda force-pushed the validationDynamicListForm branch from 8e33bf6 to 4720bc5 Compare September 19, 2023 09:06
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM now. I triggered the required test.

* [
* { name: "Name must not be empty }, // first row
* { }, // second row
* { name: "Name cannot containt number", email: "Email must contain '@'" } // third row
Copy link
Member

Choose a reason for hiding this comment

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

"contain"

validationFailed: validationFailed && validationFailed[idx],
onValidationChange: value => {
// Dynamic list consists of multiple rows. Therefore validationFailed object is presented as an array where each item represents a row
// Each row/item then consists of key-value pairs, which represent a field name and it's validation error
Copy link
Member

Choose a reason for hiding this comment

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

"its validation error"

@skobyda skobyda merged commit ae385d4 into cockpit-project:main Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-test For doc/workflow changes, or experiments which don't need a full CI run,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants