Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 3366DE00404; Mon, 2 Mar 2015 07:00:57 -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 * [209.85.212.181 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 79FA0E003A8 for ; Mon, 2 Mar 2015 07:00:54 -0800 (PST) Received: by widem10 with SMTP id em10so15540668wid.1 for ; Mon, 02 Mar 2015 07:00:54 -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=4QgUbM3f33BjI6ws3gl1641S++VXIPNZqFwBDNZWqE0=; b=f1V6kdrISR7jSIK32LVjA2hzZfK94BfGvI5q1BKemuAiKIMOFaUilvoRo591DKDnn7 TM9gvtxJMGbJrSRUhHSXmNbTax9mIuJvFd0pppJIu7a3LPebOR2+x8RF7rqKfCA5XrKP Sxpv7y9OuE6EBOBJ6KHz0r3NrATdTfuSKeDo90mmc0zQ23n3J34pF3Vlnf8y/pXzqOrk cEAaEBdEzxDU0cyyJOXFyjABx+B1D04avFktJWvalPaf446njOt3RClafEGgXqzqSI4M OGAwh/b+Z4CUyc28HsKUzPSnQ6eA6THtU6XD8S8H5q1kqfiVgC662th+96CnkVU1giKi VcCA== X-Gm-Message-State: ALoCoQmv745zbzjGbdeozphxK2yMVx5KdRFlVnhHIN4/8k+w1TKIESsgiUIq4aWeau31Y0Jy/ZAD X-Received: by 10.194.81.1 with SMTP id v1mr57396862wjx.50.1425308454011; Mon, 02 Mar 2015 07:00:54 -0800 (PST) Received: from draco.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id cf12sm19598432wjb.10.2015.03.02.07.00.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Mar 2015 07:00:53 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 2 Mar 2015 15:00:49 +0000 Message-Id: <1425308449-10473-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.0 Subject: [review-request][PATCH] bitbake: toaster: Enforce unique layer names 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: Mon, 02 Mar 2015 15:00:57 -0000 We had some clever functionality to manage duplicate layer names by using layer versions and new revisions, unfortunately this was too opaque to the user. [YOCTO #7337] Signed-off-by: Michael Wood --- .../toaster/toastergui/static/js/importlayer.js | 94 +++++++++------------- .../toaster/toastergui/templates/importlayer.html | 39 +++++++-- bitbake/lib/toaster/toastergui/views.py | 11 ++- 3 files changed, 82 insertions(+), 62 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index 9d54286..d14a8ab 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -148,7 +148,6 @@ function importLayerPageInit (ctx) { headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, success: function (data) { if (data.error != "ok") { - show_error_message(data, layerData); console.log(data.error); } else { /* Success layer import now go to the project page */ @@ -164,59 +163,7 @@ function importLayerPageInit (ctx) { } }); - function show_error_message(error, layerData) { - - var errorMsg = $("#import-error").fadeIn(); - var errorType = error.error; - var body = errorMsg.children("p"); - var title = errorMsg.children("h3"); - var optionsList = errorMsg.children("ul"); - var invalidLayerRevision = $("#invalid-layer-revision-hint"); - var layerRevisionCtrl = $("#layer-revision-ctrl"); - - /* remove any existing items */ - optionsList.children().each(function(){ $(this).remove(); }); - body.text(""); - title.text(""); - invalidLayerRevision.hide(); - layerNameCtrl.removeClass("error"); - layerRevisionCtrl.removeClass("error"); - - switch (errorType){ - case 'hint-layer-version-exists': - title.text("This layer already exists"); - body.html("A layer "+layerData.name+" already exists with this Git repository URL and this revision. You can:"); - optionsList.append("
  • Import "+layerData.name+" with a different revision
  • "); - optionsList.append("
  • or change the revision of the existing layer
  • "); - - layerRevisionCtrl.addClass("error"); - - invalidLayerRevision.html("A layer "+layerData.name+" already exists with this revision.
    You can import "+layerData.name+" with a different revision"); - invalidLayerRevision.show(); - break; - - case 'hint-layer-exists-with-different-url': - title.text("This layer already exists"); - body.html("A layer "+layerData.name+" already exists with a different Git repository URL:

    "+error.current_url+"

    You can:

    "); - optionsList.append("
  • Import the layer under a different name
  • "); - optionsList.append("
  • or change the Git repository URL of the existing layer
  • "); - duplicatedLayerName.html("A layer "+layerData.name+" already exists with a different Git repository URL.
    To import this layer give it a different name."); - duplicatedLayerName.show(); - layerNameCtrl.addClass("error"); - break; - - case 'hint-layer-exists': - title.text("This layer already exists"); - body.html("A layer "+layerData.name+" already exists. You can:"); - optionsList.append("
  • Import the layer under a different name
  • "); - break; - default: - title.text("Error") - body.text(data.error); - } - } - - function enable_import_btn (enabled) { + function enable_import_btn(enabled) { var importAndAddHint = $("#import-and-add-hint"); if (enabled) { @@ -244,6 +191,38 @@ function importLayerPageInit (ctx) { enable_import_btn(true); } + function layerExistsError(layer){ + var dupLayerInfo = $("#duplicate-layer-info"); + dupLayerInfo.find(".dup-layer-name").text(layer.name); + dupLayerInfo.find(".dup-layer-link").attr("href", layer.layerdetailurl); + dupLayerInfo.find("#dup-layer-vcs-url").text(layer.giturl); + dupLayerInfo.find("#dup-layer-revision").text(layer.revision); + + $(".fields-apart-from-layer-name").fadeOut(function(){ + + dupLayerInfo.fadeIn(); + }); + } + + layerNameInput.on('blur', function() { + if (!$(this).val()){ + return; + } + var name = $(this).val(); + + /* Check if the layer name exists */ + $.getJSON(ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" , value: name }, function(layer) { + if (layer.list.length > 0) { + for (var i in layer.list){ + if (layer.list[i].name == name) { + console.log(layer.list[i]) + layerExistsError(layer.list[i]); + } + } + } + }); + }); + vcsURLInput.on('input', function() { check_form(); }); @@ -260,6 +239,13 @@ function importLayerPageInit (ctx) { return; } + if ($("#duplicate-layer-info").css("display") != "None"){ + $("#duplicate-layer-info").fadeOut(function(){ + $(".fields-apart-from-layer-name").show(); + }); + + } + /* Don't remove the error class if we're displaying the error for another * reason. */ diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html index 19d2fc4..c687c12 100644 --- a/bitbake/lib/toaster/toastergui/templates/importlayer.html +++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html @@ -51,26 +51,51 @@
    - +
    + + + @@ -83,13 +108,16 @@ + + +
    Layer dependencies (optional) - +
    @@ -105,6 +133,7 @@ To import a layer, you need to enter a repository URL, a branch, tag or commit and a layer name + {% endblock %} diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 4f4ae67..b078d90 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2227,9 +2227,14 @@ if toastermain.settings.MANAGED: def _lv_to_dict(x): - return {"id": x.pk, "name": x.layer.name, "tooltip": x.layer.vcs_url+" | "+x.commit, - "detail": "(" + x.layer.vcs_url + (")" if x.up_branch == None else " | "+x.up_branch.name+")"), - "giturl": x.layer.vcs_url, "layerdetailurl" : reverse('layerdetails', args=(x.pk,))} + return {"id": x.pk, + "name": x.layer.name, + "tooltip": x.layer.vcs_url+" | "+x.get_vcs_reference(), + "detail": "(" + x.layer.vcs_url + (")" if x.up_branch == None else " | "+x.get_vcs_reference()+")"), + "giturl": x.layer.vcs_url, + "layerdetailurl" : reverse('layerdetails', args=(x.pk,)), + "revision" : x.get_vcs_reference(), + } # returns layers for current project release that are not in the project set, matching the name -- 2.1.0