diff --git a/editor/js/ui/projects/projectSettings.js b/editor/js/ui/projects/projectSettings.js index 0f9f009d9..bd3582a37 100644 --- a/editor/js/ui/projects/projectSettings.js +++ b/editor/js/ui/projects/projectSettings.js @@ -1193,12 +1193,19 @@ RED.projects.settings = (function() { editRepoButton.attr('disabled',true); addRemoteDialog.slideDown(200, function() { addRemoteDialog[0].scrollIntoView(); + if (isEmpty) { + remoteNameInput.val('origin'); + remoteURLInput.focus(); + } else { + remoteNameInput.focus(); + } validateForm(); }); }); var emptyItem = { empty: true }; + var isEmpty = true; var row = $('
').appendTo(repoContainer); var addRemoteDialog = $('').hide().appendTo(row); row = $('').appendTo(repoContainer); @@ -1256,6 +1263,7 @@ RED.projects.settings = (function() { setTimeout(spinner.remove, 100); if (data.remotes.length === 0) { delete activeProject.git.remotes; + isEmpty = true; remotesList.editableList('addItem',emptyItem); } else { activeProject.git.remotes = {}; @@ -1290,16 +1298,26 @@ RED.projects.settings = (function() { var validateForm = function() { var validName = /^[a-zA-Z0-9\-_]+$/.test(remoteNameInput.val()); + var repo = remoteURLInput.val(); // var validRepo = /^(?:file|git|ssh|https?|[\d\w\.\-_]+@[\w\.]+):(?:\/\/)?[\w\.@:\/~_-]+(?:\.git)?(?:\/?|\#[\d\w\.\-_]+?)$/.test(remoteURLInput.val()); - var validRepo = !/\s/.test(remoteURLInput.val()); + var validRepo = repo.length > 0 && !/\s/.test(repo); + if (/^https?:\/\/[^/]+@/i.test(repo)) { + remoteURLLabel.text("Do not include the username/password in the url"); + validRepo = false; + } else { + remoteURLLabel.text("https://, ssh:// or file://"); + } saveButton.attr('disabled',(!validName || !validRepo)) remoteNameInput.toggleClass('input-error',remoteNameInputChanged&&!validName); + remoteURLInput.toggleClass('input-error',remoteURLInputChanged&&!validRepo); if (popover) { popover.close(); popover = null; } }; var popover; + var remoteNameInputChanged = false; + var remoteURLInputChanged = false; $('