-
Notifications
You must be signed in to change notification settings - Fork 983
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 #15406 - Moved puppet outside hosts helper #3607
Conversation
Could you rebase pls? |
Fixing rubocop, codeclimate and registry... |
It works as expected for me, extra points for the backward compatibility. |
setting as WoC because of WIP in the subject, @ShimShtein what's missing? do you plan to send PRs to plugins so they can start using the new registry? |
I am fixing the registry to our latest guidelines, will get back to this PR soon. My first intention was separating puppet actions/fields, but if you have other plugins that need this in your mind, I will submit a PR for them too. |
@ShimShtein what's the status here? |
@ShimShtein, this will need a rebase. |
719d545
to
fc57cf6
Compare
[test foreman] |
@xprazak2, Rebased. ready for review |
@ShimShtein I think the integration test failure is related |
@ShimShtein, 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 |
app/helpers/puppet_related_helper.rb
Outdated
_("Puppet Environment"), | ||
link_to(host.environment, hosts_path(:search => "environment = #{host.environment}")) | ||
], | ||
:priority => 650 |
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.
Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
app/helpers/puppet_related_helper.rb
Outdated
fields << { | ||
:field => [ | ||
_("Puppet Environment"), | ||
link_to(host.environment, hosts_path(:search => "environment = #{host.environment}")) |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
[ | ||
{ :button => link_to_if_authorized(_("Audits"), hash_for_host_audits_path(:host_id => @host), :title => _("Host audit entries"), :class => 'btn btn-default'), :priority => 100 }, | ||
({ :button => link_to_if_authorized(_("Facts"), hash_for_host_facts_path(:host_id => host), :title => _("Browse host facts"), :class => 'btn btn-default'), :priority => 200 } if host.fact_values.any?), | ||
({ :button => link_to_if_authorized(_("Reports"), hash_for_host_config_reports_path(:host_id => host), :title => _("Browse host config management reports"), :class => 'btn btn-default'), :priority => 300 } if host.reports.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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
:method => :delete) | ||
), | ||
:priority => 300 | ||
} |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
:data => { :message => delete_host_dialog(host) }, | ||
:method => :delete) | ||
), | ||
:priority => 300 |
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.
Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
{ :field => [ | ||
_(status.name), | ||
content_tag(:span, ' '.html_safe, :class => host_global_status_icon_class(status.to_global)) + | ||
content_tag(:span, _(status.to_label), :class => host_global_status_class(status.to_global)) |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
content_tag(:span, _(global_status.to_label), :class => host_global_status_class(global_status.status)) | ||
], | ||
:priority => 10 | ||
} |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
content_tag(:span, ''.html_safe, :class => host_global_status_icon_class(global_status.status)) + | ||
content_tag(:span, _(global_status.to_label), :class => host_global_status_class(global_status.status)) | ||
], | ||
:priority => 10 |
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.
Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
:field => [ | ||
_("Status"), | ||
content_tag(:span, ''.html_safe, :class => host_global_status_icon_class(global_status.status)) + | ||
content_tag(:span, _(global_status.to_label), :class => host_global_status_class(global_status.status)) |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
{ :action => [_('Disable Notifications'), multiple_disable_hosts_path], :priority => 400 }, | ||
{ :action => [_('Enable Notifications'), multiple_enable_hosts_path], :priority => 500 }, | ||
{ :action => [_('Disassociate Hosts'), multiple_disassociate_hosts_path], :priority => 600 }, | ||
{ :action => [_('Rebuild Config'), rebuild_config_hosts_path], :priority => 700 } |
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.
Style/TrailingCommaInArrayLiteral: Put a comma after the last item of a multiline array.
@xprazak2, addressed everything (I think). |
@xprazak2, found both bugs (one definition change that I have not noticed and one method that escaped deletion at merge) and added documentation. |
this needs a rebase |
Works well, one final rebase and we can merge. |
Thanks! |
In order to make lists of items more extendable, I have changed the way our helpers generate lists of actions/fields.
Central registry
Added a singleton class instance that will be used as providers registry - each entry in this registry is a symbol that point to a method that will provide the relevant list items.
Now a helper can declare at module level which methods should be used from that module to provide different items.
Usage example:
Files:
app/services/ui.rb
andapp/services/ui/host_description.rb
.Priority field
Most of our items lists like multiple_actions, overview_fields e.t.c. are using array of elements to declare the elements that will be used on different host screens. I have modified each item to be a hash that contains two fields:
:action
or:field
that will contain the original item and:priority
that will contain the priority of that item.Instead of:
The code looks like:
Backwards (plugin) compatibility
The methods didn't change their name. Which means that other plugins still can
alias_method_chain
to add their items. Methods that implement sorting are aware of the fact that part of the items will be in old format.