Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored DiskUsageAction "injection" using a TransientProjectActionFactory avoid to pollute jobs configuration and history with a JobProperty
- Loading branch information
Showing
8 changed files
with
101 additions
and
22 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
67 changes: 67 additions & 0 deletions
67
src/main/java/hudson/plugins/disk_usage/DiskUsageProjectActionFactory.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,67 @@ | ||
package hudson.plugins.disk_usage; | ||
|
||
import hudson.Extension; | ||
import hudson.model.*; | ||
import net.sf.json.JSONObject; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* @author: <a hef="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a> | ||
*/ | ||
@Extension | ||
public class DiskUsageProjectActionFactory extends TransientProjectActionFactory | ||
implements Describable<DiskUsageProjectActionFactory> { | ||
|
||
@Override | ||
public Collection<? extends Action> createFor(AbstractProject job) { | ||
return Collections.singleton(new ProjectDiskUsageAction(job)); | ||
} | ||
|
||
public Descriptor<DiskUsageProjectActionFactory> getDescriptor() { | ||
return DESCRIPTOR; | ||
} | ||
|
||
@Extension | ||
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl(); | ||
|
||
public static final class DescriptorImpl extends Descriptor<DiskUsageProjectActionFactory> { | ||
|
||
public DescriptorImpl() { | ||
load(); | ||
} | ||
|
||
//Show graph on the project page? | ||
private boolean showGraph; | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.DisplayName(); | ||
} | ||
|
||
|
||
@Override | ||
public DiskUsageProjectActionFactory newInstance(StaplerRequest req, JSONObject formData) { | ||
return new DiskUsageProjectActionFactory(); | ||
} | ||
|
||
@Override | ||
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { | ||
showGraph = req.getParameter("disk_usage.showGraph") != null; | ||
save(); | ||
return super.configure(req, formData); | ||
} | ||
|
||
public boolean isShowGraph() { | ||
//The graph is shown by default | ||
return showGraph; | ||
} | ||
|
||
public void setShowGraph(Boolean showGraph) { | ||
this.showGraph = showGraph; | ||
} | ||
} | ||
|
||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...disk_usage/DiskUsageProperty/global.jelly → ...iskUsageProjectActionFactory/global.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
File renamed without changes.
File renamed without changes.
File renamed without changes.