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
Fixes #21643 - fix and move nfs_visibilty.js to webpack #5002
Conversation
Issues: #21643 |
app/helpers/mediums_helper.rb
Outdated
|
||
def required_nfs_list | ||
Hash[Operatingsystem.families.map {|key| | ||
[key, key.constantize.require_nfs_access_to_medium]}].to_json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expression at 6, 58 should be on its own line.
app/helpers/mediums_helper.rb
Outdated
@@ -1,3 +1,8 @@ | |||
module MediumsHelper | |||
include PtablesHelper | |||
|
|||
def required_nfs_list | |||
Hash[Operatingsystem.families.map {|key| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using {...} for multi-line blocks.
app/helpers/mediums_helper.rb
Outdated
|
||
def required_nfs_list | ||
Hash[Operatingsystem.families.map {|key| | ||
[key, key.constantize.require_nfs_access_to_medium]}].to_json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expression at 6, 58 should be on its own line.
app/helpers/mediums_helper.rb
Outdated
@@ -1,3 +1,8 @@ | |||
module MediumsHelper | |||
include PtablesHelper | |||
|
|||
def required_nfs_list | |||
Hash[Operatingsystem.families.map {|key| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using {...} for multi-line blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments inline.
Also, IIRC there was some dead css code you can get rid of while you're here.
$('#nfs-section').show(); | ||
} else { | ||
$('#nfs-section').hide(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can make this a one liner:
$('#nfs-section').toggle(nfsRequired[osFamily.value]);
app/views/media/_form.html.erb
Outdated
@@ -17,18 +16,15 @@ | |||
<%= text_f f, :name %> | |||
<%= text_f f, :path, :size => "col-md-8", :help_block => _("The path to the medium, can be a URL or a valid NFS server (exclusive of the architecture). | |||
for example <em>http://mirror.centos.org/centos/$version/os/$arch</em> where <strong>$arch</strong> will be substituted for the host's actual OS architecture and <strong>$version</strong>, <strong>$major</strong> and <strong>$minor</strong> will be substituted for the version of the operating system. Solaris and Debian media may also use <strong>$release</strong>.").html_safe %> | |||
<span id="nfs-section" <%= display?(!@medium.operatingsystems.map(&:require_nfs_access_to_medium).any?) %>> | |||
<span id="nfs-section" <%= display?(!@medium.operatingsystems.map{ |obj| obj.class.require_nfs_access_to_medium }.any?) %>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work if the medium has solaris os_family but no operating systems assigned.
Why not also leverage the required_nfs_list
helper here?
p.s. you can use any?
with a block instead of .map{..}.any?
app/helpers/mediums_helper.rb
Outdated
Hash[Operatingsystem.families.map do |key| | ||
[key, key.constantize.require_nfs_access_to_medium] | ||
end].to_json | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return a list of all families requiring it and check if the selected family is in it or not?
@tbrisker , Thanks for your review, could you have a second look? |
818bc2f
to
617eb77
Compare
@amirfefer, this pull request is currently not mergeable. Please rebase against the develop branch and push again. If you have a remote called 'upstream' that points to this repository, you can do this by running:
This message was auto-generated by Foreman's prprocessor |
@@ -0,0 +1,31 @@ | |||
jest.unmock('./foreman_medium'); | |||
import $ from 'jquery'; | |||
import {nfsVisibility} from './foreman_medium'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import in body of module; reorder to top import/first
Expected empty line after import statement not followed by another import import/newline-after-import
A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing
@@ -0,0 +1,31 @@ | |||
jest.unmock('./foreman_medium'); | |||
import $ from 'jquery'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import in body of module; reorder to top import/first
import $ from 'jquery'; | ||
|
||
export function nfsVisibility(osFamily, nfsRequired) { | ||
nfsRequired.includes(osFamily.value) ? $('#nfs-section').show() : $('#nfs-section').hide(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression no-unused-expressions
webpack/assets/javascripts/bundle.js
Outdated
@@ -34,4 +34,8 @@ window.tfm = Object.assign(window.tfm || {}, { | |||
reactMounter: require('./react_app/common/MountingService'), | |||
editor: require('./foreman_editor'), | |||
nav: require('./foreman_navigation'), | |||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token
webpack/assets/javascripts/bundle.js
Outdated
@@ -34,4 +34,5 @@ window.tfm = Object.assign(window.tfm || {}, { | |||
reactMounter: require('./react_app/common/MountingService'), | |||
editor: require('./foreman_editor'), | |||
nav: require('./foreman_navigation'), | |||
medium: require('./foreman_medium') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing trailing comma comma-dangle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor comment, other than that works well.
app/helpers/mediums_helper.rb
Outdated
|
||
def required_nfs? | ||
required_nfs_list.include?(@medium.os_family) || | ||
@medium.operatingsystems.any?{ |obj| obj.class.require_nfs_access_to_medium } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second part of this check is redundant, you can only add operating systems that match the family
@tbrisker , Thanks for your review, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, will merge once tests pass.
Thanks @amirfefer ! |
nfs section does not become visible when choosing a required nfs os family in installation media form.
This occurs due to broken script file - nfs_visibilty.js, which apparently doesn't work since moving to a select box from checkbox to choose an os family.
I re-wrote the logic and moved it to wepback