Sha256: ab4d321b4b88d9070eab82544eacf98bacad1957a2822c3e00899cc39338f490

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module ForemanSalt
  module HostsHelperExtensions
    extend ActiveSupport::Concern

    module Overrides
      def show_appropriate_host_buttons(host)
        (super(host) +
         [(if host.salt_master.present?
             link_to_if_authorized(_('Salt ENC'), { controller: :'foreman_salt/minions', action: :node, id: host },
               title: _('Salt external nodes YAML dump'), class: 'btn btn-default')
           end)]).flatten.compact
      end

      def host_title_actions(host)
        unless Setting[:salt_hide_run_salt_button]
          title_actions(
            button_group(
              if host.try(:salt_proxy)
                link_to_if_authorized(_('Run Salt'), { controller: :'foreman_salt/minions', action: :run, id: host },
                  title: _('Trigger a state.highstate run on a node'), class: 'btn btn-primary')
              end
            )
          )
        end
        super(host)
      end

      def multiple_actions
        actions = super
        if authorized_for(controller: :hosts, action: :edit)
          actions << [_('Change Salt Master'), select_multiple_salt_master_hosts_path] if SmartProxy.unscoped.authorized.with_features('Salt')
          if SmartProxy.unscoped.authorized.with_features('Salt')
            actions << [_('Change Salt Environment'), select_multiple_salt_environment_hosts_path]
          end
        end
        actions
      end

      def overview_fields(host)
        fields = super(host)

        fields.insert(5, [_('Salt Master'), (link_to(host.salt_proxy, hosts_path(search: "saltmaster = #{host.salt_proxy}")) if host.salt_proxy)])
        fields.insert(6, [_('Salt Environment'), (if host.salt_environment
                                                    link_to(host.salt_environment, hosts_path(search: "salt_environment = #{host.salt_environment}"))
                                                  end)])

        fields
      end
    end

    included do
      prepend Overrides
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_salt-14.1.0 app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb