Skip to content

Commit 29f60dd

Browse files
author
FezVrasta
committed
Fixed FTP remote creation.
1 parent 5d69164 commit 29f60dd

3 files changed

Lines changed: 45 additions & 19 deletions

File tree

htmlContent/git-remotes-picker.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- List of remotes defined for the current local repository -->
2-
{{#gitFtpEnabled}}<li class="dropdown-header">{{Strings.GIT_REMOTES}}</li>{{/gitFtpEnabled}}
2+
{{#gitFtpEnabled}}<li class="dropdown-header git-remotes-header">{{Strings.GIT_REMOTES}}</li>{{/gitFtpEnabled}}
33
{{#hasRemotes}}
44
{{#remotes}}
55
<li class="remote">
@@ -15,7 +15,7 @@
1515
{{#gitFtpEnabled}}
1616
<!-- List of Git-FTP remotes defined for the current local repository -->
1717
<li class="divider"></li>
18-
<li class="dropdown-header">{{Strings.GITFTP_REMOTES}}</li>
18+
<li class="dropdown-header ftp-remotes-header">{{Strings.GITFTP_REMOTES}}</li>
1919
{{#hasFtpRemotes}}
2020
{{#ftpRemotes}}
2121
<li class="gitftp-remote">

src/Ftp.js

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,48 @@ define(function (require) {
5757
.addClass("btn-loading")
5858
.prop("disabled", true);
5959

60-
return Utils.askQuestion(Strings.CREATE_GITFTP_NEW_REMOTE,
61-
Strings.ENTER_GITFTP_REMOTE_NAME).then(function (name) {
62-
return Utils.askQuestion(Strings.CREATE_GITFTP_NEW_REMOTE,
63-
Strings.ENTER_GITFTP_REMOTE_URL,
64-
{defaultValue: "ftp://user:passwd@example.org/folder"}).then(function (url) {
65-
66-
return GitFtp.addScope(name, url).then(function () {
67-
// return handleGitFtpRemoteInit();
68-
}).fail(function (err) {
69-
ErrorHandler.showError(err, "Git-FTP remote creation failed");
70-
});
71-
60+
return Utils.askQuestion(Strings.CREATE_GITFTP_NEW_REMOTE, Strings.ENTER_GITFTP_REMOTE_NAME)
61+
.then(function (name) {
62+
return Utils.askQuestion(
63+
Strings.CREATE_GITFTP_NEW_REMOTE,
64+
Strings.ENTER_GITFTP_REMOTE_URL,
65+
{defaultValue: "ftp://user:passwd@example.org/folder"}
66+
)
67+
.then(function (url) {
68+
return GitFtp.addScope(name, url).then(function () {
69+
70+
// Render the list element of the new remote
71+
// TODO: replace this part with a way to call `Remotes.refreshRemotesPicker()`
72+
var $newRemote = $("<li/>")
73+
.addClass("gitftp-remote")
74+
.append("<a/>")
75+
.find("a")
76+
.attr({href: "#", "data-remote-name": name, "data-type": "ftp"})
77+
.addClass("remote-name")
78+
.append("<span/>")
79+
.find("span")
80+
.addClass("trash-icon gitftp-remove-remote")
81+
.html("&times;")
82+
.end()
83+
.append("<span/>")
84+
.find("span:nth-child(2)")
85+
.addClass("change-remote")
86+
.text(name)
87+
.end()
88+
.end();
89+
90+
$gitPanel.find(".git-remotes-dropdown .ftp-remotes-header").after($newRemote);
91+
92+
}).fail(function (err) {
93+
ErrorHandler.showError(err, "Git-FTP remote creation failed");
94+
});
95+
});
96+
})
97+
.finally(function () {
98+
$gitPanel.find(".git-remotes")
99+
.removeClass("btn-loading")
100+
.prop("disabled", false);
72101
});
73-
}).finally(function () {
74-
$gitPanel.find(".git-remotes")
75-
.removeClass("btn-loading")
76-
.prop("disabled", false);
77-
});
78102
}
79103

80104
function handleGitFtpRemoteRemove($this) {

src/Remotes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ define(function (require) {
7575
}
7676

7777
function refreshRemotesPicker() {
78+
79+
// TODO: replace `settle` with `all` applying [this](https://github.com/zaggino/brackets-git/pull/288#issuecomment-38674930)
7880
// Run both getRemotes and getFtpRemotes and render with Mustache the template
7981
Promise.settle([Git.getRemotes(), GitFtp.getRemotes()]).spread(function (remotes, ftpRemotes) {
8082

0 commit comments

Comments
 (0)