From da243130a82480c5305687e0a93f06f680ab37a8 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Sat, 16 Aug 2014 15:25:58 +0200 Subject: [PATCH] fixes #7121 - move smart proxy action buttons to helper --- app/helpers/smart_proxies_helper.rb | 19 +++++++++++++++++++ app/views/smart_proxies/index.html.erb | 16 +--------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 app/helpers/smart_proxies_helper.rb diff --git a/app/helpers/smart_proxies_helper.rb b/app/helpers/smart_proxies_helper.rb new file mode 100644 index 00000000000..6c08b06b3dc --- /dev/null +++ b/app/helpers/smart_proxies_helper.rb @@ -0,0 +1,19 @@ +module SmartProxiesHelper + def proxy_actions proxy, authorizer + [if proxy.features.detect{|f| f.name == "Puppet CA"} + [display_link_if_authorized(_("Certificates"), hash_for_smart_proxy_puppetca_index_path(:smart_proxy_id => proxy). + merge(:auth_object => proxy, :permission => 'view_smart_proxies_puppetca', :authorizer => authorizer)), + display_link_if_authorized(_("Autosign"), hash_for_smart_proxy_autosign_index_path(:smart_proxy_id => proxy). + merge(:auth_object => proxy, :permission => 'view_smart_proxies_autosign', :authorizer => authorizer))] + end, + + if SETTINGS[:unattended] and proxy.features.detect{|f| f.name == "DHCP" } + display_link_if_authorized(_("Import subnets"), hash_for_import_subnets_path(:smart_proxy_id => proxy)) + end, + + display_link_if_authorized(_("Refresh features"), hash_for_refresh_smart_proxy_path(:id => proxy). + merge(:auth_object => proxy, :permission => 'edit_smart_proxies', :authorizer => authorizer), :method => :put), + + display_delete_if_authorized(hash_for_smart_proxy_path(:id => proxy).merge(:auth_object => proxy, :authorizer => authorizer), :confirm => _("Delete %s?") % proxy.name)] + end +end diff --git a/app/views/smart_proxies/index.html.erb b/app/views/smart_proxies/index.html.erb index 9dfaf4fd564..82ce7c2172e 100644 --- a/app/views/smart_proxies/index.html.erb +++ b/app/views/smart_proxies/index.html.erb @@ -15,21 +15,7 @@ <%= link_to_if_authorized proxy.name, hash_for_edit_smart_proxy_path(:id => proxy.id).merge(:auth_object => proxy, :authorizer => authorizer) %> <%=h proxy.url %> <%=h proxy.features.to_sentence %> - - <% ca = proxy.features.detect{|f| f.name == "Puppet CA"} %> - <%= action_buttons( - if ca - display_link_if_authorized(_("Certificates"), hash_for_smart_proxy_puppetca_index_path(:smart_proxy_id => proxy).merge(:auth_object => proxy, :permission => 'view_smart_proxies_puppetca', :authorizer => authorizer)) - end, - if ca - display_link_if_authorized(_("Autosign"), hash_for_smart_proxy_autosign_index_path(:smart_proxy_id => proxy).merge(:auth_object => proxy, :permission => 'view_smart_proxies_autosign', :authorizer => authorizer)) - end, - if SETTINGS[:unattended] and proxy.features.detect{|f| f.name == "DHCP" } - display_link_if_authorized(_("Import subnets"), hash_for_import_subnets_path(:smart_proxy_id => proxy)) - end, - display_link_if_authorized(_("Refresh features"), hash_for_refresh_smart_proxy_path(:id => proxy).merge(:auth_object => proxy, :permission => 'edit_smart_proxies', :authorizer => authorizer), :method => :put), - display_delete_if_authorized(hash_for_smart_proxy_path(:id => proxy).merge(:auth_object => proxy, :authorizer => authorizer), :confirm => _("Delete %s?") % proxy.name))%> - + <%= action_buttons(*proxy_actions(proxy, authorizer)) %> <% end %>