Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<data-tables-api.version>1.10.25-3</data-tables-api.version>
<jquery3-api.version>3.6.0-2</jquery3-api.version>
<font-awesome-api.version>5.15.3-4</font-awesome-api.version>
<echarts-api.version>5.1.2-3</echarts-api.version>
<echarts-api.version>5.1.2-4</echarts-api.version>
<bootstrap5-api.version>5.0.2-1</bootstrap5-api.version>

</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ public LinesChartModel createChartModel() {
return new FileChurnTrendChart().create(fileStatistics, decorator);
}

/**
* Returns the repository URL for the specified commit.
*
* @param commit
* the commit to get the URL for
*
* @return the repository URL
*/
@JavaScriptMethod
@SuppressWarnings("unused") // Called by jelly view
public String getCommitUrl(final String commit) {
return decorator.getRawLink(commit);
}

@JavaScriptMethod
@SuppressWarnings("unused") // Called by jelly view
@Override
Expand Down Expand Up @@ -182,6 +196,7 @@ public LinesChartModel create(final FileStatistics fileStatistics,
LinesDataSet dataSet = createDataSetPerCommit(fileStatistics, decorator);

LinesChartModel model = new LinesChartModel(dataSet);
model.setDomainAxisItemName("Commit");
LineSeries added = new LineSeries(Messages.TrendChart_Churn_Legend_Added(), Palette.GREEN.getNormal(),
StackedMode.SEPARATE_LINES, FilledMode.FILLED);
added.addAll(dataSet.getSeries(ADDED_KEY));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.jenkins.plugins.forensics.util;

import org.apache.commons.lang3.StringUtils;

import hudson.scm.RepositoryBrowser;

/**
Expand All @@ -21,12 +23,26 @@ public abstract class CommitDecorator {
public abstract String asLink(String id);

/**
* Renders the commit ID as a human readable text.
* Returns the raw link for the specified commit ID.
*
* @param id
* the ID of the commit
*
* @return a raw link to the commit, e.g. https://github.com/jenkinsci/analysis-model/commit/9f5eb8b28e422d6249e6c29dc65173a59f2d9f6f
*/
public String getRawLink(final String id) {
return StringUtils.defaultString(
StringUtils.substringBetween(asLink(id), "href=\"", "\""),
id);
}

/**
* Renders the commit ID as a human-readable text.
*
* @param id
* the ID of the commit
*
* @return a commit ID as human readable text
* @return a commit ID as human-readable text
*/
public String asText(final String id) {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@

<script>
{
const trendProxy = <st:bind value="${it}"/>;
trendProxy.getBuildTrendModel(function (lineModel) {
echartsJenkinsApi.renderConfigurableZoomableTrendChart('churn-trend-chart', lineModel.responseJSON);
});
const trendProxy = <st:bind value="${it}"/>;
trendProxy.getBuildTrendModel(function (lineModel) {
const openCommit = function (commit) {
trendProxy.getCommitUrl(commit, function (commitUrl) {
if (commitUrl.responseJSON.startsWith('http')) {
window.location.assign(commitUrl.responseJSON);
}
});
};
echartsJenkinsApi.renderConfigurableZoomableTrendChart('churn-trend-chart', lineModel.responseJSON, null, openCommit);
});
}
</script>
</bs:page>
Expand Down