Fix "Cannot move project" error message from popping up after a successful transfer
The JavaScript click handlers were never being removed, leading to duplicate requests when attempting to transfer a project to another namespace. The first transfer would succeed but the subsequent ones would fail, leading to the error message saying, "Cannot move project".
I attempted to write a unit test for this, but it was taking me too long to get it right.
Closes #1448 (closed) and #1128 (closed)
Merge request reports
Activity
Any reason we shouldn't just use jQuery's one method and remove both the
off
andon
calls?@rspeicher,
one
would only work for the submission button click handler, but not for theinput
handler or the main Transfer button. The latter two need to be fired multiple times.@stanhu The button firing multiple times is the actual cause of the issue though, right? I would think you could change the button handler to
one
and remove theoff
for both, leavingon
for the input. (Disclaimer: I haven't tested any of this)@rspeicher, actually
one
doesn't work here. The issue is that theConfirmDangerModal
is instantiated and its click handlers are always bound each time the Transfer button is hit. Suppose you click Transfer, change your mind, and cancel. Theone
semantics just says to fire this handler once. In this case, the handler is never fired, but it is still bound. Clicking the Transfer button again will bind another event handler.I also tried unbinding all children event handlers upon destruction of the modal, but this apparently doesn't work because those div elements aren't direct children of the modal.
@stanhu Ok, thanks for trying.
Added 1 commit:
- 6fb1e80a - Fix "Cannot move project" error message from popping up after a successful project transfer
mentioned in issue #1438 (closed)
173 173 $(@).closest(".diff-file").find(".notes_holder").toggle() 174 174 e.preventDefault() 175 175 176 $(document).off "click", '.js-confirm-danger' One of the causes of the multiple transfer attempts is the document has multiple event handlers bound to the
.js-confirm-danger
element. Technically, the otheroff()
calls mask the problem, but if you look at the debugger, you will see that theConfirmDangerDialog
box can be instantiated multiple times if you revisit the same page.Looks like you're right. I was under the impression that the
$ ->
section was only executed once, at first load of the page, but apparently we're using https://github.com/kossnocorp/jquery.turbolinks which messes with that. Oh well.
@stanhu I've pinged our ops guys about the "Cannot connect to the CI server." error. I'll merge when it's working again and green.
mentioned in commit 2400181a