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

prefer exacter matches of the vlanid when auto-selecting a related network #7901

Merged
merged 1 commit into from Nov 30, 2020

Conversation

LadyNamedLaura
Copy link
Contributor

Given that vlanid's are numbers there's a big difference between vlan 23 and vlan 123
With just the substring match foreman would easily confuse the 2.

Quick drive-by patch, will look if I have the time to go trough redmine and all later, unless somebody else does that for me.

This also still falls back to the substring match which I'm not sure is needed.

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

2 similar comments
@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@theforeman-bot
Copy link
Member

Can one of the admins verify this patch?

@theforeman-bot
Copy link
Member

Thank you for your contribution, @SimonPe! This PR has been inactive for 3 months, closing for now.
Feel free to reopen when you return to it. This is an automated process.

@ekohl
Copy link
Member

ekohl commented Nov 20, 2020

I think this is still relevant. @lzap any chance you can get to reviewing this or should we find someone else?

@ekohl ekohl reopened this Nov 20, 2020
lzap
lzap previously approved these changes Nov 25, 2020
Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

I am good with the code, but I have no VLAN CR networks to test with. Can I ask for a quick test @ezr-ondrej or @shiramax ? This only works with oVirt or VMware.

  • create a subnet with a VLAN ID set in Foreman
  • create a oVirt/VMWare network with VLAN ID in the name
  • the UI should pick the correct network automatically by finding the name
  • it should ignore false matches, e.g. VLAN 4 should not match 42

ezr-ondrej
ezr-ondrej previously approved these changes Nov 30, 2020
Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Works for me 👍
One change needed, but I'm ok to send a follow-up PR for that.

@@ -893,17 +893,30 @@ function selectRelatedNetwork(subnetElement) {
}

var selected = null;
// prefer a match of the vlanid bounded by non digits
// this prevent vlanId=1 from matching "vlan100"
var vlanidregex = new RegExp(`(^|\\D)(${vlanId})($|\\D)`)
Copy link
Member

Choose a reason for hiding this comment

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

I think we shouldn't use template in asset pipeline, as it works only since JS ES6 and we still support older platforms. And asset pipeline doesn't transpile through babel.

Suggested change
var vlanidregex = new RegExp(`(^|\\D)(${vlanId})($|\\D)`)
var vlanidregex = new RegExp("(^|\\D)" + vlanId + "($|\\D)");

Given that vlan ids are numbers there's a big difference between vlan 23 and vlan 123
With just the substring match foreman would easily confuse the 2.
This introduce a regexp matching for the VLANID and fullstring match only as a fallback.
@ezr-ondrej
Copy link
Member

ok to test

@ezr-ondrej
Copy link
Member

I've took the liberty to force push to this branch to fix the redmine ticket relation and to fix the use of templating (I didn't change the implementation at all, only addressed the concern of compatibility issue).
Thanks for the great addition @SimonPe and sorry for keeping you waiting :(

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @SimonPe and reviewers!

@lzap lzap merged commit 42a7404 into theforeman:develop Nov 30, 2020
@lzap
Copy link
Member

lzap commented Nov 30, 2020

Green so merged, thanks all.

@tbrisker
Copy link
Member

2.3 - 21d6ea7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Inactive Legacy JS PRs making changes in the legacy Javascript stack Needs testing
Projects
None yet
6 participants