Module: BootdiskLinksHelper

Included in:
ForemanBootdisk::HostsHelperExt, ForemanBootdisk::SubnetsHelperExt
Defined in:
app/helpers/bootdisk_links_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootdisk_authorized_for(options) ⇒ Object



17
18
19
# File 'app/helpers/bootdisk_links_helper.rb', line 17

def bootdisk_authorized_for(options)
  User.current.allowed_to?(options)
end


25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/bootdisk_links_helper.rb', line 25

def bootdisk_help_link
  display_bootdisk_link_if_authorized(
    _('Boot disk Help'),
  {
      controller: 'foreman_bootdisk/disks',
      action: 'help'
    },
    class: 'la'
  )
end

#bootdisk_title_action_buttons(actions) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/bootdisk_links_helper.rb', line 36

def bootdisk_title_action_buttons(actions)
  title_actions(
    button_group(
      select_action_button(
        _('Boot disk'), { class: 'btn btn-group' },
        actions
      )
    )
  )
end

#bootdisk_url(options) ⇒ Object



13
14
15
# File 'app/helpers/bootdisk_links_helper.rb', line 13

def bootdisk_url(options)
  ForemanBootdisk::Engine.routes.url_for(options.merge(only_path: true, script_name: foreman_bootdisk_path))
end

Core Foreman helpers can’t look up a URL against a mounted engine



5
6
7
8
9
10
11
# File 'app/helpers/bootdisk_links_helper.rb', line 5

def display_bootdisk_link_if_authorized(name, options = {}, html_options = {})
  if bootdisk_authorized_for(options)
    link_to(name, bootdisk_url(options), html_options)
  else
    ''
  end
end

#dividerObject



21
22
23
# File 'app/helpers/bootdisk_links_helper.rb', line 21

def divider
  tag(:li, class: 'divider')
end