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 1881881: Replace route dropdown input with typeahead select menu in import/edit flow #6719

Merged
merged 1 commit into from Oct 22, 2020

Conversation

rottencandy
Copy link
Contributor

@rottencandy rottencandy commented Sep 23, 2020

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

Analysis / Root cause:
The dropdown only allows for the selection of the exposed ports from the builder image.

Solution Description:
The user should have the ability to specify their target port to ensure the route works.
Relevant Slack thread: https://coreos.slack.com/archives/CHC2R6AGG/p1600757882002000

Screen shots / Gifs for design review:
tmp
tmp
cc: @openshift/team-devconsole-ux

Unit test coverage report:
Unchanged.

Test setup:

  • Navigate to +Add -> From git
  • Fill form, select Routing in advanced options
  • Notice the port input field provides typeahead for default ports, and also allows adding a custom port.

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot
Copy link
Contributor

@rottencandy: This pull request references Bugzilla bug 1881881, which is invalid:

  • expected the bug to target the "4.6.0" release, but it targets "4.7.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1881881: Replace route dropdown input with typeahead select menu in Git flow

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.

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Sep 23, 2020
@rottencandy
Copy link
Contributor Author

/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 23, 2020
@rottencandy
Copy link
Contributor Author

/cc @christianvogt

@openshift-ci-robot
Copy link
Contributor

@rottencandy: This pull request references Bugzilla bug 1881881, which is invalid:

  • expected the bug to target the "4.6.0" release, but it targets "4.7.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1881881: Replace route dropdown input with typeahead select menu in Git flow

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.

);
return acc;
}, {});
const portOptions = ports.map((port) => port.containerPort);
Copy link
Member

Choose a reason for hiding this comment

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

When you convert the ports here to strings the Select automatically matches the user input and do not show "Create "8080"" if the option is already available. Wdyt?

Suggested change
const portOptions = ports.map((port) => port.containerPort);
const portOptions: string[] = ports.map((port) => port.containerPort.toString());

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Not sure if there is something we can do about the "Create ..." option, even the Patternfly demos behave the same way: https://www.patternfly.org/v4/documentation/react/components/select#typeahead

Copy link
Member

Choose a reason for hiding this comment

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

Okay, thanks for revalidating this. I though that the .toString() solves this issue.


const CreateRoute: React.FC = () => {
const {
values: {
image: { ports },
route: { defaultUnknownPort, targetPort },
route: { defaultUnknownPort },
},
} = useFormikContext<FormikValues>();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} = useFormikContext<FormikValues>();
} = useFormikContext<DeployImageFormData | GitImportFormData>();

Adding this types so that the ports and defaultUnknownPort vars are typed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, didn't know we could do that. Now I'm wondering why we even use FormikValues type :P.

@jerolimov
Copy link
Member

@rottencandy Technical this works fine, I have added two comments to the code. I also want ask you if you want rename your new component from import/route/RouteInputField to import/route/PortInputField. For me this matches more the special case it handles here.

In this case a port validation 1-65535 would be also a good idea. It's not required, but I missed this when entering some invalid numbers.

Wdyt?

@rottencandy
Copy link
Contributor Author

@rottencandy Technical this works fine, I have added two comments to the code. I also want ask you if you want rename your new component from import/route/RouteInputField to import/route/PortInputField. For me this matches more the special case it handles here.

Thanks for the review @jerolimov , Renamed to PortInputField.

In this case a port validation 1-65535 would be also a good idea. It's not required, but I missed this when entering some invalid numbers.

Currently we do the validation using a regex(/^\d+$/), I wasn't able to find a way to check for a maximum number using regex.

@jerolimov
Copy link
Member

Currently we do the validation using a regex(/^\d+$/)

We could use a number check similar to this instead of regex for the unknownTargetPort validation scheme:

const portValidationSchema = yup
  .number()
  .typeError('Port must be an Integer.')
  .integer('Port must be an Integer.')
  .min(1, 'Port must be between 1 and 65535.')
  .max(65535, 'Port must be between 1 and 65535.');

Didn't know the typeError check before. It was the message if you enter "asd". Integer ensures that user could not enter "3.1415". Wdyt? Is it worth to update the PR again? :)

@rottencandy
Copy link
Contributor Author

We could use a number check similar to this instead of regex for the unknownTargetPort validation scheme:

const portValidationSchema = yup
  .number()
  .typeError('Port must be an Integer.')
  .integer('Port must be an Integer.')
  .min(1, 'Port must be between 1 and 65535.')
  .max(65535, 'Port must be between 1 and 65535.');

Didn't know the typeError check before. It was the message if you enter "asd". Integer ensures that user could not enter "3.1415". Wdyt? Is it worth to update the PR again? :)

Updated.

@jerolimov
Copy link
Member

/retest

@rottencandy
Copy link
Contributor Author

Updated to behave the same way when selecting Knative Service.

@rottencandy rottencandy changed the title Bug 1881881: Replace route dropdown input with typeahead select menu in Git flow Bug 1881881: Replace route dropdown input with typeahead select menu in import/edit flow Sep 30, 2020
@jerolimov
Copy link
Member

jerolimov commented Sep 30, 2020

Hmm, I'm really sorry but could not verify this issue. I tried to set a custom port for the route and select "Knative Service" as Deployment. The created Route has not set the port anywhere.

Then I tried this on master, and changed ServerlessRouteSection.tsx so that the <InputField name="route.unknownTargetPort" ... was always used. And the Route does not contain the entered port in this case as well. Only when selecting a port from the Dropdown (on master) the value was set in the Route correctly. So maybe this is already an issue before? @invincibleJai what do you think?

@rottencandy Unfortunately, I'm now thinking about the unifying between two different cases. Before we have <InputField name="route.unknownTargetPort" ... OR <DropdownField name="route.targetPort" .... But with this PR we always use the unknownTargetPort. If we have no other reason to keep targetPort which I maybe oversee at the moment, we should maybe simplify the complete createRoute algorithm and should always use only one variable / form field here? 🤔

@invincibleJai
Copy link
Member

/assign

@rottencandy
Copy link
Contributor Author

rottencandy commented Oct 1, 2020

@jerolimov The knative service function prioritized targetPort over unknownTargetPort, which is why it was never using the entered port, I've updated it to use unknownTargetPort when available.

AFAIK, targetPort is mainly being used in two places:

  • In the edit flow, when user does not intend to change port, targetPort will be set as the existing port value(in full format eg.8080-tcp).
  • In the image stream search fields, both internal & external fields set targetPort to the first of available ports, not sure why it is being set here.

@christianvogt
Copy link
Contributor

One more small issue:

  • import from git https://github.com/nodeshift-starters/react-web-ap and set port to 3000
  • from topology right click the deployment and select edit <mydeployment>
  • open the routing advanced section
  • click the x in the target port text field
  • observe the placeholder shows 8080
  • complete the form
  • if you navigate to the route associated with this deployment, the port remains as 3000-tcp

@rottencandy
Copy link
Contributor Author

One more small issue:

* import from git `https://github.com/nodeshift-starters/react-web-ap` and set port to 3000

* from topology right click the deployment and select `edit <mydeployment>`

* open the routing advanced section

* click the `x` in the target port text field

* observe the placeholder shows `8080`

* complete the form

* if you navigate to the route associated with this deployment, the port remains as `3000-tcp`

Fixed.

@rottencandy
Copy link
Contributor Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Oct 5, 2020
@openshift-ci-robot
Copy link
Contributor

@rottencandy: This pull request references Bugzilla bug 1881881, 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.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state ASSIGNED, 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.

@rottencandy
Copy link
Contributor Author

/retest

2 similar comments
@rottencandy
Copy link
Contributor Author

/retest

@rottencandy
Copy link
Contributor Author

/retest

@debsmita1
Copy link
Contributor

One more small issue:

* import from git `https://github.com/nodeshift-starters/react-web-ap` and set port to 3000

* from topology right click the deployment and select `edit <mydeployment>`

* open the routing advanced section

* click the `x` in the target port text field

* observe the placeholder shows `8080`

* complete the form

* if you navigate to the route associated with this deployment, the port remains as `3000-tcp`

Fixed.

@rottencandy I could reproduce the above issue for knative service workload. Have a look at the gif below:
port

@rottencandy
Copy link
Contributor Author

Updated edit flow to use defaultUnknownPort when port is input is cleared.

@debsmita1
Copy link
Contributor

verified this locally
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 20, 2020
@jerolimov
Copy link
Member

/retest

@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bgliwa01, christianvogt, debsmita1, rottencandy, 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 Oct 21, 2020
@openshift-merge-robot openshift-merge-robot merged commit cf36763 into openshift:master Oct 22, 2020
@openshift-ci-robot
Copy link
Contributor

@rottencandy: All pull requests linked via external trackers have merged:

Bugzilla bug 1881881 has been moved to the MODIFIED state.

In response to this:

Bug 1881881: Replace route dropdown input with typeahead select menu in import/edit flow

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.7 milestone Oct 26, 2020
@rottencandy
Copy link
Contributor Author

/cherrypick release-4.6

@openshift-cherrypick-robot

@rottencandy: new pull request created: #7064

In response to this:

/cherrypick release-4.6

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.

@rottencandy rottencandy deleted the routeinput branch December 7, 2020 14:32
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/knative Related to knative-plugin kind/bug Categorizes issue or PR as related to a bug. 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