Skip to content

Commit

Permalink
[FIXED JENKINS-19219] Upgrading to dashboard-view 2.9 causes Jobs Gri…
Browse files Browse the repository at this point in the history
…d information to not be displayed.

use default value of "Number of columns" if user does not configure portlet.
  • Loading branch information
ssogabe committed Aug 16, 2013
1 parent d434bdb commit d5b3a9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/main/java/hudson/plugins/view/dashboard/core/JobsPortlet.java
Expand Up @@ -3,7 +3,6 @@
import java.util.List;

import hudson.Extension;
import hudson.model.TopLevelItem;
import hudson.model.Descriptor;
import hudson.model.Job;
import hudson.plugins.view.dashboard.DashboardPortlet;
Expand All @@ -19,20 +18,22 @@
*/
public class JobsPortlet extends DashboardPortlet {

private int columnCount = 3;
private static final int MIN_COLUMNCOUNT = 3;

private int columnCount;
private boolean fillColumnFirst = false;

@DataBoundConstructor
public JobsPortlet(String name,
int columnCount,
boolean fillColumnFirst) {
super(name);
this.columnCount = columnCount;
this.columnCount = columnCount <= 0 ? MIN_COLUMNCOUNT : columnCount;
this.fillColumnFirst = fillColumnFirst;
}

public int getColumnCount() {
return this.columnCount <= 0 ? 3 : this.columnCount;
return columnCount;
}

public int getRowCount() {
Expand All @@ -50,7 +51,7 @@ public boolean getFillColumnFirst() {

public Job getJob(int curRow, int curColumun){
List<Job> jobs = this.getDashboard().getJobs();
int idx = 0;
int idx;
// get grid coordinates from given params
if (this.fillColumnFirst){
idx = curRow + curColumun * this.getRowCount();
Expand All @@ -70,6 +71,10 @@ public Job getJob(int curRow, int curColumun){
@Extension
public static class DescriptorImpl extends Descriptor<DashboardPortlet> {

public int getDefaultCoulmnCount() {
return MIN_COLUMNCOUNT;
}

@Override
public String getDisplayName() {
return Messages.Dashboard_JobsGrid();
Expand Down
Expand Up @@ -27,7 +27,7 @@ THE SOFTWARE.
<f:textbox name="portlet.name" field="name" default="${descriptor.getDisplayName()}" />
</f:entry>
<f:entry title="${%Number of columns}">
<f:textbox name="portlet.columnCount" field="columnCount" />
<f:textbox name="portlet.columnCount" field="columnCount" default="${descriptor.getDefaultCoulmnCount()}" />
</f:entry>
<f:block>
<f:checkbox name="portlet.fillColumnFirst" field="fillColumnFirst" />
Expand Down

0 comments on commit d5b3a9f

Please sign in to comment.