diff --git a/app/assets/images/icon_image_layers.svg b/app/assets/images/icon_image_layers.svg new file mode 100644 index 00000000..ea87ec36 --- /dev/null +++ b/app/assets/images/icon_image_layers.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/panamax/images.css.scss b/app/assets/stylesheets/panamax/images.css.scss index 9de50bdd..9057baed 100644 --- a/app/assets/stylesheets/panamax/images.css.scss +++ b/app/assets/stylesheets/panamax/images.css.scss @@ -1,5 +1,6 @@ @import 'ctl_base_ui/colors'; @import 'ctl_base_ui/icons'; +@import 'ctl_base_ui/mixins'; #images_flow { h1 { @@ -69,10 +70,24 @@ ul.images li { border-bottom: $light_grey 1px solid; overflow: auto; padding-bottom: 22px; + padding-top: 22px; + + .image-layers-link { + background: image-url('icon_image_layers.svg') -10px -17px; + background-size: 40px 40px; + float: left; + width: 20px; + height: 20px; + @include hide-text; + + &:hover { + background-position: -10px 3px; + } + } h3 { - margin: 0; - padding: 22px 0 0 0; + margin: 0 0 0 25px; + padding: 0; } h6 { diff --git a/app/models/local_image.rb b/app/models/local_image.rb index e9d16c51..5f0f7366 100644 --- a/app/models/local_image.rb +++ b/app/models/local_image.rb @@ -1,10 +1,15 @@ class LocalImage < BaseImage PANAMAX_IMAGE_NAMES = ['centurylink/panamax-ui:latest', 'centurylink/panamax-api:latest'] + IMAGE_LAYERS_BASE_URL = 'https://ImageLayers.io' def panamax_image? PANAMAX_IMAGE_NAMES.include?(name) end + def image_layers_url + IMAGE_LAYERS_BASE_URL + "?images=#{name}" + end + def local? true end diff --git a/app/views/images/index.html.haml b/app/views/images/index.html.haml index 2aca81c8..27c8c122 100644 --- a/app/views/images/index.html.haml +++ b/app/views/images/index.html.haml @@ -18,7 +18,9 @@ %ul.images - @images.each do |image| %li - %h3= image.tags.first + - il_message = "Inspect #{image.name} with ImageLayers.io" + = link_to il_message, image.image_layers_url, { class: 'image-layers-link', title: il_message, target: '_blank' } + %h3= image.name %h6= image.tags[1..-1].try(:join, ', ') %dl %dt diff --git a/spec/features/manage_images_spec.rb b/spec/features/manage_images_spec.rb index 037b0dc4..b01351b8 100644 --- a/spec/features/manage_images_spec.rb +++ b/spec/features/manage_images_spec.rb @@ -7,5 +7,11 @@ expect(page).to have_content 'socialize_api:latest' end + + it 'can visit the image layers page for an image' do + visit '/images' + + expect(page).to have_link 'Inspect socialize_api:latest with ImageLayers.io', href: 'https://ImageLayers.io?images=socialize_api:latest' + end end end diff --git a/spec/models/local_image_spec.rb b/spec/models/local_image_spec.rb index ebd2826b..41d44846 100644 --- a/spec/models/local_image_spec.rb +++ b/spec/models/local_image_spec.rb @@ -52,6 +52,12 @@ end end + describe '#image_layers_url' do + it 'concatenates the image layers URL with the image name' do + expect(subject.image_layers_url).to eq 'https://ImageLayers.io?images=blah/not-panamax' + end + end + describe '#docker_index_url' do it 'is nil' do expect(subject.docker_index_url).to be_nil