From patchwork Thu Sep 14 23:20:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: toaster: reserve HEAD from imported layers From: "Reyna, David" X-Patchwork-Id: 144163 Message-Id: <1505431229-5404-1-git-send-email-david.reyna@windriver.com> To: Date: Thu, 14 Sep 2017 16:20:29 -0700 From: David Reyna The HEAD reference in Toaster layers are reserved for the "Local Yocto Project" layers, stored at the top directory. Imported layers are not allowed to use this since they are managed differently - for example the 'remotes' will collide. Fix the add layer handler to not drop the data fields when it is a git repo. Explicitly inform the user when an internal Toaster error is returned via AJAX, so that they know why clicking the layer add button did not do anything. [YOCTO #9924] Signed-off-by: David Reyna --- bitbake/lib/toaster/toastergui/api.py | 6 +++--- bitbake/lib/toaster/toastergui/static/js/importlayer.js | 17 ++++++++++++++--- .../lib/toaster/toastergui/templates/importlayer.html | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py index cb8f0f3..ab6ba69 100644 --- a/bitbake/lib/toaster/toastergui/api.py +++ b/bitbake/lib/toaster/toastergui/api.py @@ -293,14 +293,14 @@ class XhrLayer(View): layer_source=LayerSource.TYPE_IMPORTED) # Local layer - if 'local_source_dir' in layer_data: + if ('local_source_dir' in layer_data) and layer.local_source_dir: layer.local_source_dir = layer_data['local_source_dir'] # git layer elif 'vcs_url' in layer_data: layer.vcs_url = layer_data['vcs_url'] layer_version.dirpath = layer_data['dir_path'] - layer_version.commit = layer_data['get_ref'] - layer_version.branch = layer_data['get_ref'] + layer_version.commit = layer_data['git_ref'] + layer_version.branch = layer_data['git_ref'] layer.save() layer_version.save() diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index b3f094e..59652b9 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -176,6 +176,8 @@ function importLayerPageInit (ctx) { success: function (data) { if (data.error != "ok") { console.log(data.error); + /* let the user know why nothing happened */ + alert(data.error) } else { createImportedNotification(data); window.location.replace(libtoaster.ctx.projectPageUrl); @@ -244,9 +246,18 @@ function importLayerPageInit (ctx) { enable_import_btn(true); } - if ($("#git-repo-radio").prop("checked") && - vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) { - enable_import_btn(true); + if ($("#git-repo-radio").prop("checked")) { + if (gitRefInput.val().length > 0 && + gitRefInput.val() == 'HEAD') { + $('#invalid-layer-revision-hint').show(); + $('#layer-revision-ctrl').addClass('has-error'); + enable_import_btn(false); + } else if (vcsURLInput.val().length > 0 && + gitRefInput.val().length > 0) { + $('#invalid-layer-revision-hint').hide(); + $('#layer-revision-ctrl').removeClass('has-error'); + enable_import_btn(true); + } } } diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html index afbeb94..7e5253e 100644 --- a/bitbake/lib/toaster/toastergui/templates/importlayer.html +++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html @@ -115,8 +115,8 @@ - +