Project

General

Profile

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

foreman-docker / app / helpers / container_steps_helper.rb @ 04b6e05e

1 3eab3643 Daniel Lobato
module ContainerStepsHelper
2
  def container_wizard(step)
3
    wizard_header(
4
      step,
5 99b91b0d Daniel Lobato
      *humanized_steps
6 3eab3643 Daniel Lobato
    )
7
  end
8 ada932ab Dmitri Dolguikh
9
  def select_registry(f)
10 6d101d7a Dmitri Dolguikh
    registries = DockerRegistry.with_taxonomy_scope_override(@location, @organization)
11 ac230210 David Davis
                 .authorized(:view_registries)
12 6d101d7a Dmitri Dolguikh
    field(f, 'docker_container_wizard_states_image[registry_id]', :label => _("Registry")) do
13 f4c209f1 Dmitri Dolguikh
      collection_select :docker_container_wizard_states_image, :registry_id,
14 6d101d7a Dmitri Dolguikh
                        registries,
15 ada932ab Dmitri Dolguikh
                        :id, :name,
16
                        { :prompt => _("Select a registry") },
17 6d101d7a Dmitri Dolguikh
                        :class => "form-control", :disabled => registries.size == 0
18 ada932ab Dmitri Dolguikh
    end
19
  end
20 30891c0a Daniel Lobato
21 99b91b0d Daniel Lobato
  def humanized_steps
22
    [_('Preliminary'), _('Image'), _('Configuration'), _('Environment')]
23
  end
24
25 30891c0a Daniel Lobato
  def last_step?
26
    step == wizard_steps.last
27
  end
28
29
  def taxonomy_icon(taxonomy)
30
    taxonomy == 'locations' ? 'globe' : 'briefcase'
31
  end
32 41572b90 Partha Aji
33
  def tab_class(tab_name)
34
    active_tab.to_s == tab_name.to_s ? "active" : ""
35
  end
36
37 f02a9ce2 Sebastian Gräßl
  # 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 41572b90 Partha Aji
  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 f6a9acbd Sebastian Gräßl
  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 41572b90 Partha Aji
  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 3eab3643 Daniel Lobato
end