summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-07-12 15:54:51 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-19 08:56:52 +0100
commit07a58a8944315f87107b29c3d66bc3a7d57c0249 (patch)
tree1c80fc596636db3971542ac903092a4b1d39f7da
parent587275eefd744032f00ebdce35134b2ab2bb7572 (diff)
downloadpoky-07a58a8944315f87107b29c3d66bc3a7d57c0249.tar.gz
bitbake: toaster: only show "New custom image" button for builds with image targets
Add a has_image_targets() method to Build, and use that to hide the "New custom image" button on the build dashboard if a build has no targets which build images. [YOCTO #9514] (Bitbake rev: 3c4b053e44ea512ef2ced67289a7b0161db6ce9b) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: bavery <brian.avery@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/orm/models.py13
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basebuildpage.html42
2 files changed, 35 insertions, 20 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 0443a4589d..a1119168dd 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -449,6 +449,19 @@ class Build(models.Model):
449 break 449 break
450 return has_images 450 return has_images
451 451
452 def has_image_targets(self):
453 """
454 Returns True if a build has any targets which were built from
455 image recipes.
456 """
457 targets = Target.objects.filter(build_id=self.id)
458 has_image_targets = False
459 for target in targets:
460 if target.is_image:
461 has_image_targets = True
462 break
463 return has_image_targets
464
452 def get_image_file_extensions(self): 465 def get_image_file_extensions(self):
453 """ 466 """
454 Get string of file name extensions for images produced by this build; 467 Get string of file name extensions for images produced by this build;
diff --git a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
index e9927ebbaa..8d7c562640 100644
--- a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
+++ b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html
@@ -117,30 +117,32 @@
117 {% endwith %} 117 {% endwith %}
118 118
119 <!-- new custom image from image recipe in this build --> 119 <!-- new custom image from image recipe in this build -->
120 <button class="btn btn-default btn-block navbar-btn" data-role="new-custom-image-trigger">New custom image</button> 120 {% if build.has_image_targets %}
121 {% include 'newcustomimage_modal.html' %} 121 <button class="btn btn-default btn-block navbar-btn" data-role="new-custom-image-trigger">New custom image</button>
122 <script> 122 {% include 'newcustomimage_modal.html' %}
123 // imageRecipes includes both custom image recipes and built-in 123 <script>
124 // image recipes, any of which can be used as the basis for a 124 // imageRecipes includes both custom image recipes and built-in
125 // new custom image 125 // image recipes, any of which can be used as the basis for a
126 var imageRecipes = {{ build.get_image_recipes | objects_to_dictionaries:"id,name" | json }}; 126 // new custom image
127 var imageRecipes = {{ build.get_image_recipes | objects_to_dictionaries:"id,name" | json }};
127 128
128 $(document).ready(function () { 129 $(document).ready(function () {
129 var newCustomImageModal = $('#new-custom-image-modal'); 130 var newCustomImageModal = $('#new-custom-image-modal');
130 var newCustomImageTrigger = $('[data-role="new-custom-image-trigger"]'); 131 var newCustomImageTrigger = $('[data-role="new-custom-image-trigger"]');
131 132
132 // show create new custom image modal to select an image built 133 // show create new custom image modal to select an image built
133 // during this build as the basis for the custom recipe 134 // during this build as the basis for the custom recipe
134 newCustomImageTrigger.click(function () { 135 newCustomImageTrigger.click(function () {
135 if (!imageRecipes.length) { 136 if (!imageRecipes.length) {
136 return; 137 return;
137 } 138 }
138 139
139 newCustomImageModalSetRecipes(imageRecipes); 140 newCustomImageModalSetRecipes(imageRecipes);
140 newCustomImageModal.modal('show'); 141 newCustomImageModal.modal('show');
142 });
141 }); 143 });
142 }); 144 </script>
143 </script> 145 {% endif %}
144 </ul> 146 </ul>
145 147
146 </div> 148 </div>