diff --git a/.gitignore b/.gitignore index 470785b2..dbb96188 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /npm-debug.log /less/fonts/octicon.css /git.log +/src/Ftp/styles/ftp.css diff --git a/htmlContent/git-remotes-picker.html b/htmlContent/git-remotes-picker.html index 4d18961e..f8da8940 100644 --- a/htmlContent/git-remotes-picker.html +++ b/htmlContent/git-remotes-picker.html @@ -2,7 +2,7 @@ {{#remotes}}
  • - {{#deletable}}×{{/deletable}} + {{#deletable}}×{{/deletable}} {{name}}
  • diff --git a/less/brackets-git.less b/less/brackets-git.less index b20cc232..0ae0819c 100644 --- a/less/brackets-git.less +++ b/less/brackets-git.less @@ -240,7 +240,7 @@ display: inline-block; width: 100%; } - .trash-icon { + .hover-icon { opacity: 0; background-image: none !important; width: 16px; @@ -254,17 +254,11 @@ font-weight: bold; } } - &:hover .trash-icon { + &:hover .hover-icon { opacity: 1; } } - a[data-type=ftp] .change-remote:before, span[data-type=ftp]:before { - content: "FTP:"; - padding-right: 5px; - opacity: 0.5; - } - .dropdown-menu { border: none; border-radius: @tc-control-border-radius; @@ -299,7 +293,7 @@ cursor: default; } - .gitftp-remote-new, .git-remote-new { + li:not(".remote"):not(".divider"):not(".dropdown-header") > a { font-style: italic; } } @@ -339,6 +333,22 @@ background-repeat: repeat; -webkit-animation: btn-loading 1s linear infinite; } + + // Git-FTP styles, will be removed after S38, see /src/Ftp/styles/ftp.less + .git-remotes-dropdown { + .gitftp-init-remote { + position: relative; + top: 2px; + right: 4px; + } + } + + a[data-type=ftp] .change-remote:before, span[data-type=ftp]:before { + content: "FTP:"; + padding-right: 5px; + opacity: 0.5; + } + } @-webkit-keyframes btn-loading { diff --git a/nls/root/strings.js b/nls/root/strings.js index 5a60ffd0..1f0c81da 100644 --- a/nls/root/strings.js +++ b/nls/root/strings.js @@ -35,7 +35,7 @@ define({ CLONE_REPOSITORY: "Clone repository", CREATE_NEW_BRANCH: "Create new branch\u2026", CREATE_NEW_REMOTE: "Create new remote\u2026", - CREATE_NEW_GITFTP_REMOTE: "Create new Git-FTP remote\u2026", + CREATE_NEW_GITFTP_SCOPE: "Create new Git-FTP remote\u2026", CUSTOM_TERMINAL_COMMAND: "Custom terminal command (sample: gnome-terminal or complete path to executable)", CUSTOM_TERMINAL_COMMAND_HINT: "Sample arguments: --window --working-directory=$1
    $1 in arguments will be replaced by current project directory.", DATE_FORMAT: "YYYY-MM-DD HH:mm:ss", @@ -57,9 +57,9 @@ define({ ENTER_USERNAME: "Enter username:", ENTER_REMOTE_GIT_URL: "Enter Git URL of the repository you want to clone:", ENTER_REMOTE_NAME: "Enter name of the new remote:", - ENTER_GITFTP_REMOTE_NAME: "Enter name of the new Git-FTP remote:", + ENTER_GITFTP_SCOPE_NAME: "Enter name of the new Git-FTP remote:", ENTER_REMOTE_URL: "Enter URL of the new remote:", - ENTER_GITFTP_REMOTE_URL: "Enter FTP URL of the new Git-FTP remote specifing username and password:", + ENTER_GITFTP_SCOPE_URL: "Enter FTP URL of the new Git-FTP remote specifing username and password:", ERROR_TERMINAL_NOT_FOUND: "Terminal was not found for your OS, you can define a custom Terminal command in the settings", EXTENDED_COMMIT_MESSAGE: "EXTENDED", EXTENSION_WAS_UPDATED_TITLE: "The extension was updated to {0}", @@ -84,10 +84,11 @@ define({ GITFTP_PUSH_RESPONSE: "Git-FTP Push response", GIT_SETTINGS: "Git Settings\u2026", GIT_REMOTES: "Git remotes", - GITFTP_REMOTES: "Git-FTP remotes", + GITFTP_SCOPES: "Git-FTP remotes", GOTO_PREVIOUS_GIT_CHANGE: "Go to previous Git change", GOTO_NEXT_GIT_CHANGE: "Go to next Git change", - INIT_GITFTP_REMOTE_NAME: "Initialize Git-FTP remote \"{0}\"?", + INIT_GITFTP_SCOPE: "Initialize Git-FTP remote", + INIT_GITFTP_SCOPE_NAME: "Initialize Git-FTP remote \"{0}\"?", LAUNCH_BASH_SHORTCUT: "Bash/Terminal shortcut", LOADING: "Loading\u2026", LINES: "Lines", diff --git a/src/Ftp/Ftp.js b/src/Ftp/Ftp.js index 6aaab7b3..7cf58bbe 100644 --- a/src/Ftp/Ftp.js +++ b/src/Ftp/Ftp.js @@ -16,7 +16,7 @@ define(function (require) { GitFtp = require("./GitFtp"); // Module variables - var ftpRemotesTemplate = require("text!src/Ftp/templates/remotes-picker.html"), + var ftpScopesTemplate = require("text!src/Ftp/templates/remotes-picker.html"), $gitPanel = null, $remotesDropdown = null; @@ -24,8 +24,9 @@ define(function (require) { var attachEvents = _.once(function () { $gitPanel - .on("click", ".gitftp-remote-new", handleGitFtpRemoteCreation) - .on("click", ".gitftp-remove-remote", function () { handleGitFtpRemoteRemove($(this)); }) + .on("click", ".gitftp-remote-new", function () { handleGitFtpScopeCreation(); }) + .on("click", ".gitftp-remove-remote", function () { handleGitFtpScopeRemove($(this)); }) + .on("click", ".gitftp-init-remote", function () { handleGitFtpInitScope($(this)); }) .on("click", ".gitftp-push", handleGitFtpPush); }); @@ -38,10 +39,10 @@ define(function (require) { } function handleGitFtpPush() { - var gitFtpRemote = $gitPanel.find(".git-remote-selected").text().trim(); + var gitFtpScope = $gitPanel.find(".git-remote-selected").text().trim(); $gitPanel.find(".gitftp-push").prop("disabled", true).addClass("btn-loading"); - GitFtp.push(gitFtpRemote).done(function (result) { + GitFtp.push(gitFtpScope).done(function (result) { Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_INFO, Strings.GITFTP_PUSH_RESPONSE, // title @@ -56,16 +57,16 @@ define(function (require) { }); } - function handleGitFtpRemoteCreation() { + function handleGitFtpScopeCreation() { $gitPanel.find(".git-remotes") .addClass("btn-loading") .prop("disabled", true); - return Utils.askQuestion(Strings.CREATE_GITFTP_NEW_REMOTE, Strings.ENTER_GITFTP_REMOTE_NAME) + return Utils.askQuestion(Strings.CREATE_GITFTP_NEW_SCOPE, Strings.ENTER_GITFTP_SCOPE_NAME) .then(function (name) { return Utils.askQuestion( - Strings.CREATE_GITFTP_NEW_REMOTE, - Strings.ENTER_GITFTP_REMOTE_URL, + Strings.CREATE_GITFTP_NEW_SCOPE, + Strings.ENTER_GITFTP_SCOPE_URL, {defaultValue: "ftp://user:passwd@example.org/folder"} ) .then(function (url) { @@ -73,25 +74,25 @@ define(function (require) { // Render the list element of the new remote // TODO: replace this part with a way to call `Remotes.refreshRemotesPicker()` - var $newRemote = $("
  • ") - .addClass("gitftp-remote") - .append("") - .find("a") - .attr({href: "#", "data-remote-name": name, "data-type": "ftp"}) - .addClass("remote-name") - .append("") - .find("span") - .addClass("trash-icon gitftp-remove-remote") - .html("×") - .end() - .append("") - .find("span:nth-child(2)") - .addClass("change-remote") - .text(name) - .end() - .end(); - - $gitPanel.find(".git-remotes-dropdown .ftp-remotes-header").after($newRemote); + var $newScope = $("
  • ") + .addClass("gitftp-remote") + .append("") + .find("a") + .attr({href: "#", "data-remote-name": name, "data-type": "ftp"}) + .addClass("remote-name") + .append("") + .find("span") + .addClass("trash-icon gitftp-remove-remote") + .html("×") + .end() + .append("") + .find("span:nth-child(2)") + .addClass("change-remote") + .text(name) + .end() + .end(); + + $gitPanel.find(".git-remotes-dropdown .ftp-remotes-header").after($newScope); }).catch(function (err) { ErrorHandler.showError(err, "Git-FTP remote creation failed"); @@ -105,25 +106,25 @@ define(function (require) { }); } - function handleGitFtpRemoteRemove($this) { + function handleGitFtpScopeRemove($this) { $gitPanel.find(".git-remotes") .addClass("btn-loading") .prop("disabled", true); var $selectedElement = $this.closest(".remote-name"), - $currentRemote = $gitPanel.find(".git-remote-selected"), - remoteName = $selectedElement.data("remote-name"); + $currentScope = $gitPanel.find(".git-remote-selected"), + scopeName = $selectedElement.data("remote-name"); return Utils.askQuestion( - Strings.DELETE_REMOTE, - StringUtils.format(Strings.DELETE_REMOTE_NAME, remoteName), + Strings.DELETE_SCOPE, + StringUtils.format(Strings.DELETE_SCOPE_NAME, scopeName), {booleanResponse: true} ).then(function (response) { if (response) { - return GitFtp.removeScope(remoteName).then(function () { + return GitFtp.removeScope(scopeName).then(function () { $selectedElement.parent().remove(); - var newRemote = $gitPanel.find(".git-remotes-dropdown .remote").first().find("a").data("remote-name"); - $currentRemote.data("remote-name", newRemote).html(newRemote); + var newScope = $gitPanel.find(".git-remotes-dropdown .remote").first().find("a").data("remote-name"); + $currentScope.data("remote-name", newScope).html(newScope); }).catch(function (err) { ErrorHandler.showError(err, "Remove scope failed"); }); @@ -135,16 +136,40 @@ define(function (require) { }); } - function addFtpRemotesToPicker() { - GitFtp.getRemotes().then(function (ftpRemotes) { + function handleGitFtpInitScope($this) { + $gitPanel.find(".git-remotes") + .addClass("btn-loading") + .prop("disabled", true); + + var $selectedElement = $this.closest(".remote-name"), + scopeName = $selectedElement.data("remote-name"); + + return Utils.askQuestion( + Strings.INIT_GITFTP_SCOPE, + StringUtils.format(Strings.INIT_GITFTP_SCOPE_NAME, scopeName), + {booleanResponse: true} + ).then(function (response) { + if (response) { + return GitFtp.init(scopeName).catch(function (err) { + ErrorHandler.showError(err, "Init scope failed"); + }); + } + }).finally(function () { + $gitPanel.find(".git-remotes") + .removeClass("btn-loading") + .prop("disabled", false); + }); + } + + function addFtpScopesToPicker() { + GitFtp.getScopes().then(function (ftpScopes) { // Pass to Mustache the needed data - var compiledTemplate = Mustache.render(ftpRemotesTemplate, { + var compiledTemplate = Mustache.render(ftpScopesTemplate, { Strings: Strings, - ftpRemotes: ftpRemotes, - hasFtpRemotes: ftpRemotes.length > 0 + ftpScopes: ftpScopes, + hasFtpScopes: ftpScopes.length > 0 }); - $remotesDropdown.prepend(compiledTemplate); }).catch(function (err) { @@ -158,7 +183,7 @@ define(function (require) { }); EventEmitter.on(Events.REMOTES_REFRESH_PICKER, function () { - addFtpRemotesToPicker(); + addFtpScopesToPicker(); }); }); diff --git a/src/Ftp/GitFtp.js b/src/Ftp/GitFtp.js index b4955ce4..1e609db9 100644 --- a/src/Ftp/GitFtp.js +++ b/src/Ftp/GitFtp.js @@ -22,7 +22,7 @@ define(function (require, exports) { return git(["ftp", "push", "--scope", scope]); } - function getRemotes() { + function getScopes() { return git(["config", "--list"]).then(function (stdout) { return stdout.split("\n").reduce(function (result, row) { var io = row.indexOf(".url"); @@ -64,10 +64,10 @@ define(function (require, exports) { } // Public API - exports.init = init; - exports.push = push; - exports.getRemotes = getRemotes; - exports.addScope = addScope; + exports.init = init; + exports.push = push; + exports.getScopes = getScopes; + exports.addScope = addScope; exports.removeScope = removeScope; }); diff --git a/src/Ftp/styles/ftp.less b/src/Ftp/styles/ftp.less new file mode 100644 index 00000000..98b59bc3 --- /dev/null +++ b/src/Ftp/styles/ftp.less @@ -0,0 +1,17 @@ +#git-panel { + + .git-remotes-dropdown { + .gitftp-init-remote { + position: relative; + top: 2px; + right: 4px; + } + } + + a[data-type=ftp] .change-remote:before, span[data-type=ftp]:before { + content: "FTP:"; + padding-right: 5px; + opacity: 0.5; + } + +} diff --git a/src/Ftp/templates/remotes-picker.html b/src/Ftp/templates/remotes-picker.html index 5a436178..4c930cb3 100644 --- a/src/Ftp/templates/remotes-picker.html +++ b/src/Ftp/templates/remotes-picker.html @@ -1,15 +1,16 @@ -
  • -{{#hasFtpRemotes}} -{{#ftpRemotes}} + +{{#hasFtpScopes}} +{{#ftpScopes}}
  • - × + × {{name}} +
  • -{{/ftpRemotes}} -{{/hasFtpRemotes}} -
  • {{Strings.CREATE_NEW_GITFTP_REMOTE}}
  • +{{/ftpScopes}} +{{/hasFtpScopes}} +
  • {{Strings.CREATE_NEW_GITFTP_SCOPE}}