]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: base Only show New Build button when there are > 0 projects
authorMichael Wood <michael.g.wood@intel.com>
Thu, 20 Nov 2014 15:06:28 +0000 (15:06 +0000)
committerAlexandru DAMIAN <alexandru.damian@intel.com>
Thu, 27 Nov 2014 17:04:52 +0000 (17:04 +0000)
Only show new build button if we have defined at least one project as we
can't select a project to build against if there are no projects created
yet.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
lib/toaster/toastergui/static/js/base.js
lib/toaster/toastergui/templates/base.html

index 864130def91f5264e382144aabddc27a52ad554f..fac59e64589dcadeb5b06c5a38218d06d2a3c3ed 100644 (file)
@@ -3,10 +3,12 @@
 function basePageInit (ctx) {
 
   var newBuildButton = $("#new-build-button");
-  /* Hide the button if we're on the project,newproject or importlyaer page */
-  if (ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
-    newBuildButton.hide();
-    return;
+  /* Hide the button if we're on the project,newproject or importlyaer page
+   * or if there are no projects yet defined
+   */
+  if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
+      newBuildButton.hide();
+      return;
   }
 
 
@@ -17,6 +19,9 @@ function basePageInit (ctx) {
 
 
   function _checkProjectBuildable(){
+    if (ctx.projectId == undefined)
+      return;
+
     libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId,
       function(data){
         if (data.machine.name == undefined || data.layers.length == 0) {
index 734d2ad8a213b0f0f5c31e49f11de68f3e05aa42..f457b91dcede2c627a8fa0ad77ba714976a4c769 100644 (file)
@@ -31,6 +31,7 @@
     ctx.projectBuildUrl = "{% url 'xhr_build' %}";
     ctx.projectPageUrl = "{% url 'project' %}";
     ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}";
+    ctx.numProjects = {{projects|length}};
     {% if project %}
       ctx.projectId = {{project.id}};
     {% endif %}