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

Introduce field validation to Create container dialog #1354

Merged
merged 7 commits into from
Oct 18, 2023

Conversation

skobyda
Copy link
Contributor

@skobyda skobyda commented Jul 13, 2023

Fixes #609

This introduces both dynamic validation run with "onBlur" and static validation when form is submitted:

Dynamic validation

Screencast.from.2023-07-13.13-16-41.webm

On Form submit validation:

Screencast.from.2023-07-13.13-17-47.webm

Screenshot from 2023-07-13 13-15-12
Screenshot from 2023-07-13 13-15-01

@skobyda skobyda marked this pull request as draft July 13, 2023 11:15
@skobyda skobyda requested a review from garrett July 13, 2023 11:19
@marusak
Copy link
Member

marusak commented Jul 13, 2023

Not a review, just very quickly noticed on screenshot that you require everything but for example for ports that is not the case. From man pages: --publish, -p=[[ip:][hostPort]:]containerPort[/protocol]

Similarly for volumes you don't have to specify source. (Not sure if we want to support that 🤷‍♂️ )

Also when 'required' appears it breaks the [-] button alignment. And there is isRequired prop which adds * to fields, we should use that one as well.

@skobyda skobyda force-pushed the validateImageRun branch 4 times, most recently from 108e1b8 to 68cb803 Compare July 25, 2023 12:22
@skobyda
Copy link
Contributor Author

skobyda commented Jul 25, 2023

Not a review, just very quickly noticed on screenshot that you require everything but for example for ports that is not the case. From man pages: --publish, -p=[[ip:][hostPort]:]containerPort[/protocol]

Similarly for volumes you don't have to specify source. (Not sure if we want to support that man_shrugging )

Also when 'required' appears it breaks the [-] button alignment. And there is isRequired prop which adds * to fields, we should use that one as well.

Fixed

@garrett
Copy link
Member

garrett commented Aug 7, 2023

Please refer to the form design documentation:

https://www.patternfly.org/components/forms/form/design-guidelines/#errors-and-validation

  • Helper Text for error messages is not supposed to have icons, as there are icons in the forms
  • Be more descriptive than "required", when it's possible.
  • Are all of these actually required? There should be a few with some defaults, like the port. If you specify one, it should default to the other, I thought, as long as there is one port? IP address is optional too; I thought it'll default to 0.0.0.0 (localhost) when the entry is blank. If a value isn't needed, then we shouldn't show that it's required.
  • Anything that's required should be marked with a required asterisk. (I thought we did this. A few things have it already.)

An aside:

  • The - button is misaligned... and shouldn't be a secondary button; it should be a trash icon

@skobyda skobyda force-pushed the validateImageRun branch 2 times, most recently from fc6254f to 2489fce Compare August 30, 2023 11:20
@skobyda skobyda force-pushed the validateImageRun branch 2 times, most recently from a9f37bd to 9f74a06 Compare September 12, 2023 12:04
@skobyda
Copy link
Contributor Author

skobyda commented Sep 12, 2023

Updated the PR to use debounce, now just waiting for cockpit-project/cockpit#19251 to land

@skobyda skobyda force-pushed the validateImageRun branch 4 times, most recently from 607719f to b4c4a7e Compare October 10, 2023 11:04
@skobyda skobyda marked this pull request as ready for review October 10, 2023 11:04
@skobyda skobyda removed the blocked label Oct 10, 2023
@skobyda skobyda force-pushed the validateImageRun branch 7 times, most recently from 48971d2 to ce1ba8a Compare October 16, 2023 13:07
garrett
garrett previously approved these changes Oct 18, 2023
Copy link
Member

@garrett garrett left a comment

Choose a reason for hiding this comment

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

Looks good overall! Thanks!

I did find a couple of things that could be handled in follow-ups.


  1. Trash can icon is misaligned when there are elements pushing it vertically.

image

But this can be handled in a follow-up.


  1. I get an error of file not found in the autocomplete widget, but not as a message. Is this intended?

Screenshot from 2023-10-18 09-26-12

image

This can also be a follow-up.

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! I now see where you want to go with the field validation.

n_m needs a refresh for reposchutz, but we can ignore that for now, as it will bitrot exceedingly fast. Let's resolve the code issues first, and then we can refresh it as the last thing (we can even do this via the workflow now).

src/util.js Outdated Show resolved Hide resolved
src/PublishPort.jsx Outdated Show resolved Hide resolved
src/PublishPort.jsx Outdated Show resolved Hide resolved
src/ImageRunModal.jsx Outdated Show resolved Hide resolved
src/ImageRunModal.jsx Outdated Show resolved Hide resolved
src/PublishPort.jsx Show resolved Hide resolved
src/util.js Show resolved Hide resolved
src/ImageRunModal.jsx Outdated Show resolved Hide resolved
test/check-application Outdated Show resolved Hide resolved
src/ImageRunModal.jsx Show resolved Hide resolved
@skobyda skobyda force-pushed the validateImageRun branch 3 times, most recently from f50e3f7 to beb14b8 Compare October 18, 2023 09:57
src/ImageRunModal.jsx Fixed Show fixed Hide fixed
src/ImageRunModal.jsx Fixed Show fixed Hide fixed
@skobyda skobyda requested a review from martinpitt October 18, 2023 10:01
@skobyda skobyda force-pushed the validateImageRun branch 3 times, most recently from 001012e to 52a46fb Compare October 18, 2023 10:35
@martinpitt martinpitt temporarily deployed to npm-update October 18, 2023 10:38 — with GitHub Actions Inactive
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! A few remaining small issues, and I also had a look at the coverage report.

src/util.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/PublishPort.jsx Outdated Show resolved Hide resolved
src/Volume.jsx Outdated Show resolved Hide resolved
src/Env.jsx Outdated Show resolved Hide resolved
src/Env.jsx Show resolved Hide resolved
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.

🎉 Cheers!

break;
case "envValue":
break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

Comment on lines +35 to +36
if (!envKey || !envVar) {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 added lines are not executed by any test. Details

>
<TextInput id={id + "-value"}
value={item.envValue || ''}
validated={validationFailed?.envValue ? "error" : "default"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

validated={validationFailed?.envValue ? "error" : "default"}
onChange={(_event, value) => {
utils.validationClear(validationFailed, "envValue", onValidationChange);
utils.validationDebounce(() => onValidationChange({ ...validationFailed, envValue: validateEnvVar(value, "envValue") }));
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

const containerNameValidation = await this.validateContainerName(containerName);

if (containerNameValidation)
validationFailed.containerName = containerNameValidation;
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

{_("Create and run")}
</Button>
<Button variant='secondary' id="create-image-create-btn" onClick={() => this.onCreateClicked(false)} isDisabled={!image && selectedImage === ""}>
<Button variant='secondary' id="create-image-create-btn" onClick={() => this.onCreateClicked(false)} isDisabled={(!image && selectedImage === "") || this.isFormInvalid(dialogValues.validationFailed)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details


break;
}
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

return _("Container path must not be empty");

break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

@martinpitt martinpitt merged commit 332f835 into cockpit-project:main Oct 18, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate fields in run image dialog
5 participants