diff --git a/app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb b/app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb index 702ed7056..2c516e558 100644 --- a/app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb +++ b/app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb @@ -4,7 +4,7 @@ def permitted_actions(template) original = super(template) if template.is_a?(JobTemplate) - original.unshift(display_link_if_authorized(_('Run'), hash_for_new_job_invocation_path(:template_id => template.id).merge(:authorizer => authorizer))) unless template.snippet + original.unshift(authorized_for(controller: :job_invocations, action: :create) ? link_to(_('Run'), hash_for_new_job_invocation_path(:template_id => template.id).merge(:authorizer => authorizer)) : nil) unless template.snippet end original diff --git a/app/views/job_invocations/new.html.erb b/app/views/job_invocations/new.html.erb index 2ba1219f7..fd1e54ee8 100644 --- a/app/views/job_invocations/new.html.erb +++ b/app/views/job_invocations/new.html.erb @@ -2,8 +2,8 @@ <% stylesheet 'foreman_remote_execution/foreman_remote_execution' %> <% title _('Job invocation') %> <% if(request.path_parameters[:action] == "rerun") %> - <%= display_link_if_authorized(_('Use new job wizard'), hash_for_rerun_job_invocation_path({:id => request.path_parameters[:id]}).merge(request.query_parameters)) %> + <%= authorized_for(controller: :job_invocations, action: :create) ? link_to(_('Use new job wizard'), hash_for_rerun_job_invocation_path({:id => request.path_parameters[:id]}).merge(request.query_parameters)) : nil %> <% else %> - <%= display_link_if_authorized(_('Use new job wizard'), hash_for_new_job_invocation_path().merge(request.query_parameters)) %> + <%= authorized_for(controller: :job_invocations, action: :create) ? link_to(_('Use new job wizard'), hash_for_new_job_invocation_path().merge(request.query_parameters)) : nil %> <%end%> <%= render :partial => 'form' %> diff --git a/app/views/job_invocations/welcome.html.erb b/app/views/job_invocations/welcome.html.erb index 66173d16b..11eac0f4e 100644 --- a/app/views/job_invocations/welcome.html.erb +++ b/app/views/job_invocations/welcome.html.erb @@ -9,6 +9,6 @@

<%= link_to _('Learn more about this in the documentation.'), documentation_url('1.ForemanRemoteExecution1.3Manual', :root_url => 'https://www.theforeman.org/plugins/foreman_remote_execution/1.3/index.html#'), :rel => 'external' %>

- <%= display_link_if_authorized(_("Run Job"), { :action => :create }, { :class => "btn btn-primary btn-lg" }) %> + <%= authorized_for(controller: :job_invocations, action: :create) ? link_to(_("Run Job"), { :action => :create }, { :class => "btn btn-primary btn-lg" }) : nil %>