Skip to content
Permalink
Browse files

[FIXED JENKINS-20235 JENKINS-20006] Configurable default view

Conflicts:
	src/main/java/com/cloudbees/hudson/plugins/folder/Folder.java
  • Loading branch information...
daniel-beck committed Feb 16, 2014
1 parent 4398ffb commit 08d327b3648641942ae89e23ba7f4db562f864a0
@@ -47,6 +47,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;
@@ -269,33 +270,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());

try { // TODO use setIncludeRegex as of 1.526
Field f = lv.getClass().getDeclaredField("includeRegex");
f.setAccessible(true);
f.set(lv, ".*");
f = lv.getClass().getDeclaredField("includePattern");
f.setAccessible(true);
f.set(lv, Pattern.compile(".*"));
} catch (Throwable e) {
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();
}
lv.save();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to set up the initial view", e);
}
@@ -480,7 +479,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());
}

/**
@@ -710,6 +710,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 08d327b

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