Project

General

Profile

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

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

1
module ContainerStepsHelper
2
  def container_wizard(step)
3
    wizard_header(
4
      step,
5
      *humanized_steps
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 humanized_steps
22
    [_('Preliminary'), _('Image'), _('Configuration'), _('Environment')]
23
  end
24

    
25
  def last_step?
26
    step == wizard_steps.last
27
  end
28

    
29
  def taxonomy_icon(taxonomy)
30
    taxonomy == 'locations' ? 'globe' : 'briefcase'
31
  end
32

    
33
  def tab_class(tab_name)
34
    active_tab.to_s == tab_name.to_s ? "active" : ""
35
  end
36

    
37
  # el7 returns -> "name" => "docker.io: docker.io/centos",
38
  # while f20 returns -> "name" => "centos"
39
  # we need repo name to be => "docker.io/centos" for el7 and "centos" for fedora
40
  # to ensure proper search with respect to the tags, image creation etc.
41
  def cleanup_image_name(name)
42
    name.split.last
43
  end
44

    
45

    
46
  def model_for(registry_type)
47
    if active_tab.to_s == registry_type.to_s
48
      @docker_container_wizard_states_image
49
    else
50
      DockerContainerWizardStates::Image.new(:wizard_state => @state)
51
    end
52
  end
53

    
54
  def active_tab
55
    if @docker_container_wizard_states_image.katello?
56
      :katello
57
    elsif @docker_container_wizard_states_image.registry_id.nil?
58
      :hub
59
    else
60
      :registry
61
    end
62
  end
63
end