From 46b4ea8e3e47ce6d39dd4fc3513b78a16a7fde15 Mon Sep 17 00:00:00 2001
From: Joseph Schorr <josephschorr@users.noreply.github.com>
Date: Thu, 17 Mar 2016 16:55:41 -0400
Subject: [PATCH] Fix display of images in new sec scan API

Fixes #1297
---
 static/directives/image-feature-view.html       | 11 ++++++++---
 static/directives/image-view-layer.html         |  5 ++---
 static/directives/image-vulnerability-view.html | 11 ++++++++---
 static/js/services/image-metadata-service.js    |  2 ++
 4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/static/directives/image-feature-view.html b/static/directives/image-feature-view.html
index 20864f6c4..f9162f287 100644
--- a/static/directives/image-feature-view.html
+++ b/static/directives/image-feature-view.html
@@ -146,10 +146,15 @@
            </span>
          </td>
          <td class="double-col image-col hidden-xs hidden-sm hidden-md">
-            <span data-title="{{ feature.imageCommand }}" bs-tooltip>
-              <span class="dockerfile-command" command="feature.imageCommand"></span>
+            <span bo-if="feature.imageCommand">
+              <span data-title="{{ feature.imageCommand }}" data-container="body" bs-tooltip>
+                <span class="dockerfile-command" command="feature.imageCommand"></span>
+              </span>
+              <a href="/repository/{{ repository.namespace }}/{{ repository.name }}/image/{{ feature.imageId }}"><i class="fa fa-archive"></i></a>
+              </span>
+            <span bo-if="!feature.imageCommand">
+              <span class="image-link" repository="repository" image-id="feature.imageId"></span>
             </span>
-            <a href="/repository/{{ repository.namespace }}/{{ repository.name }}/image/{{ feature.imageId }}"><i class="fa fa-archive"></i></a>
          </td>
          <td></td>
         </tr>
diff --git a/static/directives/image-view-layer.html b/static/directives/image-view-layer.html
index f85e34964..0d0601b6d 100644
--- a/static/directives/image-view-layer.html
+++ b/static/directives/image-view-layer.html
@@ -4,9 +4,8 @@
         {{ image.id.substr(0, 12) }}
     </a>
   </div>
-  <div class="image-comment" ng-if="image.comment">{{ image.comment }}</div>
-  <div class="image-command">
-     <div class="nondocker-command" ng-if="!getDockerfileCommand(image.command) && image.command.length">{{ image.command.join(' ') }}</div>
+   <div class="image-command">
+     <div class="nondocker-command" ng-if="!getDockerfileCommand(image.command)">{{ image.command.join(' ') }}</div>
      <div class="dockerfile-command" command="getDockerfileCommand(image.command)"
           ng-if="getDockerfileCommand(image.command)"></div>
   </div>
diff --git a/static/directives/image-vulnerability-view.html b/static/directives/image-vulnerability-view.html
index 6fb89f6e2..140cc5e16 100644
--- a/static/directives/image-vulnerability-view.html
+++ b/static/directives/image-vulnerability-view.html
@@ -134,10 +134,15 @@
             <span class="fixed-in-version" bo-if="vuln.fixedInVersion" bo-text="vuln.fixedInVersion"></span>
          </td>
          <td class="double-col image-col hidden-xs hidden-sm hidden-md">
-            <span data-title="{{ vuln.imageCommand }}" data-container="body" bs-tooltip>
-              <span class="dockerfile-command" command="vuln.imageCommand"></span>
+            <span bo-if="vuln.imageCommand">
+              <span data-title="{{ vuln.imageCommand }}" data-container="body" bs-tooltip>
+                <span class="dockerfile-command" command="vuln.imageCommand"></span>
+              </span>
+              <a href="/repository/{{ repository.namespace }}/{{ repository.name }}/image/{{ vuln.imageId }}"><i class="fa fa-archive"></i></a>
+              </span>
+            <span bo-if="!vuln.imageCommand">
+              <span class="image-link" repository="repository" image-id="vuln.imageId"></span>
             </span>
-            <a href="/repository/{{ repository.namespace }}/{{ repository.name }}/image/{{ vuln.imageId }}"><i class="fa fa-archive"></i></a>
          </td>
          <td></td>
         </tr>
diff --git a/static/js/services/image-metadata-service.js b/static/js/services/image-metadata-service.js
index ac04ab7a1..4b7d251ed 100644
--- a/static/js/services/image-metadata-service.js
+++ b/static/js/services/image-metadata-service.js
@@ -31,6 +31,8 @@ angular.module('quay').factory('ImageMetadataService', ['UtilService', function(
 
     if (!image.__imageMap) {
       image.__imageMap = {};
+      image.__imageMap[image.id] = image;
+
       for (var i = 0; i < image.history.length; ++i) {
         var cimage = image.history[i];
         image.__imageMap[cimage.id] = cimage;