Add default columns to list views
This uses the default "All" view columns as the columns for any views without a columns attribute sets. This means that view definitions which don't define any columns will still end up producing a useful view. (Note that the "All" columns are not fetched from the Jenkins instance; the columns that are the default in a fresh Jenkins install are hard-coded.) Change-Id: I0a21e024be383088c6238c3fc7beb708af8c2c46
This commit is contained in:
parent
41c54bba00
commit
83592a094b
@ -50,6 +50,8 @@ COLUMN_DICT = {
|
||||
'build-button': 'hudson.views.BuildButtonColumn',
|
||||
'last-stable': 'hudson.views.LastStableColumn',
|
||||
}
|
||||
DEFAULT_COLUMNS = ['status', 'weather', 'job', 'last-success', 'last-failure',
|
||||
'last-duration', 'build-button']
|
||||
|
||||
|
||||
class List(jenkins_jobs.modules.base.Base):
|
||||
@ -78,7 +80,7 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
XML.SubElement(root, 'jobFilters')
|
||||
|
||||
c_xml = XML.SubElement(root, 'columns')
|
||||
columns = data.get('columns', [])
|
||||
columns = data.get('columns', DEFAULT_COLUMNS)
|
||||
|
||||
for column in columns:
|
||||
if column in COLUMN_DICT:
|
||||
|
26
tests/views/fixtures/view_list_defaults001.xml
Normal file
26
tests/views/fixtures/view_list_defaults001.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<hudson.model.ListView>
|
||||
<name>list-view-name01</name>
|
||||
<description>Sample description</description>
|
||||
<filterExecutors>true</filterExecutors>
|
||||
<filterQueue>true</filterQueue>
|
||||
<properties class="hudson.model.View$PropertyList"/>
|
||||
<jobNames>
|
||||
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
||||
<string>job-name-1</string>
|
||||
<string>job-name-2</string>
|
||||
<string>job-name-3</string>
|
||||
</jobNames>
|
||||
<jobFilters/>
|
||||
<columns>
|
||||
<hudson.views.StatusColumn/>
|
||||
<hudson.views.WeatherColumn/>
|
||||
<hudson.views.JobColumn/>
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<hudson.views.BuildButtonColumn/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
</hudson.model.ListView>
|
11
tests/views/fixtures/view_list_defaults001.yaml
Normal file
11
tests/views/fixtures/view_list_defaults001.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
name: list-view-name01
|
||||
view-type: list
|
||||
description: 'Sample description'
|
||||
filter-executors: true
|
||||
filter-queue: true
|
||||
job-name:
|
||||
- job-name-1
|
||||
- job-name-2
|
||||
- job-name-3
|
||||
recurse: true
|
||||
status-filter: false
|
Loading…
Reference in New Issue
Block a user