Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #2006 from tfennelly/2.0-with-config-tabs
[JENKINS-32357] Section tabs for job configs - phase 1
- Loading branch information
Showing
30 changed files
with
2,768 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2016, CloudBees | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"> | ||
<st:documentation> | ||
Client-side CSS loading tag. Similar to adjunct, but driven from the client. See page-init.js. | ||
|
||
@since 2.0 | ||
<st:attribute name="src" required="true"> | ||
CSS source path (relative to Jenkins). | ||
</st:attribute> | ||
</st:documentation> | ||
|
||
<div class="jenkins-css-load" data-src="${attrs.src}" /> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2016, CloudBees | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"> | ||
<st:documentation> | ||
Client-side JavaScript loading tag. Similar to adjunct, but driven from the client. See page-init.js. | ||
|
||
@since 2.0 | ||
<st:attribute name="src" required="true"> | ||
JavaScript source path (relative to Jenkins). | ||
</st:attribute> | ||
</st:documentation> | ||
|
||
<div class="jenkins-js-load" data-src="${attrs.src}" /> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
var $ = require('jquery-detached').getJQuery(); | ||
var jenkinsLocalStorage = require('./util/jenkinsLocalStorage.js'); | ||
var configMetadata = require('./widgets/config/model/ConfigTableMetaData.js'); | ||
|
||
$(function() { | ||
// Horrible ugly hack... | ||
// We need to use Behaviour.js to wait until after radioBlock.js Behaviour.js rules | ||
// have been applied, otherwise row-set rows become visible across sections. | ||
var done = false; | ||
Behaviour.specify(".block-control", 'row-set-block-control', 1000, function() { // jshint ignore:line | ||
if (done) { | ||
return; | ||
} | ||
done = true; | ||
|
||
// Only do job configs for now. | ||
var configTables = $('.job-config.tabbed'); | ||
if (configTables.size() > 0) { | ||
var tabBarShowPreferenceKey = 'config:usetabs'; | ||
var tabBarShowPreference = jenkinsLocalStorage.getGlobalItem(tabBarShowPreferenceKey, "yes"); | ||
|
||
var tabBarWidget = require('./widgets/config/tabbar.js'); | ||
if (tabBarShowPreference === "yes") { | ||
configTables.each(function() { | ||
var configTable = $(this); | ||
var tabBar = tabBarWidget.addTabs(configTable); | ||
|
||
// We want to merge some sections together. | ||
// Merge the "Advanced" section into the "General" section. | ||
var generalSection = tabBar.getSection('config_general'); | ||
if (generalSection) { | ||
generalSection.adoptSection('config_advanced_project_options'); | ||
} | ||
|
||
addFinderToggle(tabBar); | ||
tabBar.onShowSection(function() { | ||
// Hook back into hudson-behavior.js | ||
fireBottomStickerAdjustEvent(); | ||
}); | ||
tabBar.deactivator.click(function() { | ||
jenkinsLocalStorage.setGlobalItem(tabBarShowPreferenceKey, "no"); | ||
require('window-handle').getWindow().location.reload(); | ||
}); | ||
$('.jenkins-config-widgets .find-container input').focus(function() { | ||
fireBottomStickerAdjustEvent(); | ||
}); | ||
|
||
if (tabBar.hasSections()) { | ||
var tabBarLastSectionKey = 'config:' + tabBar.configForm.attr('name') + ':last-tab'; | ||
var tabBarLastSection = jenkinsLocalStorage.getPageItem(tabBarLastSectionKey, tabBar.sections[0].id); | ||
tabBar.onShowSection(function() { | ||
jenkinsLocalStorage.setPageItem(tabBarLastSectionKey, this.id); | ||
}); | ||
tabBar.showSection(tabBarLastSection); | ||
} | ||
}); | ||
} else { | ||
configTables.each(function() { | ||
var configTable = $(this); | ||
var activator = tabBarWidget.addTabsActivator(configTable); | ||
configMetadata.markConfigTableParentForm(configTable); | ||
activator.click(function() { | ||
jenkinsLocalStorage.setGlobalItem(tabBarShowPreferenceKey, "yes"); | ||
require('window-handle').getWindow().location.reload(); | ||
}); | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
function addFinderToggle(configTableMetadata) { | ||
var findToggle = $('<div class="find-toggle" title="Find"></div>'); | ||
var finderShowPreferenceKey = 'config:showfinder'; | ||
|
||
$('.tabBar', configTableMetadata.configWidgets).append(findToggle); | ||
findToggle.click(function() { | ||
var findContainer = $('.find-container', configTableMetadata.configWidgets); | ||
if (findContainer.hasClass('visible')) { | ||
findContainer.removeClass('visible'); | ||
jenkinsLocalStorage.setGlobalItem(finderShowPreferenceKey, "no"); | ||
} else { | ||
findContainer.addClass('visible'); | ||
$('input', findContainer).focus(); | ||
jenkinsLocalStorage.setGlobalItem(finderShowPreferenceKey, "yes"); | ||
} | ||
}); | ||
|
||
if (jenkinsLocalStorage.getGlobalItem(finderShowPreferenceKey, "yes") === 'yes') { | ||
findToggle.click(); | ||
} | ||
} | ||
|
||
function fireBottomStickerAdjustEvent() { | ||
Event.fire(window, 'jenkins:bottom-sticker-adjust'); // jshint ignore:line | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Page initialisation tasks. | ||
*/ | ||
|
||
var $ = require('jquery-detached').getJQuery(); | ||
var jsModules = require('jenkins-js-modules'); | ||
|
||
$(function() { | ||
loadScripts(); | ||
loadCSS(); | ||
}); | ||
|
||
function loadScripts() { | ||
$('.jenkins-js-load').each(function () { | ||
var scriptUrl = $(this).attr('data-src'); | ||
if (scriptUrl) { | ||
// jsModules.addScript will ensure that the script is | ||
// loaded once and once only. So, this can be considered | ||
// analogous to a client-side adjunct. | ||
jsModules.addScript(scriptUrl); | ||
$(this).remove(); | ||
} | ||
}); | ||
} | ||
|
||
function loadCSS() { | ||
$('.jenkins-css-load').each(function () { | ||
var cssUrl = $(this).attr('data-src'); | ||
if (cssUrl) { | ||
// jsModules.addCSSToPage will ensure that the CSS is | ||
// loaded once and once only. So, this can be considered | ||
// analogous to a client-side adjunct. | ||
jsModules.addCSSToPage(cssUrl); | ||
$(this).remove(); | ||
} | ||
}); | ||
} |
Oops, something went wrong.