editor: fail gracefully when pulling without credentials set

This commit is contained in:
Nicolas Wavrant 2020-04-10 07:00:29 +02:00
parent 759a1a96b3
commit 9fe2b229ff
1 changed files with 25 additions and 12 deletions

View File

@ -219,19 +219,32 @@
if (event.target.getAttribute('name') == "short-action-pull-all") {
event.preventDefault();
return gadget.startLongActionNotification()
.push(function () {
return gadget.getDeclaredGadget("storage");
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getParameter("username"),
gadget.getParameter("password")
]);
}).push(function(credential_list) {
if (!credential_list[0] && !credential_list[1]) {
window.alert("Credentials should be set before pulling.");
} else {
return gadget.startLongActionNotification()
.push(function () {
return gadget.getDeclaredGadget("storage");
})
.push(function (storage_gadget) {
return storage_gadget.pullEverything();
})
.push(function () {
return gadget.displayResourceList();
})
.push(function () {
return gadget.stopLongActionNotification();
});
}
return;
})
.push(function (storage_gadget) {
return storage_gadget.pullEverything();
})
.push(function () {
return gadget.displayResourceList();
})
.push(function () {
return gadget.stopLongActionNotification();
})
}
else if (event.target.getAttribute('name') == "short-action-push-all") {
event.preventDefault();