Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-47214 Give ability to opt out of autofavoriting (#12)
- Loading branch information
James William Dumay
committed
Nov 29, 2017
1 parent
73db17e
commit 45f6a79
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/io/jenkins/blueocean/autofavorite/user/FavoritingUserProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.jenkins.blueocean.autofavorite.user; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import hudson.Extension; | ||
import hudson.model.User; | ||
import hudson.model.UserProperty; | ||
import hudson.model.UserPropertyDescriptor; | ||
import io.jenkins.blueocean.autofavorite.Messages; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class FavoritingUserProperty extends UserProperty { | ||
|
||
private Boolean autofavoriteEnabled; | ||
|
||
@DataBoundConstructor | ||
public FavoritingUserProperty(Boolean autofavoriteEnabled) { | ||
this.autofavoriteEnabled = autofavoriteEnabled; | ||
} | ||
|
||
public boolean isAutofavoriteEnabled() { | ||
return autofavoriteEnabled; | ||
} | ||
|
||
@VisibleForTesting | ||
public void setAutofavoriteEnabled(boolean autofavoriteEnabled) { | ||
this.autofavoriteEnabled = autofavoriteEnabled; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends UserPropertyDescriptor { | ||
|
||
public DescriptorImpl() { | ||
super(FavoritingUserProperty.class); | ||
} | ||
|
||
@Override | ||
public UserProperty newInstance(User user) { | ||
return new FavoritingUserProperty(true); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.autofavorite_name(); | ||
} | ||
} | ||
|
||
public static FavoritingUserProperty from(User user) { | ||
return user.getProperty(FavoritingUserProperty.class); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/resources/io/jenkins/blueocean/autofavorite/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
autofavorite.name = Automatically favorite pipelines |
9 changes: 9 additions & 0 deletions
9
...main/resources/io/jenkins/blueocean/autofavorite/user/FavoritingUserProperty/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?jelly escape-by-default='true'?> | ||
<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"> | ||
<f:block> | ||
<f:entry name="auto-fav-enabled" field="autofavoriteEnabled"> | ||
<f:checkbox title="${%autofavorite.enabled}" name="autofavoriteEnabled" checked="${instance.autofavoriteEnabled}"/> | ||
</f:entry> | ||
</f:block> | ||
</j:jelly> |
1 change: 1 addition & 0 deletions
1
...resources/io/jenkins/blueocean/autofavorite/user/FavoritingUserProperty/config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
autofavorite.enabled = when your email address appears in the change list of a run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters