Sha256: ab2e8203d8a6fa302f97bd9dee1eaf8fc504366bfd6426d42fb955a5142be2a5

Contents?: true

Size: 1.39 KB

Versions: 30

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module ForemanAnsible
  module AnsibleHostgroupsHelper
    def ansible_hostgroups_actions(hostgroup)
      actions = []
      is_hostgroup_empty = hostgroup.all_ansible_roles.empty? || hostgroup.hosts_count.zero?

      if User.current.can?(:create_job_invocations)
        actions << {
          action: if is_hostgroup_empty
                    disabled_action_link(_('Run all Ansible roles'))
                  else
                    display_link_if_authorized(_('Run all Ansible roles'), hash_for_play_roles_hostgroup_path(id: hostgroup), 'data-no-turbolink': true, title: _('Run all Ansible roles on hosts belonging to this host group'))
                  end,
          priority: 31
        }
      end

      if User.current.can?(:view_job_invocations) && User.current.can?(:view_recurring_logics)
        actions << {
          action: if is_hostgroup_empty
                    disabled_action_link(_('Configure Ansible Job'))
                  else
                    link_to(_('Configure Ansible Job'), "/ansible/hostgroups/#{hostgroup.id}", class: 'la')
                  end,
          priority: 32
        }
      end

      actions
    end

    def disabled_action_link(text)
      {
        content: link_to(text, 'javascript:void(0);', disabled: true, title: _('No roles/hosts assigned'), class: 'disabled'),
        options: { class: 'disabled' }
      }
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-15.0.1 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-15.0.0 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.2.2 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.2.1 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.7 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.2.0 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.1.1 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.1.0 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.5 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-14.0.0 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.4 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.3 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.2 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.1 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-13.0.0 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-12.0.7 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-10.4.4 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-12.0.6 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb
foreman_ansible-12.0.5 app/helpers/foreman_ansible/ansible_hostgroups_helper.rb