Sha256: 887422cb462eb26da5d3ee586b3271aacf62f007673d296b8dd9fa0ea1464b07

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module ForemanAnsible
  # Small convenience to list all roles in the UI
  module AnsibleRolesHelper
    def ansible_proxy_links(hash, classes = nil)
      SmartProxy.with_features('Ansible').map do |proxy|
        display_link_if_authorized(_('Import from %s') % proxy.name,
                                   hash.merge(:proxy => proxy),
                                   :class => classes)
      end.flatten
    end

    def ansible_role_select(f, persisted)
      blank_opt = persisted ? {} : { :include_blank => true }
      select_items = persisted ? [f.object.ansible_role] : AnsibleRole.order(:name)
      select_f f,
               :ansible_role_id,
               select_items,
               :id,
               :to_label,
               blank_opt,
               :label => _("Ansible Role"),
               :disabled => persisted,
               :required => true
    end

    def ansible_proxy_import(hash)
      select_action_button(_('Import'),
                           { :primary => true, :class => 'roles-import' },
                           ansible_proxy_links(hash))
    end

    def import_time(role)
      _('%s ago') % time_ago_in_words(role.updated_at)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_ansible-2.3.6 app/helpers/foreman_ansible/ansible_roles_helper.rb
foreman_ansible-2.3.5 app/helpers/foreman_ansible/ansible_roles_helper.rb