Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 897D7E008F2; Thu, 20 Nov 2014 07:06:50 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.51 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 8662EE008E3 for ; Thu, 20 Nov 2014 07:06:44 -0800 (PST) Received: by mail-wg0-f51.google.com with SMTP id k14so3972223wgh.10 for ; Thu, 20 Nov 2014 07:06:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fhCCv4+H7Av5CekGC19WfeptqbLf4hfUWalsf/CtkuI=; b=e5D12QEeM89hfwmELrYRb7iNHjZnlRK+F3m9GbDE8ZrjcIqt+5S75LjzUeyT5mFA3g lQMBaseHgFpWIEaMGMh+ggUJLPZ0MdsPTZyK4BMf/aFdXkVzzVo0fKUfOkXUXtUPTcHJ 3hSfPc7X2O3UWCKDq5N3hWV8dtWfrK5pZ0oivUltZjqAQp/jrmP3wY2KX8D93mMsrXBt KscXKVyPXa+GfyHa8L5MwO5RmWH9vtrZvwjGk25Q+AIOzy/MywbG10i0BTg1f64FAJSr LluWcL/VlzIYpTs3a9xqyFg/pBlJ3ikV4JBXwWJx7R2dl1jLrLHD5vev+EO7gaRD2r/j 7P6Q== X-Gm-Message-State: ALoCoQmtG3vDw8FhrOUXZp9IvVNqdOuDjDBl+L7pBIxwrSNIbpnOZkEeBnQNXRBQI2sKHkdIDKv4 X-Received: by 10.194.2.244 with SMTP id 20mr69777132wjx.4.1416496003770; Thu, 20 Nov 2014 07:06:43 -0800 (PST) Received: from draco.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id u13sm4445516wiv.10.2014.11.20.07.06.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 07:06:43 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 20 Nov 2014 15:06:28 +0000 Message-Id: <1416495988-15287-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [review-request][PATCH] bitbake: toaster: base Only show New Build button when there are > 0 projects X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2014 15:06:50 -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 --- bitbake/lib/toaster/toastergui/static/js/base.js | 13 +++++++++---- bitbake/lib/toaster/toastergui/templates/base.html | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 864130d..fac59e6 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js @@ -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) { diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index 734d2ad..f457b91 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -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 %} -- 1.9.1