Skip to content

Commit

Permalink
Merge pull request #37 from stbenjam/search
Browse files Browse the repository at this point in the history
Add scoped search on saltmaster
  • Loading branch information
stbenjam committed May 10, 2015
2 parents 1a592f1 + fd8a6c7 commit 7f117f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module HostsHelperExtensions
extend ActiveSupport::Concern

included do
alias_method_chain :host_title_actions, :salt_run
alias_method_chain :host_title_actions, :salt
alias_method_chain :show_appropriate_host_buttons, :salt
alias_method_chain :overview_fields, :salt
end

def show_appropriate_host_buttons_with_salt(host)
Expand All @@ -13,7 +14,7 @@ def show_appropriate_host_buttons_with_salt(host)
:title => _('Salt external nodes YAML dump'), :class => 'btn btn-default') unless host.salt_master.blank?)]).flatten.compact
end

def host_title_actions_with_salt_run(host)
def host_title_actions_with_salt(host)
title_actions(
button_group(
if host.try(:salt_proxy)
Expand All @@ -22,7 +23,16 @@ def host_title_actions_with_salt_run(host)
end
)
)
host_title_actions_without_salt_run(host)
host_title_actions_without_salt(host)
end

def overview_fields_with_salt(host)
fields = overview_fields_without_salt(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"), (link_to(host.salt_environment, hosts_path(:search => "salt_environment = #{host.salt_environment}")) if host.salt_environment)])

fields
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module HostManagedExtensions

scoped_search :in => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
scoped_search :in => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
scoped_search :in => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster

validate :salt_modules_in_host_environment
end
Expand Down
1 change: 1 addition & 0 deletions app/models/foreman_salt/concerns/hostgroup_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module HostgroupExtensions

scoped_search :in => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
scoped_search :in => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
scoped_search :in => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster
end

def all_salt_modules
Expand Down

0 comments on commit 7f117f0

Please sign in to comment.