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

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

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

            Dates

              Created:
              Updated:
              Resolved: