Skip to content
Snippets Groups Projects

Fix "Cannot move project" error message from popping up after a successful transfer

Merged Stan Hu requested to merge stanhu/gitlab-ce:fix-cannot-move-project-error into master

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".

image

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Stan Hu Added 1 commit:

    Added 1 commit:

    • 978892a3 - Fix "Cannot move project" error message from popping up after a successful project transfer
  • Stan Hu Added 1 commit:

    Added 1 commit:

    • fe7f266c - Fix "Cannot move project" error message from popping up after a successful project transfer
  • Any reason we shouldn't just use jQuery's one method and remove both the off and on calls?

  • Author Maintainer

    @rspeicher, one would only work for the submission button click handler, but not for the input 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 the off for both, leaving on for the input. (Disclaimer: I haven't tested any of this)

  • Stan Hu Added 1 commit:

    Added 1 commit:

    • 958cd0cd - Use one instead of off and on
  • Stan Hu Added 1 commit:

    Added 1 commit:

    • e237f78b - Revert one; this does not work
  • Author Maintainer

    @rspeicher, actually one doesn't work here. The issue is that the ConfirmDangerModal 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. The one 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.

  • Stan Hu Added 1 commit:

    Added 1 commit:

    • 6fb1e80a - Fix "Cannot move project" error message from popping up after a successful project transfer
  • Stan Hu mentioned in issue #1438 (closed)

    mentioned in issue #1438 (closed)

  • Douwe Maan
    Douwe Maan @DouweM started a thread on the diff
173 173 $(@).closest(".diff-file").find(".notes_holder").toggle()
174 174 e.preventDefault()
175 175
176 $(document).off "click", '.js-confirm-danger'
  • Do we need this one?

  • Author Maintainer

    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 other off() calls mask the problem, but if you look at the debugger, you will see that the ConfirmDangerDialog 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.

  • Douwe Maan Status changed to merged

    Status changed to merged

  • Douwe Maan mentioned in commit 2400181a

    mentioned in commit 2400181a

  • Please register or sign in to reply
    Loading