Sha256: f873f8ceb1cd18d2f6b57e7d4bcbe06d192d3276340d88f661071d2758ec6183

Contents?: true

Size: 1020 Bytes

Versions: 10

Compression:

Stored size: 1020 Bytes

Contents

module ForemanAnsible
  # Chained methods to extend the hosts menu with Ansible actions
  module HostsHelperExtensions
    extend ActiveSupport::Concern

    module Overrides
      def host_title_actions(*args)
        host = args.first
        if ansible_roles_present?(host)
          button = ansible_roles_button(host)
          title_actions(button_group(button))
        end
        super(*args)
      end

      def multiple_actions
        super +
          [[_('Play Ansible roles'),
            multiple_play_roles_hosts_path,
            false]]
      end
    end

    included do
      prepend Overrides
    end

    def ansible_roles_present?(host)
      host.ansible_roles.present? ||
        host.inherited_ansible_roles.present?
    end

    def ansible_roles_button(host)
      link_to(
        _('Run Ansible roles'),
        play_roles_host_path(:id => host.id),
        :id => :ansible_roles_button,
        :class => 'btn btn-default',
        :'data-no-turbolink' => true
      )
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_ansible-2.2.1 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.2.0 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.1.2 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.1.1 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.0.4 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.0.3 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.0.2 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.1.0 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.0.1 app/helpers/foreman_ansible/hosts_helper_extensions.rb
foreman_ansible-2.0.0 app/helpers/foreman_ansible/hosts_helper_extensions.rb