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

Bug 1829445: Fixes: Container image does not validate dynamically #5231

Merged

Conversation

sahil143
Copy link
Contributor

Fixes: https://issues.redhat.com/browse/ODC-3178

Analysis / Root cause:

container image validation only happens on blur, which caused some issue

Solution Description:

enable image validation while user types

Screen shots / Gifs for design review:

container-image

Unit test coverage report:

Test setup:

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/shared Related to console-shared labels Apr 29, 2020
@sahil143 sahil143 changed the title Fixes: Container image does not validate dynamically Bug 1829445: Fixes: Container image does not validate dynamically Apr 29, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Apr 29, 2020
@openshift-ci-robot
Copy link
Contributor

@sahil143: This pull request references Bugzilla bug 1829445, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1829445: Fixes: Container image does not validate dynamically

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

kind: 'DockerImage',
name: _.trim(searchTermImage),
const handleSearch = React.useCallback(
_.debounce((newValues: any) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: type here

@@ -151,8 +136,8 @@ const ImageSearch: React.FC = () => {
helpText={getHelpText()}
helpTextInvalid={helpTextInvalid}
validated={validated}
onBlur={() => {
handleSearch();
onKeyUp={() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use onChange here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -125,10 +120,6 @@ const ImageSearch: React.FC = () => {
<span>{values.searchTerm === '' ? 'Required' : values.isi.status?.message}</span>
);

React.useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would break edit application scenario. We need this logic here.

onBlur={() => {
handleSearch();
onChange={(e: KeyboardEvent) => {
handleSearch((e.target as HTMLInputElement).value);
setFieldTouched('searchTerm', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure you don't need to do that now since default onBlur on the field will handle this.


const handleSave = (name: string) => {
setNewImageSecret(name);
values.searchTerm && handleSearch();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is being used to trigger the validation again when a pull secret is added. So we need this one as well.

@rohitkrai03
Copy link
Contributor

/assign

@christianvogt
Copy link
Contributor

The gif looks odd to me.
Firstly you are typing fairly quick and yet it still started validating.

Secondly as soon as the user inputs a value which no longer matches that which is currently validating or that which has already errored I think that the helper text should be cleared immediately.

Please involve UX for approval.

@sahil143
Copy link
Contributor Author

sahil143 commented May 6, 2020

/cc @serenamarie125 @beaumorley @openshift/team-devconsole-ux

@sahil143
Copy link
Contributor Author

sahil143 commented May 6, 2020

updated Gif
validate-2

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
Copy link
Contributor

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

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

This looks great thanks @sahil143 !

@christianvogt
Copy link
Contributor

/lgtm cancel

I can submit the form after immediately changing the image name to something that is invalid. The form submits with the previous valid value.

The field state should be immediately invalidated on change of the image name value.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
@sahil143
Copy link
Contributor Author

sahil143 commented May 7, 2020

/lgtm cancel

I can submit the form after immediately changing the image name to something that is invalid. The form submits with the previous valid value.

The field state should be immediately invalidated on change of the image name value.

Fixed. @christianvogt Please review again

@christianvogt
Copy link
Contributor

@sahil143 while the create button is properly disabled, the helper text remains while typing. This helper text should also be cleared.
image

@sahil143
Copy link
Contributor Author

sahil143 commented May 7, 2020

@sahil143 while the create button is properly disabled, the helper text remains while typing. This helper text should also be cleared.
image

fixed!

Copy link
Contributor

@christianvogt christianvogt left a comment

Choose a reason for hiding this comment

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

I also noticed that after entering a valid image, then changing to a new valid image, the old app name and name values remain which no longer coincide with the new image. They should be modified again if the user never touched those fields. I'm ok if we tackle this in a new issue though

handleSearch();
setFieldTouched('searchTerm', true);
onChange={(e: KeyboardEvent) => {
setFieldValue('disableSubmit', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't think this field is necessary. We were able to have a disabled submit button without it. You should be resetting the values previously set by the error or success conditions. See what is done in the catch of the search.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

disabled submit button is based on only two props i.e. dirty and errors. Not sure how we can disable the button based on these and in catch block we are only setting the image stream data to empty values and error.

Copy link
Contributor

Choose a reason for hiding this comment

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

The submit button disabled state is controlled by the validation of the form data. By deleting the required image values the form will be in an invalid state, thereby disabling the submit button.

By not having a valid image, the submit button will be disabled. So setting the values back to empty (as they were on initializing the form) and any other state necessary, we get the desired outcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove the disableSubmit prop from everywhere and here we can set setFieldValue('isi', {}); so the form will be disabled when user starts to type and if there is no valid image in the isi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

@sahil143
Copy link
Contributor Author

sahil143 commented May 8, 2020

I also noticed that after entering a valid image, then changing to a new valid image, the old app name and name values remain which no longer coincide with the new image. They should be modified again if the user never touched those fields. I'm ok if we tackle this in a new issue though

fixed! added a method to reset the fields based on form type

@abhi-kn
Copy link
Contributor

abhi-kn commented May 8, 2020

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. and removed bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. labels May 8, 2020
@openshift-ci-robot
Copy link
Contributor

@abhi-kn: This pull request references Bugzilla bug 1829445, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 8, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: beaumorley, christianvogt, rohitkrai03, sahil143, serenamarie125

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2020
@openshift-merge-robot openshift-merge-robot merged commit b1ee685 into openshift:master May 9, 2020
@openshift-ci-robot
Copy link
Contributor

@sahil143: All pull requests linked via external trackers have merged: openshift/console#5231. Bugzilla bug 1829445 has been moved to the MODIFIED state.

In response to this:

Bug 1829445: Fixes: Container image does not validate dynamically

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.5 milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet