Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-20647

<c:select/> inside <f:hetero-list> throws Uncaught TypeError: Cannot read property 'click' of undefined (multiple-scms + mercurial)

    XMLWordPrintable

Details

    Description

      I can't add Mercurial repository using Multiple SCMs. When I click "Mercurial" in the drop-down list "Add SCM", nothing happens and I can see in Chrome console the error message:

      Uncaught TypeError: Cannot read property 'click' of undefined (element-min.js:7)

      Adding Subversion and CVS repos works well, the problem only with mercurial.

      Attachments

        Activity

          soid Greg Temchenko created issue -
          soid Greg Temchenko made changes -
          Field Original Value New Value
          Environment Jenkins v1.534, Google Chrome and Safari.
          dewanj Jeff DeWan added a comment -

          I am experiencing the same behavior with a similar TypeError message in Firefox 25.0.1:

          TypeError: this._events is undefined
          	
          
          ...resetConfig();},subscribe:function(b,c){this._events=this._events||{};if(!(b in ...
          
          element-min.js (line 7)
          

          The Jenkins server is v1.541. I can add other repository types (svn, git, cvs) just fine, only Mercurial seems to be a problem.

          dewanj Jeff DeWan added a comment - I am experiencing the same behavior with a similar TypeError message in Firefox 25.0.1: TypeError: this._events is undefined ...resetConfig();},subscribe:function(b,c){this._events=this._events||{};if(!(b in ... element-min.js (line 7) The Jenkins server is v1.541. I can add other repository types (svn, git, cvs) just fine, only Mercurial seems to be a problem.
          jglick Jesse Glick added a comment -

          Also in 1.509.4.

          jglick Jesse Glick added a comment - Also in 1.509.4.
          jglick Jesse Glick made changes -
          Component/s mercurial [ 15502 ]
          Labels javascript
          jglick Jesse Glick added a comment -

          Reproducible in standalone 1.509.4 with Mercurial and Multiple SCMs plugins installed, though not from hpi:run in the Mercurial plugin.

          Uncaught TypeError: Cannot read property 'click' of undefined @ element-min.js:7
          a.addListener @ element-min.js:7
          makeButton @ hudson-behavior.js:480
          
          function makeButton(e,onclick) {
              var h = e.onclick;
              var clsName = e.className;
              var n = e.name;
              var btn = new YAHOO.widget.Button(e,{});
              if(onclick!=null)
                  btn.addListener("click",onclick); // HERE
          
          jglick Jesse Glick added a comment - Reproducible in standalone 1.509.4 with Mercurial and Multiple SCMs plugins installed, though not from hpi:run in the Mercurial plugin. Uncaught TypeError: Cannot read property 'click' of undefined @ element-min.js:7 a.addListener @ element-min.js:7 makeButton @ hudson-behavior.js:480 function makeButton(e,onclick) { var h = e.onclick; var clsName = e.className; var n = e.name; var btn = new YAHOO.widget.Button(e,{}); if (onclick!= null ) btn.addListener( "click" ,onclick); // HERE
          jglick Jesse Glick added a comment -

          The difference is the use of <c:select/> (at the recommendation of @stephenc) rather than plain <f:select/>. No clue why that would break something in JavaScript; the difference should only be on the server side.

          jglick Jesse Glick added a comment - The difference is the use of <c:select/> (at the recommendation of @stephenc) rather than plain <f:select/> . No clue why that would break something in JavaScript; the difference should only be on the server side.
          jglick Jesse Glick added a comment - https://github.com/jenkinsci/credentials-plugin/commit/23fc1cbbe4a73e33f062b3c588bab98b287ae8c9 is the difference.
          jglick Jesse Glick made changes -
          Component/s credentials [ 16523 ]
          Component/s mercurial [ 15502 ]
          Component/s multiple-scms [ 15810 ]
          Assignee Kevin Bell [ kbell ] stephenconnolly [ stephenconnolly ]
          jglick Jesse Glick made changes -
          Summary Uncaught TypeError: Cannot read property 'click' of undefined (when trying to add mercurial repo) <c:select/> inside <f:hetero-list> throws Uncaught TypeError: Cannot read property 'click' of undefined (multiple-scms + mercurial)
          jglick Jesse Glick added a comment -

          Try downgrading Credentials to 1.9.2.

          jglick Jesse Glick added a comment - Try downgrading Credentials to 1.9.2.
          jglick Jesse Glick added a comment -
          if (!this._events[type]) {
          

          (element-debug.js:694) with -Ddebug.YUI=true.

          jglick Jesse Glick added a comment - if (! this ._events[type]) { ( element-debug.js:694 ) with -Ddebug.YUI=true .
          jglick Jesse Glick added a comment -
          diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly
          index 9ba0184..66a4c5e 100644
          --- a/src/main/resources/lib/credentials/select.jelly
          +++ b/src/main/resources/lib/credentials/select.jelly
          @@ -47,25 +47,22 @@
             <f:select style="width:90%" clazz="${attrs.clazz} credentials-select" field="${attrs.field}"
                       default="${attrs.default}"/>
             <!-- TODO  add support for checking permissions against stores in request path -->
          +  <j:set var="buttonId" value="${h.generateId()}"/>
          +  <st:nbsp/>
             <j:choose>
               <j:when test="${h.hasPermission(app.getDescriptorByName('com.cloudbees.plugins.credentials.CredentialsSelectHelper').CREATE)}">
          -      <j:set var="buttonId" value="${h.generateId()}"/>
          -      <st:nbsp/>
                 <button id="${buttonId}" type="button" onclick="return window.credentials.add();">
                   <img src="${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/>
                   ${%Add}
                 </button>
          -      <script>makeButton($('${buttonId}'), window.credentials.add)</script>
               </j:when>
               <j:otherwise>
                 <st:nbsp/>
          -      <button id="${buttonId}" type="button" onclick="return window.credentials.add();" disabled="disabled">
          +      <button id="${buttonId}" type="button" disabled="disabled">
                   <img src="${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/>
                   ${%Add}
                 </button>
          -      <script>makeButton($('${buttonId}'), function () {
          -        return false;
          -      })</script>
               </j:otherwise>
             </j:choose>
          +  <script>makeButton($('${buttonId}'))</script>
           </j:jelly>
          \ No newline at end of file
          

          prevents this error when inside the Multiple SCMs section, but makes the button do nothing at all when used normally. Anyway, without this patch, when used normally (or with the patch, when used inside Multiple SCMs) the button does not work, for an apparently unrelated reason:

          GET http://localhost:8080/descriptor/com.cloudbees.plugins.credentials.CredentialsSelectHelper/dialog 404 (Not Found) @ prototype.js:1585
          Ajax.Request.Class.create.request @ prototype.js:1585
          Ajax.Request.Class.create.initialize @ prototype.js:1550
          (anonymous function) @ prototype.js:452
          klass @ prototype.js:101
          window.credentials.add @ select.js:23
          
          jglick Jesse Glick added a comment - diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index 9ba0184..66a4c5e 100644 --- a/src/main/resources/lib/credentials/select.jelly +++ b/src/main/resources/lib/credentials/select.jelly @@ -47,25 +47,22 @@ <f:select style= "width:90%" clazz= "${attrs.clazz} credentials-select" field= "${attrs.field}" default= "${attrs.default}" /> <!-- TODO add support for checking permissions against stores in request path --> + <j:set var= "buttonId" value= "${h.generateId()}" /> + <st:nbsp/> <j:choose> <j:when test= "${h.hasPermission(app.getDescriptorByName( 'com.cloudbees.plugins.credentials.CredentialsSelectHelper' ).CREATE)}" > - <j:set var= "buttonId" value= "${h.generateId()}" /> - <st:nbsp/> <button id= "${buttonId}" type= "button" onclick= "return window.credentials.add();" > <img src= "${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/> ${%Add} </button> - <script> makeButton($( '${buttonId}' ), window.credentials.add) </script> </j:when> <j:otherwise> <st:nbsp/> - <button id= "${buttonId}" type= "button" onclick= "return window.credentials.add();" disabled= "disabled" > + <button id= "${buttonId}" type= "button" disabled= "disabled" > <img src= "${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/> ${%Add} </button> - <script> makeButton($( '${buttonId}' ), function () { - return false; - }) </script> </j:otherwise> </j:choose> + <script> makeButton($( '${buttonId}' )) </script> </j:jelly> \ No newline at end of file prevents this error when inside the Multiple SCMs section, but makes the button do nothing at all when used normally. Anyway, without this patch, when used normally (or with the patch, when used inside Multiple SCMs) the button does not work, for an apparently unrelated reason: GET http://localhost:8080/descriptor/com.cloudbees.plugins.credentials.CredentialsSelectHelper/dialog 404 (Not Found) @ prototype.js:1585 Ajax.Request.Class.create.request @ prototype.js:1585 Ajax.Request.Class.create.initialize @ prototype.js:1550 (anonymous function) @ prototype.js:452 klass @ prototype.js:101 window.credentials.add @ select.js:23
          jglick Jesse Glick added a comment -

          The 404 seems to be the result of an improper incremental build; fixed by clean build.

          jglick Jesse Glick added a comment - The 404 seems to be the result of an improper incremental build; fixed by clean build.
          jglick Jesse Glick made changes -
          Assignee stephenconnolly [ stephenconnolly ] Jesse Glick [ jglick ]
          jglick Jesse Glick made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          jglick Jesse Glick made changes -
          Assignee Jesse Glick [ jglick ] stephenconnolly [ stephenconnolly ]
          jglick Jesse Glick added a comment - Seems to have been fixed in 1.9.4 by a different approach: https://github.com/jenkinsci/credentials-plugin/commit/07978d5c546329ff3301e28a11821897ee461d4a
          jglick Jesse Glick made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]
          stephenconnolly Stephen Connolly made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 152456 ] JNJira + In-Review [ 207172 ]

          People

            stephenconnolly Stephen Connolly
            soid Greg Temchenko
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: