Skip to content

Commit

Permalink
Implemented suggestion JENKINS-21406(Difference View). Added the opti…
Browse files Browse the repository at this point in the history
…on to restore either file A or file B configuration in the Difference View.
  • Loading branch information
boev committed Jan 23, 2014
1 parent 2ad4c27 commit 83de45b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
Expand Up @@ -168,7 +168,50 @@ public final void doDiffFiles(StaplerRequest req, StaplerResponse rsp)
+ "&timestamp2=" + parser.get("timestamp2"));
}

/**
* Used in the Difference jelly only. Returns one of the two timestamps that
* have been passed to the Difference page as parameter. timestampNumber
* must be 1 or 2.
*
* @param timestampNumber
* 1 for timestamp1 and 2 for timestamp2
* @return the timestamp as String.
*/
public final String getTimestamp(short timestampNumber) {
checkConfigurePermission();
return this.getRequestParameter("timestamp" + timestampNumber);
}

/**
* Used in the Difference jelly only. Returns the user that made the change
* in one of the Files shown in the Difference view(A or B). timestampNumber
* decides between File A and File B.
*
* @param timestampNumber
* 1 for File A and 2 for File B
* @return the user as String.
*/
public final String getUser(short timestampNumber) {
checkConfigurePermission();
return getHistoryDao().getRevisions(this.project.getConfigFile())
.get(getTimestamp(timestampNumber)).getUser();
}

/**
* Used in the Difference jelly only. Returns the operation made on one of
* the two Files A and B. timestampNumber decides which file exactly.
*
* @param timestampNumber
* 1 for File A, 2 for File B
* @return the operation as String.
*/
public final String getOperation(short timestampNumber) {
checkConfigurePermission();
return getHistoryDao().getRevisions(this.project.getConfigFile())
.get(getTimestamp(timestampNumber)).getOperation();
}


/**
* Takes the two timestamp request parameters and returns the diff between the corresponding
* config files of this project as a list of single lines.
Expand Down Expand Up @@ -209,7 +252,6 @@ private XmlFile getOldConfigXml(String timestamp) {
}
}


/**
* Action when 'restore' button is pressed: Replace current config file by older version.
*
Expand Down
Expand Up @@ -18,7 +18,18 @@
<p>${%No lines changed}</p>
</j:when>
<j:otherwise>
<table class="pane" style="width:100%">
<table style="width:100%;">
<thead>
<tr>
<td colspan="2"> <font size="3"> File A </font></td>
<td colspan="2"> <font size="3"> File B </font></td>
</tr>
<tr>
<td colspan="2"> ${it.getTimestamp(1)}; ${it.getOperation(1)}; <a href="${rootURL}/user/${it.getUser(1)}">${it.getUser(1)}</a> </td>
<td colspan="2"> ${it.getTimestamp(2)}; ${it.getOperation(2)}; <a href="${rootURL}/user/${it.getUser(2)}">${it.getUser(2)}</a> </td>
</tr>
</thead>
<tbody style="outline: 1pt solid #B2B2B2;">
<j:forEach items="${it.getLines()}" var="line">
<tr>
<j:choose>
Expand All @@ -37,12 +48,24 @@
</j:choose>
</tr>
</j:forEach>
</tbody>
</table>
<f:form method="post" action="forwardToRestoreQuestion?timestamp=${request.getParameter('timestamp1')}" name="forward">
<div align="right">
<f:submit value="${%Restore old version}" />
</div>
</f:form>
<div align="right">
<table>
<tr>
<td>
<f:form method="post" action="forwardToRestoreQuestion?timestamp=${request.getParameter('timestamp1')}" name="forward">
<f:submit value="${%Restore file A configuration}" />
</f:form>
</td>
<td>
<f:form method="post" action="forwardToRestoreQuestion?timestamp=${request.getParameter('timestamp2')}" name="forward">
<f:submit value="${%Restore file B configuration}" />
</f:form>
</td>
</tr>
</table>
</div>
</j:otherwise>
</j:choose>
</div>
Expand Down

0 comments on commit 83de45b

Please sign in to comment.