Skip to content

Commit

Permalink
Fix Reports Success/Warning icons, counts
Browse files Browse the repository at this point in the history
  • Loading branch information
sultan committed Oct 16, 2022
1 parent 04d6d63 commit 095257e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,8 @@ public final int getSegmentCount( ArtifactVersion v )
*/
public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException
{
if ( VersionComparators.isSnapshot( v ) )
{
return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ),
segment ) );
}
int segmentCount = getSegmentCount( v );
if ( segment.value() >= segmentCount )
{
throw new InvalidSegmentException( segment, segmentCount, v );
}
return innerIncrementSegment( v, segment );
return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ),
segment ) );
}

protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ protected void renderOverview()
*/
protected <Q extends OverviewStats> void renderOverviewTableRow( Q stats )
{
renderStatRow( "report.overview.numUpToDate", stats.getUpToDate() );
renderStatRow( "report.overview.numNewerVersionAvailable", stats.getAny() );
renderStatRow( "report.overview.numNewerIncrementalAvailable", stats.getIncremental() );
renderStatRow( "report.overview.numNewerMinorAvailable", stats.getMinor() );
renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor() );
renderStatRow( "report.overview.numUpToDate", stats.getUpToDate(), true );
renderStatRow( "report.overview.numNewerVersionAvailable", stats.getAny(), false );
renderStatRow( "report.overview.numNewerIncrementalAvailable", stats.getIncremental(), false );
renderStatRow( "report.overview.numNewerMinorAvailable", stats.getMinor(), false );
renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor(), false );
}

/**
Expand Down Expand Up @@ -421,6 +421,7 @@ protected void renderTableHeaderCells( String... keys )

protected String getLabel( ArtifactVersion version, AbstractVersionDetails details )
{

if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) )
{
return getText( "report.latestSubIncremental" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void incrementDependencies()
*
* @param updates collection of all version updates, typically from {@linkplain PluginUpdatesModel#getAllUpdates()}
* @param cache if not null, cache to retrieve the version information, initialised with
* the {@link ArtifactVersions#getOldestUpdate(Optional)} update information
* the {@link ArtifactVersions#getNewestUpdate(Optional)} update information
* @param <T> always equal to {@linkplain PluginOverviewStats}
* @param <V> always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails}
* @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information
Expand All @@ -66,19 +66,19 @@ public static <T extends OverviewStats, V extends ArtifactVersions> T fromUpdate
PluginOverviewStats stats = new PluginOverviewStats();
updates.forEach( details ->
{
if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null )
if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null )
{
stats.incrementAny();
}
else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null )
else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null )
{
stats.incrementIncremental();
}
else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null )
else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null )
{
stats.incrementMinor();
}
else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null )
else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null )
{
stats.incrementMajor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected <T extends OverviewStats> void renderOverviewTableRow( T stats )
{
super.renderOverviewTableRow( stats );
super.renderStatRow( "report.overview.numNewerDependenciesAvailable",
( (PluginOverviewStats) stats ).getDependencies() );
( (PluginOverviewStats) stats ).getDependencies(), false );
}

protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ protected void renderSuccessIcon()
sink.figureGraphics( "images/icon_success_sml.gif" );
}

protected void renderStatRow( String textKey, int statCount )
protected void renderStatRow( String textKey, int statCount, boolean forceSuccessIcon )
{
sink.tableRow();
sink.tableCell();
if ( statCount == 0 )
if ( statCount == 0 || forceSuccessIcon )
{
renderSuccessIcon();
}
Expand Down

0 comments on commit 095257e

Please sign in to comment.