Project

General

Profile

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

foreman_docker / app / helpers / container_steps_helper.rb @ 27a7d2c4

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
  def model_for(registry_type)
46
    if active_tab.to_s == registry_type.to_s
47
      @docker_container_wizard_states_image
48
    else
49
      DockerContainerWizardStates::Image.new(:wizard_state => @state)
50
    end
51
  end
52

    
53
  def image_search_wrapper_class(model)
54
    if model.errors.messages[:image]
55
      'form-group has-error'
56
    else
57
      'form-group'
58
    end
59
  end
60

    
61
  def tab_active?(registry)
62
    active_tab == registry.to_sym
63
  end
64

    
65
  def active_tab
66
    if @docker_container_wizard_states_image.katello?
67
      :katello
68
    elsif @docker_container_wizard_states_image.registry_id.nil?
69
      :hub
70
    else
71
      :registry
72
    end
73
  end
74
end