mirror of
https://git.yoctoproject.org/poky
synced 2026-04-30 03:32:12 +02:00
bitbake: toaster: control the selection of git and local repo
Changes made in this patch will help user to select either repo based on git and local. This patch also improves the help provided to user so that user can understand them and take necessary action to proceed. [YOCOT #9911] (Bitbake rev: 26bee4c2c05dc202857270cd5f56abff79674ca7) Signed-off-by: Sujith H <sujith.h@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -10,6 +10,7 @@ function importLayerPageInit (ctx) {
|
||||
var layerDepInput = $("#layer-dependency");
|
||||
var layerNameCtrl = $("#layer-name-ctrl");
|
||||
var duplicatedLayerName = $("#duplicated-layer-name-hint");
|
||||
var localDirPath = $("#local-dir-path");
|
||||
|
||||
var layerDeps = {};
|
||||
var layerDepsDeps = {};
|
||||
@@ -35,6 +36,9 @@ function importLayerPageInit (ctx) {
|
||||
}
|
||||
});
|
||||
|
||||
// Disable local dir repo when page is loaded.
|
||||
$('#local-dir').hide();
|
||||
|
||||
// disable the "Add layer" button when the layer input typeahead is empty
|
||||
// or not in the typeahead choices
|
||||
layerDepInput.on("input change", function () {
|
||||
@@ -168,8 +172,16 @@ function importLayerPageInit (ctx) {
|
||||
dir_path: $("#layer-subdir").val(),
|
||||
project_id: libtoaster.ctx.projectId,
|
||||
layer_deps: layerDepsCsv,
|
||||
local_source_dir: $('#local-dir-path').val(),
|
||||
};
|
||||
|
||||
if ($('input[name=repo]:checked').val() == "git") {
|
||||
layerData.local_source_dir = "";
|
||||
} else {
|
||||
layerData.vcs_url = "";
|
||||
layerData.git_ref = "";
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ctx.xhrImportLayerUrl,
|
||||
@@ -208,25 +220,45 @@ function importLayerPageInit (ctx) {
|
||||
function check_form() {
|
||||
var valid = false;
|
||||
var inputs = $("input:required");
|
||||
var inputStr = inputs.val().split("");
|
||||
|
||||
for (var i=0; i<inputs.length; i++){
|
||||
if (!(valid = inputs[i].value)){
|
||||
for (var i=0; i<inputs.val().length; i++){
|
||||
if (!(valid = inputStr[i])){
|
||||
enable_import_btn(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
enable_import_btn(true);
|
||||
if (valid) {
|
||||
if ($("#local-dir-radio").prop("checked") && localDirPath.val().length > 0) {
|
||||
enable_import_btn(true);
|
||||
}
|
||||
if ($("#git-repo-radio").prop("checked") && vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
|
||||
enable_import_btn(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (inputs.val().length == 0)
|
||||
enable_import_btn(false);
|
||||
}
|
||||
|
||||
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.vcs_url);
|
||||
dupLayerInfo.find("#dup-layer-revision").text(layer.vcs_reference);
|
||||
|
||||
if (layer.local_source_dir) {
|
||||
$("#git-layer-dup").hide();
|
||||
$("#local-layer-dup").fadeIn();
|
||||
dupLayerInfo.find(".dup-layer-name").text(layer.name);
|
||||
dupLayerInfo.find(".dup-layer-link").attr("href", layer.layerdetailurl);
|
||||
dupLayerInfo.find("#dup-local-source-dir-name").text(layer.local_source_dir);
|
||||
} else {
|
||||
$("#git-layer-dup").fadeIn();
|
||||
$("#local-layer-dup").hide();
|
||||
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.vcs_url);
|
||||
dupLayerInfo.find("#dup-layer-revision").text(layer.vcs_reference);
|
||||
}
|
||||
$(".fields-apart-from-layer-name").fadeOut(function(){
|
||||
|
||||
dupLayerInfo.fadeIn();
|
||||
@@ -271,10 +303,13 @@ function importLayerPageInit (ctx) {
|
||||
|
||||
if ($("#duplicate-layer-info").css("display") != "None"){
|
||||
$("#duplicate-layer-info").fadeOut(function(){
|
||||
$(".fields-apart-from-layer-name").show();
|
||||
});
|
||||
$(".fields-apart-from-layer-name").show();
|
||||
radioDisplay();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
radioDisplay();
|
||||
|
||||
/* Don't remove the error class if we're displaying the error for another
|
||||
* reason.
|
||||
@@ -301,4 +336,72 @@ function importLayerPageInit (ctx) {
|
||||
}
|
||||
});
|
||||
|
||||
function radioDisplay() {
|
||||
if ($('input[name=repo]:checked').val() == "local") {
|
||||
$('#git-repo').hide();
|
||||
$('#import-git-layer-and-add-hint').hide();
|
||||
$('#local-dir').fadeIn();
|
||||
$('#import-local-dir-and-add-hint').fadeIn();
|
||||
} else {
|
||||
$('#local-dir').hide();
|
||||
$('#import-local-dir-and-add-hint').hide();
|
||||
$('#git-repo').fadeIn();
|
||||
$('#import-git-layer-and-add-hint').fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
$('input:radio[name="repo"]').change(function() {
|
||||
radioDisplay();
|
||||
if ($("#local-dir-radio").prop("checked")) {
|
||||
if (localDirPath.val().length > 0) {
|
||||
enable_import_btn(true);
|
||||
} else {
|
||||
enable_import_btn(false);
|
||||
}
|
||||
}
|
||||
if ($("#git-repo-radio").prop("checked")) {
|
||||
if (vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
|
||||
enable_import_btn(true);
|
||||
} else {
|
||||
enable_import_btn(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
localDirPath.on('input', function(){
|
||||
if ($(this).val().trim().length == 0) {
|
||||
$('#import-and-add-btn').attr("disabled","disabled");
|
||||
$('#local-dir').addClass('has-error');
|
||||
$('#hintError-dir-abs-path').show();
|
||||
$('#hintError-dir-path-starts-with-slash').show();
|
||||
} else {
|
||||
var input = $(this);
|
||||
var reBeginWithSlash = /^\//;
|
||||
var reCheckVariable = /^\$/;
|
||||
var re = /([ <>\\|":\.%\?\*]+)/;
|
||||
|
||||
var invalidDir = re.test(input.val());
|
||||
var invalidSlash = reBeginWithSlash.test(input.val());
|
||||
var invalidVar = reCheckVariable.test(input.val());
|
||||
|
||||
if (!invalidSlash && !invalidVar) {
|
||||
$('#local-dir').addClass('has-error');
|
||||
$('#import-and-add-btn').attr("disabled","disabled");
|
||||
$('#hintError-dir-abs-path').show();
|
||||
$('#hintError-dir-path-starts-with-slash').show();
|
||||
} else if (invalidDir) {
|
||||
$('#local-dir').addClass('has-error');
|
||||
$('#import-and-add-btn').attr("disabled","disabled");
|
||||
$('#hintError-dir-path').show();
|
||||
} else {
|
||||
$('#local-dir').removeClass('has-error');
|
||||
if (layerNameInput.val().length > 0) {
|
||||
$('#import-and-add-btn').removeAttr("disabled");
|
||||
}
|
||||
$('#hintError-dir-abs-path').hide();
|
||||
$('#hintError-dir-path-starts-with-slash').hide();
|
||||
$('#hintError-dir-path').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user