Project

General

Profile

Revision f6a9acbd

Added by Sebastian Gräßl over 5 years ago

Fixes #18518 - Add proper validation for container image

For now the image has only been validate via the result
of the search, but not enforced on the server side.

The model validation brings now proper feedback when
the form has been submitted to the server.

View differences:

app/views/containers/steps/_image_hub_tab.html.erb
4 4
  :url => wizard_path,
5 5
  :method => :put,
6 6
  :html => {:data => {:registry => registry}} do |f| %>
7

  
8
  <% model.errors.messages.each do |field, field_errors| %>
9
    <div class="alert alert-danger">
10
      <span class="pficon pficon-error-circle-o"></span>
11
      <ul>
12
        <% field_errors.each do |message| %>
13
          <li><%= message %></li>
14
        <% end %>
15
      </ul>
16
    </div>
17
  <% end %>
18

  
7 19
  <% if registry == "registry" -%>
8 20
    <div class="input-group col-md-6">
9 21
      <%= select_registry f %>
10 22
    </div>
11 23
  <% end -%>
12 24

  
13
  <div class="form-group">
14
    <div class='row'>
15
      <% help_type = f.object.errors[:repository_name].present? ? :help_block : :help_inline %>
16
      <%= text_f(
17
        f,
18
        :repository_name,
19
        :label => _('Search'),
20
        :size => 'col-md-6',
21
        :'data-url'  => auto_complete_repository_name_image_search_path(model.compute_resource_id),
22
        :value       => f.object.repository_name.present? ? f.object.repository_name : '',
23
        :'data-registry' => registry,
24
        :'data-search' => true,
25
        :focus_on_load => true,
26
        :placeholder => _('Find your favorite container, e.g. centos'),
27
        help_type => link_to_function(
28
            icon_text('search', ''),
29
            'searchRepo(this)',
30
            :class => 'btn btn-default',
31
            :id => "search_repository_#{registry}",
32
            :'data-registry' => registry,
33
            :'data-url' => search_repository_image_search_path(model.compute_resource_id)
34
          ) + content_tag(:span, '', :id => 'image-confirmation').html_safe) %>
35
    </div>
36
    <div class='row'>
37
      <%= text_f f, :tag,
25
  <% help_type = f.object.errors[:repository_name].present? ? :help_block : :help_inline %>
26
  <%= text_f(f, :repository_name,
27
    :label => _('Search'),
28
    :size => 'col-md-6',
29
    :wrapper_class => (image_search_wrapper_class(model) if tab_active?(registry)),
30
    :'data-url'  => auto_complete_repository_name_image_search_path(model.compute_resource_id),
31
    :value       => f.object.repository_name.present? ? f.object.repository_name : '',
32
    :'data-registry' => registry,
33
    :'data-image' => true,
34
    :'data-search' => true,
35
    :'data-min-length' => 1,
36
    :focus_on_load => true,
37
    :placeholder => _('Find your favorite container, e.g. centos'),
38
    :control_group_id => "#{registry}_image_search",
39
    help_type => link_to_function(
40
        icon_text('search', ''),
41
        'searchRepo(this)',
42
        :class => 'btn btn-default',
43
        :id => "search_repository_#{registry}",
38 44
        :'data-registry' => registry,
39
        :'data-tag' => true,
40
        :'data-url' => auto_complete_image_tag_image_search_path(model.compute_resource_id) %>
41
    </div>
42
  </div>
45
        :'data-url' => search_repository_image_search_path(model.compute_resource_id)
46
      ) + content_tag(:span, '', :id => 'image-confirmation').html_safe) %>
47

  
48
  <%= text_f f, :tag,
49
    :control_group_id => "#{registry}_tag_search",
50
    :'data-registry' => registry,
51
    :'data-tag' => true,
52
    :'data-url' => auto_complete_image_tag_image_search_path(model.compute_resource_id) %>
43 53

  
44 54
  <div class="col-md-12">
45 55
    <div data-search-spinner=true class='col-md-offset-3 hide'>

Also available in: Unified diff