Sha256: a81c819e0e6be366e0f3c3edfc00307cbc1c819ac15eae2d15d545c3c44dfb5a

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

module ForemanRemoteExecution
  module HostsHelperExtensions
    def multiple_actions
      super + [ [_('Schedule Remote Job'), new_job_invocation_path, false] ]
    end

    def schedule_job_multi_button(*args)
      host_features = RemoteExecutionFeature.with_host_action_button.order(:label).map do |feature|
        link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [args.first.id], :feature => feature.label), :method => :post)
      end

      if host_features.present?
        action_buttons(schedule_job_button(*args), *host_features)
      else
        schedule_job_button(*args)
      end
    end

    def schedule_job_button(*args)
      link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [args.first.id]), :id => :run_button, :class => 'btn btn-default')
    end

    def web_console_button(host, *args)
      return unless authorized_for(permission: 'cockpit_hosts', auth_object: host)
      url = SSHExecutionProvider.cockpit_url_for_host(host.name)
      url ? link_to(_('Web Console'), url, :class => 'btn btn-default', :id => :'web-console-button') : nil
    end

    def host_title_actions(*args)
      title_actions(button_group(schedule_job_multi_button(*args)),
                    button_group(web_console_button(*args)))
      super(*args)
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_remote_execution-2.0.10 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-2.0.9 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-2.0.8 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-3.0.3 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-3.0.2 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-2.0.7 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-3.0.1 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-3.0.0 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
foreman_remote_execution-2.0.6 app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb