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)

    Details

    • Similar Issues:

      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

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

          Show
          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.
          Hide
          jglick Jesse Glick added a comment -

          Also in 1.509.4.

          Show
          jglick Jesse Glick added a comment - Also in 1.509.4.
          Hide
          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
          
          Show
          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
          Hide
          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.

          Show
          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.
          Show
          jglick Jesse Glick added a comment - https://github.com/jenkinsci/credentials-plugin/commit/23fc1cbbe4a73e33f062b3c588bab98b287ae8c9 is the difference.
          Hide
          jglick Jesse Glick added a comment -

          Try downgrading Credentials to 1.9.2.

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

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

          Show
          jglick Jesse Glick added a comment - if (! this ._events[type]) { ( element-debug.js:694 ) with -Ddebug.YUI=true .
          Hide
          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
          
          Show
          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
          Hide
          jglick Jesse Glick added a comment -

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

          Show
          jglick Jesse Glick added a comment - The 404 seems to be the result of an improper incremental build; fixed by clean build.
          Hide
          jglick Jesse Glick added a comment -
          Show
          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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: