zendesk/samson

Review button is disabled if git reference not entered quickly enough

alongwill opened this issue · 3 comments

On upgrading from v2206 to v3171 we've noticed the "Review" button is often disabled if the git reference is not entered quickly enough.
samson_review3

If one of the existing references (e.g. master or 92c4047 in the screenshot) is clicked then the "Review" button will be enabled.

As I type in the reference I can see the commit_statuses API calls happening and returning successfully for valid references, so the github API is responding correctly.
commit_statuses

This problem is occurring in Firefox 77.0.1 and Chrome 83.0.4103.97 on Mac OS.

yeah, I've seen this happen but was never able to reproduce it, I'll take a look ...

I think the problem may be responses to the ajax call in check_status coming back out of sequence. https://github.com/zendesk/samson/blob/master/app/assets/javascripts/ref_status_typeahead.js#L59
I added console.log lines to debug this:

$.ajax({
      url: $("#new_deploy").data("commit-status-url"),
      data: { ref: ref },
      success: function(response) {
        $reference.removeClass("loading");
        switch(response.state) {
          case "success":
            console.log("    check_status 1 " + response.state + "-" + ref);
            $ref_status_container.addClass("hidden");
            $tag_form_group.addClass("has-success");
            break;
          case "pending":
          case "missing":
            console.log("    check_status 2 " + response.state + "-" + ref);
            $tag_form_group.addClass("has-warning");
            show_status_problems(response.statuses, false);
            break;
          case "failure":
          case "error":
            console.log("    check_status 3 " + response.state + "-" + ref);
            $tag_form_group.addClass("has-error");
            show_status_problems(response.statuses, false);
            break;
          case "fatal":
            console.log("    check_status 4 " + response.state + "-" + ref);
            $tag_form_group.addClass("has-error");
            $submit_button.prop("disabled", true);
            show_status_problems(response.statuses, true);
            break;
          default:
            console.log("    check_status 5 " + response.state + "-" + ref);
            alert("Unexpected response: " + response.toString());
            break;
        }
      }
    });

I then typed in master and the developer console logged the following:

 check_status 4 fatal-m
 check_status 4 fatal-mas
 check_status 2 pending-master
 check_status 4 fatal-ma
 check_status 4 fatal-mast
 check_status 4 fatal-maste

If the last character of the reference (e.g. r in master) is typed after waiting about 3 seconds then the "Review" button shows.

fixed in #3818