Jakub Czaplicki edited a comment on Bug JENKINS-22311

I did some work on this. The idea is to hide the build parameters and only show them when a user clicks on the "pending—Build #..." string, with ability to hide the long string again (and later with ability to view/expand all hidden build parameters). The working example script of what I aim for is here: http://jsfiddle.net/jakubczaplicki/WT88W/

It required modification of two files (see diffs below).

I'd like a feedback and some suggestions/help on how to improve this code, such that it can be applied to master branch.

Some notes:

  • Tested on Jenkins ver. 1.565
  • Uses jQuery 1.7.2 (which is AFAIK default jQuery version built in jenkins)
  • Every N seconds the BuildHistory is being refreshed. After each refresh, the parameters are hidden again.
  • I am aware that I used deprecated jQuery's .live() method, however the suggestion on http://www.andismith.com/blog/2011/11/on-and-off/ didn't work.
  • Without .live(), the jQuery script stops working after the BuildHistory list refresh
  • Jenkins core modification is new to me, so my change may not be following coding standards.

Code:

diff --git a/core/src/main/resources/hudson/widgets/BuildHistoryWidget/entries.jelly b/core/src/main/resources/hudson/widgets/BuildHistoryWidget/entries.jelly
index e545724..4ffd3ac 100644
--- a/core/src/main/resources/hudson/widgets/BuildHistoryWidget/entries.jelly
+++ b/core/src/main/resources/hudson/widgets/BuildHistoryWidget/entries.jelly
@@ -47,6 +47,7 @@ THE SOFTWARE.
               <l:stopButton href="" class="code-quote">"${rootURL}/queue/cancelItem?id=${item.id}" alt="${%cancel this build}"/>
             </j:if>
           </div>
+          <div class="itemsummary" id="${id}">
           <j:set var="cause" value="${item.getCauseOfBlockage()}"/>
           <j:choose>
             <j:when test="${cause!=null}">
              (${%pending}—<st:include it="${cause}" page="summary.jelly"/>)
            </j:when>
            <j:otherwise>
               (${%pending})
             </j:otherwise>
           </j:choose>
-          ${item.params}
+          </div>
+          <div class="itemparams" id="${id}">${item.params}</div>
         </td>
       </tr>
     </j:forEach>

diff --git a/core/src/main/resources/lib/layout/layout.jelly b/core/src/main/resources/lib/layout/layout.jelly
index a8466f3..6168fb9 100644
--- a/core/src/main/resources/lib/layout/layout.jelly
+++ b/core/src/main/resources/lib/layout/layout.jelly
@@ -141,6 +140,11 @@ ${h.initPageVariables(context)}
     <j:forEach var="pd" items="${h.pageDecorators}">
       <st:include it="${pd}" page="header.jelly" optional="true" />
     </j:forEach>
+
+    <!-- itemparams == Pending Job Build Parameters -->
+    <style type="text/css"> div.itemparams { display:none; overflow: hidden; text-overflow: ellipsis; } </style>
+    <script>jQuery(document).ready(function() { jQuery('div.itemsummary').live( "click", function() { jQuery('#'+this.id+'.itemparams').toggle(); }); });</script>
+
   </head>
   <body id="jenkins jenkins-${h.version}" class="yui-skin-sam">
     <!-- for accessibility, skip the entire navigation bar and etc and go straight to the head of the content -->
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to