Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id D4154E010DF; Thu, 8 Oct 2015 11:32:50 -0700 (PDT) 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 * [209.85.212.176 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 175C2E010CB for ; Thu, 8 Oct 2015 11:32:44 -0700 (PDT) Received: by wiclk2 with SMTP id lk2so37597785wic.1 for ; Thu, 08 Oct 2015 11:32:44 -0700 (PDT) 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:in-reply-to :references; bh=MONUOeTQxakqqXifingpjnqGZ/KYr/7pejgkaX8lpxs=; b=csehTYDR0jLfLlFop9Trg45R5YCvMJ/wt+li0FHnSsKimfVIoaaN9BDSP5S8xi0tze KQhGMVTRBTELaxhxTJLMHsdzx2+z7OJk2iVVkmkVdHLcJifAAbnc01nqohHjDD5AJ9r2 3MMYYLmJkU1mEEjzyls+DDtCPoNSM9D9w+eMZPmJYmms277G2GiDg+0yF8yaLjXtyhNM dG5Spebwr3PT/cgIvgNT0eyXqRtSxT6dSxNYMQkJypoU2i1RUzk5X+qWQG0T8snamBfQ mFUQ8LXREADX3KmY3/OAP+2ay7rrtTTRFG/9J0q0pWN9qOSSNfyzFu+/pzRAYVohYYNe lxxA== X-Gm-Message-State: ALoCoQl9OkOxnjCKfEe+TTh3iDvem9xzEpO2i2DkI/l2exYgWZI4UEQ4fPTJ+d3M+9yi9VOYyWzB X-Received: by 10.194.58.177 with SMTP id s17mr11300500wjq.102.1444329164004; Thu, 08 Oct 2015 11:32:44 -0700 (PDT) Received: from dorado.Home ([2.218.205.118]) by smtp.gmail.com with ESMTPSA id x9sm47729394wjf.44.2015.10.08.11.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 11:32:43 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 8 Oct 2015 19:32:36 +0100 Message-Id: <1444329157-11590-5-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444329157-11590-1-git-send-email-michael.g.wood@intel.com> References: <1444329157-11590-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 4/5] toaster: Fix stale layer state buttons 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, 08 Oct 2015 18:32:50 -0000 Move the "is available to the project" state computation to the template for the Layer add/remove buttons, Recipe build/Add layer as done for the Package add/remove. This is more reliable as we can get an inconsistent state on the front end JS as there are many opportunities for hitting out of date project information. [YOCTO #8294] Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/static/js/layerBtn.js | 9 +-------- bitbake/lib/toaster/toastergui/static/js/table.js | 2 +- bitbake/lib/toaster/toastergui/static/js/tests/test.js | 2 +- bitbake/lib/toaster/toastergui/tables.py | 7 ++++--- bitbake/lib/toaster/toastergui/templates/layer_btn.html | 12 ++++++++++-- bitbake/lib/toaster/toastergui/templates/recipe_btn.html | 12 ++++++++++-- bitbake/lib/toaster/toastergui/templates/toastertable.html | 1 - 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js index da0241c..7318b3f 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js @@ -1,6 +1,6 @@ "use strict"; -function layerBtnsInit(ctx) { +function layerBtnsInit() { /* Remove any current bindings to avoid duplicated binds */ $(".layerbtn").unbind('click'); @@ -80,11 +80,4 @@ function layerBtnsInit(ctx) { imgCustomModal.data('recipe', $(this).data('recipe')); imgCustomModal.modal('show'); }); - - /* Setup the initial state of the buttons */ - - for (var i in ctx.projectLayers){ - $(".layer-exists-" + ctx.projectLayers[i]).show(); - $(".layer-add-" + ctx.projectLayers[i]).hide(); - } } diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js b/bitbake/lib/toaster/toastergui/static/js/table.js index bc81e67..40b5022 100644 --- a/bitbake/lib/toaster/toastergui/static/js/table.js +++ b/bitbake/lib/toaster/toastergui/static/js/table.js @@ -130,7 +130,7 @@ function tableInit(ctx){ tableBody.append(row); /* If we have layerbtns then initialise them */ - layerBtnsInit(ctx); + layerBtnsInit(); /* If we have popovers initialise them now */ $('td > a.btn').popover({ diff --git a/bitbake/lib/toaster/toastergui/static/js/tests/test.js b/bitbake/lib/toaster/toastergui/static/js/tests/test.js index d610113..f0df6e4 100644 --- a/bitbake/lib/toaster/toastergui/static/js/tests/test.js +++ b/bitbake/lib/toaster/toastergui/static/js/tests/test.js @@ -152,7 +152,7 @@ QUnit.test("Layer details page init", function(assert){ }); QUnit.test("Layer btns init", function(assert){ - assert.throws(layerBtnsInit({ projectLayers : [] })); + assert.throws(layerBtnsInit()); }); QUnit.test("Table init", function(assert){ diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 4f24772..b10445b 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -57,9 +57,7 @@ class LayersTable(ToasterTable): context = super(LayersTable, self).get_context_data(**kwargs) project = Project.objects.get(pk=kwargs['pid']) - context['project'] = project - context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=project)) return context @@ -93,7 +91,10 @@ class LayersTable(ToasterTable): def setup_queryset(self, *args, **kwargs): prj = Project.objects.get(pk = kwargs['pid']) - compatible_layers = prj.compatible_layerversions() + compatible_layers = prj.get_all_compatible_layer_versions() + + self.static_context_extra['current_layers'] = \ + prj.get_project_layer_versions(pk=True) self.queryset = compatible_layers.order_by(self.default_orderby) diff --git a/bitbake/lib/toaster/toastergui/templates/layer_btn.html b/bitbake/lib/toaster/toastergui/templates/layer_btn.html index a2e9393..314eec7 100644 --- a/bitbake/lib/toaster/toastergui/templates/layer_btn.html +++ b/bitbake/lib/toaster/toastergui/templates/layer_btn.html @@ -1,8 +1,16 @@ - - diff --git a/bitbake/lib/toaster/toastergui/templates/recipe_btn.html b/bitbake/lib/toaster/toastergui/templates/recipe_btn.html index 77c1b23..baab06e 100644 --- a/bitbake/lib/toaster/toastergui/templates/recipe_btn.html +++ b/bitbake/lib/toaster/toastergui/templates/recipe_btn.html @@ -1,7 +1,15 @@ - -