Project

General

Profile

Download (1.33 KB) Statistics
| Branch: | Tag: | Revision:

foreman-docker / app / helpers / container_steps_helper.rb @ d2e54db4

1
module ContainerStepsHelper
2
  def container_wizard(step)
3
    wizard_header(
4
      step,
5
      *wizard_steps.map { |s| s.to_s.humanize }
6
    )
7
  end
8

    
9
  def select_registry(f)
10
    registries = DockerRegistry.with_taxonomy_scope_override(@location, @organization)
11
                 .authorized(:view_registries)
12
    field(f, 'docker_container_wizard_states_image[registry_id]', :label => _("Registry")) do
13
      collection_select :docker_container_wizard_states_image, :registry_id,
14
                        registries,
15
                        :id, :name,
16
                        { :prompt => _("Select a registry") },
17
                        :class => "form-control", :disabled => registries.size == 0
18
    end
19
  end
20

    
21
  def last_step?
22
    step == wizard_steps.last
23
  end
24

    
25
  def taxonomy_icon(taxonomy)
26
    taxonomy == 'locations' ? 'globe' : 'briefcase'
27
  end
28

    
29
  def tab_class(tab_name)
30
    active_tab.to_s == tab_name.to_s ? "active" : ""
31
  end
32

    
33
  def model_for(registry_type)
34
    if active_tab.to_s == registry_type.to_s
35
      @docker_container_wizard_states_image
36
    else
37
      DockerContainerWizardStates::Image.new(:wizard_state => @state)
38
    end
39
  end
40

    
41
  def active_tab
42
    if @docker_container_wizard_states_image.katello?
43
      :katello
44
    elsif @docker_container_wizard_states_image.registry_id.nil?
45
      :hub
46
    else
47
      :registry
48
    end
49
  end
50
end