-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental 'Details' widget for builds (#10147)
- Loading branch information
Showing
17 changed files
with
576 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package jenkins.model.details; | ||
|
||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
import hudson.model.Actionable; | ||
import hudson.model.ModelObject; | ||
import hudson.model.Run; | ||
import org.jenkins.ui.icon.IconSpec; | ||
|
||
/** | ||
* {@link Detail} represents a piece of information about a {@link Run}. | ||
* Such information could include: | ||
* <ul> | ||
* <li>the date and time the run started</li> | ||
* <li>the amount of time the run took to complete</li> | ||
* <li>SCM information for the build</li> | ||
* <li>who kicked the build off</li> | ||
* </ul> | ||
* @since TODO | ||
*/ | ||
public abstract class Detail implements ModelObject, IconSpec { | ||
|
||
private final Actionable object; | ||
|
||
public Detail(Actionable object) { | ||
this.object = object; | ||
} | ||
|
||
public Actionable getObject() { | ||
return object; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public @Nullable String getIconClassName() { | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public @Nullable String getDisplayName() { | ||
return null; | ||
} | ||
|
||
/** | ||
* Optional URL for the {@link Detail}. | ||
* If provided the detail element will be a link instead of plain text. | ||
*/ | ||
public @Nullable String getLink() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return the grouping of the detail | ||
*/ | ||
public DetailGroup getGroup() { | ||
return GeneralDetailGroup.get(); | ||
} | ||
|
||
/** | ||
* @return order in the group, zero is first, MAX_VALUE is any order | ||
*/ | ||
public int getOrder() { | ||
return Integer.MAX_VALUE; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
core/src/main/java/jenkins/model/details/DetailFactory.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,57 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2025 Jan Faracik | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package jenkins.model.details; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.ExtensionList; | ||
import hudson.ExtensionPoint; | ||
import hudson.model.Actionable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
/** | ||
* Allows you to add multiple details to an Actionable object at once. | ||
* @param <T> the type of object to add to; typically an {@link Actionable} subtype | ||
* @since TODO | ||
*/ | ||
public abstract class DetailFactory<T extends Actionable> implements ExtensionPoint { | ||
|
||
public abstract Class<T> type(); | ||
|
||
public abstract @NonNull List<? extends Detail> createFor(@NonNull T target); | ||
|
||
@Restricted(NoExternalUse.class) | ||
public static <T extends Actionable> List<DetailFactory<T>> factoriesFor(Class<T> type) { | ||
List<DetailFactory<T>> result = new ArrayList<>(); | ||
for (DetailFactory<T> wf : ExtensionList.lookup(DetailFactory.class)) { | ||
if (wf.type().isAssignableFrom(type)) { | ||
result.add(wf); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
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,6 @@ | ||
package jenkins.model.details; | ||
|
||
/** | ||
* Represents a group for categorizing {@link Detail} | ||
*/ | ||
public abstract class DetailGroup {} |
13 changes: 13 additions & 0 deletions
13
core/src/main/java/jenkins/model/details/DurationDetail.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,13 @@ | ||
package jenkins.model.details; | ||
|
||
import hudson.model.Run; | ||
|
||
/** | ||
* Displays the duration of the given run, or, if the run has completed, shows the total time it took to execute | ||
*/ | ||
public class DurationDetail extends Detail { | ||
|
||
public DurationDetail(Run<?, ?> run) { | ||
super(run); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
core/src/main/java/jenkins/model/details/GeneralDetailGroup.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,12 @@ | ||
package jenkins.model.details; | ||
|
||
import hudson.Extension; | ||
import hudson.ExtensionList; | ||
|
||
@Extension | ||
public class GeneralDetailGroup extends DetailGroup { | ||
|
||
public static GeneralDetailGroup get() { | ||
return ExtensionList.lookupSingleton(GeneralDetailGroup.class); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/src/main/java/jenkins/model/details/TimestampDetail.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,13 @@ | ||
package jenkins.model.details; | ||
|
||
import hudson.model.Run; | ||
|
||
/** | ||
* Displays the start time of the given run | ||
*/ | ||
public class TimestampDetail extends Detail { | ||
|
||
public TimestampDetail(Run<?, ?> run) { | ||
super(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
Oops, something went wrong.