Skip to content
Permalink
Browse files

Merge pull request #5 from daniel-beck/JENKINS-20235-20006

[FIXED JENKINS-20235 JENKINS-20006] Configurable default view
  • Loading branch information...
jglick committed Feb 17, 2014
2 parents ac59f52 + a65a502 commit 4aa06dc7e312a988cb1f9fd0f144be235d8e7018
@@ -46,6 +46,7 @@
import hudson.model.ItemVisitor;
import hudson.model.Items;
import hudson.model.Job;
import hudson.model.AllView;
import hudson.model.ListView;
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;
@@ -265,24 +266,31 @@ private void init() {
for (FolderProperty p : properties) {
p.setOwner(this);
}
if (columns == null) {
columns = new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}
if (filters == null) {
filters = new DescribableList<ViewJobFilter, Descriptor<ViewJobFilter>>(this);
}
if (views == null) {
views = new CopyOnWriteArrayList<View>();
}
if (views.size() == 0) {
ListView lv = new ListView("All", this);
views.add(lv);
try {
lv.getColumns().replaceBy(columns.toList());
lv.getJobFilters().replaceBy(filters.toList());
lv.setIncludeRegex(".*");
lv.save();
if (columns != null || filters != null) {
// we're loading an ancient config
if (columns == null) {
columns = new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}
if (filters == null) {
filters = new DescribableList<ViewJobFilter, Descriptor<ViewJobFilter>>(this);
}
ListView lv = new ListView("All", this);
views.add(lv);
lv.getColumns().replaceBy(columns.toList());
lv.getJobFilters().replaceBy(filters.toList());
lv.setIncludeRegex(".*");
lv.save();
} else {
AllView v = new AllView("All", this);
views.add(v);
v.save();
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to set up the initial view", e);
}
@@ -468,7 +476,8 @@ public FolderIcon getIconColor() {
* Folder is no longer a view by itself.
*/
public DescribableList<ListViewColumn, Descriptor<ListViewColumn>> getColumns() {
return columns;
return new DescribableList<ListViewColumn, Descriptor<ListViewColumn>>(this,
ListViewColumn.createDefaultInitialColumnList());
}

/**
@@ -698,6 +707,10 @@ public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp)
description = json.getString("description");
displayName = Util.fixEmpty(json.optString("displayNameOrNull"));

if (json.has("primaryView")) {
setPrimaryView(viewGroupMixIn.getView(json.getString("primaryView")));
}

properties.rebuild(req, json, getDescriptor().getPropertyDescriptors());
for (FolderProperty p : properties) // TODO: push this to the subtype of property descriptors
{
@@ -42,6 +42,23 @@ THE SOFTWARE.
<f:textarea codemirror-mode="${app.markupFormatter.codeMirrorMode}" codemirror-config="${app.markupFormatter.codeMirrorConfig}" previewEndpoint="/markupFormatter/previewDescription" />
</f:entry>

<j:if test="${it.views.size()>1}">
<f:entry title="${%Default View}" field="defaultView">
<select class="setting-input" name="primaryView">
<j:forEach var="v" items="${it.views}">
<j:choose>
<j:when test="${it.primaryView==v}">
<option value="${v.viewName}" selected="selected">${v.viewName}</option>
</j:when>
<j:otherwise>
<option value="${v.viewName}">${v.viewName}</option>
</j:otherwise>
</j:choose>
</j:forEach>
</select>
</f:entry>
</j:if>

<!-- TODO tried to hide unless ${it.icon.descriptor.all().size() > 1} using f:invisibleEntry but this did not seem to work: -->
<f:dropdownDescriptorSelector title="${%Icon}" field="icon"/>

0 comments on commit 4aa06dc

Please sign in to comment.
You can’t perform that action at this time.