Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	pom.xml
	src/main/java/hudson/plugins/claim/AbstractClaimBuildAction.java
  • Loading branch information
huybrechts committed Feb 3, 2013
2 parents e3f3de5 + a91fe82 commit 7e8a50d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
24 changes: 20 additions & 4 deletions pom.xml
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424.1.AGFA-SNAPSHOT</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.420</version>
</parent>

<artifactId>claim</artifactId>
Expand All @@ -15,4 +15,20 @@
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>


13 changes: 13 additions & 0 deletions src/main/java/hudson/plugins/claim/AbstractClaimBuildAction.java
Expand Up @@ -11,6 +11,7 @@
import hudson.tasks.junit.TestAction;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;

Expand All @@ -29,6 +30,7 @@ public abstract class AbstractClaimBuildAction<T extends Saveable> extends TestA

private boolean claimed;
private String claimedBy;
private Date claimDate;
private boolean transientClaim;

protected T owner;
Expand Down Expand Up @@ -111,6 +113,7 @@ public void claim(String claimedBy, String reason, boolean sticky) {
}
}

this.claimDate = new Date();
}

/**
Expand All @@ -124,6 +127,7 @@ public void unclaim() {
this.claimed = false;
this.claimedBy = null;
this.transientClaim = false;
this.claimDate = null;
// we remember the reason to show it if someone reclaims this build.

for (ClaimListener listener: ClaimListener.all()) {
Expand Down Expand Up @@ -194,6 +198,15 @@ public boolean isSticky() {
public void setSticky(boolean sticky) {
this.transientClaim = !sticky;
}

@Exported
public Date getClaimDate() {
return this.claimDate;
}

public boolean hasClaimDate() {
return this.claimDate != null;
}

public abstract String getNoun();

Expand Down
@@ -1,5 +1,5 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">

<script type="text/javascript">
function ShowPopup(hoveritem)
Expand All @@ -19,7 +19,14 @@
<j:choose>
<j:when test="${it.isClaimedByMe()}">
<p>
You claimed this ${it.noun}.
<j:choose>
<j:when test="${it.hasClaimDate()}">
You claimed this ${it.noun} on <i:formatDate value="${it.claimDate}" type="both" dateStyle="medium" timeStyle="medium"/>.
</j:when>
<j:otherwise>
You claimed this ${it.noun}.
</j:otherwise>
</j:choose>
<j:if test="${it.canRelease()}">
<a id="dropClaim" href="claim/unclaim">Drop the claim.</a>
</j:if>
Expand All @@ -30,7 +37,14 @@
</j:when>
<j:when test="${it.claimed}">
<p>
This ${it.noun} was claimed by ${it.claimedByName}.
<j:choose>
<j:when test="${it.hasClaimDate()}">
This ${it.noun} was claimed by ${it.claimedByName} on <i:formatDate value="${it.claimDate}" type="both" dateStyle="medium" timeStyle="medium"/>.
</j:when>
<j:otherwise>
This ${it.noun} was claimed by ${it.claimedByName}.
</j:otherwise>
</j:choose>
<j:if test="${it.canClaim()}">
<a id="claimForYourself" href="#" onClick="ShowPopup(this); return false;">Claim for yourself.</a>
</j:if>
Expand Down
10 changes: 2 additions & 8 deletions src/test/java/hudson/plugins/claim/ClaimTest.java
Expand Up @@ -51,19 +51,13 @@ public class ClaimTest extends HudsonTestCase {
protected void setUp() throws Exception {
super.setUp();

hudson.setAuthorizationStrategy(new FullControlOnceLoggedInAuthorizationStrategy());
HudsonPrivateSecurityRealm realm = new HudsonPrivateSecurityRealm(false);
hudson.setSecurityRealm(realm);

User user1 = realm.createAccount("user1", "user1");
User user2 = realm.createAccount("user2", "user2");


project = createFreeStyleProject("x");
project.getBuildersList().add(new FailureBuilder());
project.getPublishersList().add(new ClaimPublisher());
build = project.scheduleBuild2(0).get();

hudson.setAuthorizationStrategy(new FullControlOnceLoggedInAuthorizationStrategy());
hudson.setSecurityRealm(createDummySecurityRealm());
}

public void testHasClaimAction() {
Expand Down

0 comments on commit 7e8a50d

Please sign in to comment.