提交 72c2ffc1 编写于 作者: K kzantow

Merge remote-tracking branch 'primary/2.0' into 2.0-install-dependency-view

......@@ -139,19 +139,19 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.ui</groupId>
<artifactId>jquery-detached</artifactId>
<version>1.2</version>
<version>1.2.1</version>
<classifier>core-assets</classifier>
</dependency>
<dependency>
<groupId>org.jenkins-ci.ui</groupId>
<artifactId>bootstrap</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<classifier>core-assets</classifier>
</dependency>
<dependency>
<groupId>org.jenkins-ci.ui</groupId>
<artifactId>handlebars</artifactId>
<version>1.1</version>
<version>1.1.1</version>
<classifier>core-assets</classifier>
</dependency>
<dependency>
......
......@@ -20,10 +20,12 @@ function ConfigRowGrouping(startRow, parentRowGroupContainer) {
this.label = undefined;
}
ConfigRowGrouping.prototype.getRowCount = function() {
ConfigRowGrouping.prototype.getRowCount = function(includeChildren) {
var count = this.rows.length;
for (var i = 0; i < this.rowGroups.length; i++) {
count += this.rowGroups[i].getRowCount();
if (includeChildren === undefined || includeChildren === true) {
for (var i = 0; i < this.rowGroups.length; i++) {
count += this.rowGroups[i].getRowCount();
}
}
return count;
};
......
......@@ -102,6 +102,29 @@ ConfigSection.prototype.markRowsAsActive = function() {
this.updateRowGroupVisibility();
};
ConfigSection.prototype.hasText = function(text) {
var $ = jQD.getJQuery();
var selector = ":containsci('" + text + "')";
var sectionRows = this.getRows();
for (var i1 = 0; i1 < sectionRows.length; i1++) {
var row = sectionRows[i1];
var elementsWithText = $(selector, row);
if (elementsWithText.size() > 0) {
return true;
}
}
for (var i2 = 0; i2 < this.subSections.length; i2++) {
if (this.subSections[i2].hasText(text)) {
return true;
}
}
return false;
};
ConfigSection.prototype.activeRowCount = function() {
var activeRowCount = 0;
var rows = this.getRows();
......@@ -190,8 +213,8 @@ ConfigSection.prototype.highlightText = function(text) {
var selector = ":containsci('" + text + "')";
var rows = this.getRows();
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (var i1 = 0; i1 < rows.length; i1++) {
var row = rows[i1];
/*jshint loopfunc: true */
$('span.highlight-split', row).each(function() { // jshint ignore:line
......@@ -209,11 +232,16 @@ ConfigSection.prototype.highlightText = function(text) {
$this.contents().each(function () {
// We specifically only mess with text nodes
if (this.nodeType === 3) {
var highlightedMarkup = this.wholeText.replace(regex, '<span class="highlight">$1</span>');
$(this).replaceWith('<span class="highlight-split">' + highlightedMarkup + '</span>');
var $textNode = $(this);
var highlightedMarkup = $textNode.text().replace(regex, '<span class="highlight">$1</span>');
$textNode.replaceWith('<span class="highlight-split">' + highlightedMarkup + '</span>');
}
});
});
}
}
for (var i2 = 0; i2 < this.subSections.length; i2++) {
this.subSections[i2].highlightText(text);
}
};
......@@ -262,7 +262,7 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
if (withText === '') {
if (this.hasSections()) {
for (var i1 = 0; i1 < this.sections.length; i1++) {
this.sections[i1].activator.show();
this.sections[i1].activator.removeClass('hidden');
}
var activeSection = this.activeSection();
if (!activeSection) {
......@@ -273,30 +273,16 @@ ConfigTableMetaData.prototype.showSections = function(withText) {
}
} else {
if (this.hasSections()) {
var $ = jQD.getJQuery();
var selector = ":containsci('" + withText + "')";
var sectionsWithText = [];
for (var i2 = 0; i2 < this.sections.length; i2++) {
var section = this.sections[i2];
var containsText = false;
var sectionRows = section.getRows();
for (var i3 = 0; i3 < sectionRows.length; i3++) {
var row = sectionRows[i3];
var elementsWithText = $(selector, row);
if (elementsWithText.size() > 0) {
containsText = true;
break;
}
}
if (containsText) {
section.activator.show();
if (section.hasText(withText)) {
section.activator.removeClass('hidden');
sectionsWithText.push(section);
} else {
section.activator.hide();
section.activator.addClass('hidden');
}
}
......
......@@ -10,4 +10,9 @@
/*
* Widget styles
*/
@import "config/tabbar";
\ No newline at end of file
@import "config/tabbar";
.hidden {
display: none;
}
\ No newline at end of file
<form name="config" action="configSubmit" method="post" class="jenkins-config">
<table width="100%" class="job-config tabbed">
<tbody>
<tr>
<td class="setting-name">Project name</td>
<td class="setting-main">
<input name="name" value="Free-2" class="setting-input " type="text"></td>
</tr>
<tr nameref="rowSetStart24">
<td><input type="hidden" name="stapler-class-bag" value="true"></td>
</tr>
<!-- Purposely indenting so as to highlight the implicit data "model" around row groupings -->
<tr style="display:none" class="row-set-start row-group-start" nameref="rowSetStart24"></tr>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb9" nameref="rowSetStart22">
<td colspan="3">
<input name="specified" class="optional-block-control block-control " type="checkbox">
<label class="attach-previous">Discard Old Builds</label>
</td>
</tr>
<tr class="help-area" nameref="rowSetStart22">
<td></td>
<td colspan="2">
<div class="help">Loading...</div>
</td>
<td></td>
</tr>
<tr class="rowvg-start" nameref="rowSetStart22" style="display: none;"></tr>
<tr nameref="rowSetStart22" style="display: none;"><td class="setting-name">Strategy</td><td class="setting-main"></td></tr>
<tr class="dropdownList-container" nameref="rowSetStart22" style="display: none;"><td colspan="2"></td></tr>
<tr class=" rowvg-end optional-block-end row-group-end" nameref="rowSetStart22"></tr>
<tr class="row-set-end row-group-end" nameref="rowSetStart24"></tr>
<tr>
<td colspan="4">
<div class="section-header"><a id="section0" class="section-anchor">#</a>Advanced Project Options</div>
</td>
</tr>
<tr>
<td>
<script src="/jenkins/adjuncts/5a08e6fd/lib/form/advanced/advanced.js" type="text/javascript"></script>
<div style="" class="advancedLink">
<span class="yui-button yui-push-button advanced-button advancedButton" id="yui-gen9">
<span class="first-child">
<button type="button" tabindex="0" id="yui-gen9-button">Advanced...</button>
</span>
</span>
</div>
<table class="advancedBody">
<tbody>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb13">
<td colspan="3">
<input class="optional-block-control block-control "type="checkbox"checked="true">
<label class="attach-previous">Quiet period</label>
</td>
</tr>
<tr class="rowvg-start"></tr>
<tr>
<td class="setting-name">Quiet period</td>
<td class="setting-main"></td>
</tr>
<tr>
<td colspan="2"></td>
<td class="setting-description">Number of seconds</td>
</tr>
<tr class=" rowvg-end optional-block-end row-group-end"></tr>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb14">
<td colspan="3"><input class="optional-block-control block-control "
type="checkbox" id="cb14"><label class="attach-previous">Retry Count</label></td>
</tr>
<tr class="rowvg-start" style="display: none;"></tr>
<tr style="display: none;">
<td class="setting-name">SCM checkout retry count</td>
<td class="setting-main"><input min="0" step="1" value="0"
class="setting-input number" type="number"></td>
</tr>
<tr class=" rowvg-end optional-block-end row-group-end"></tr>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb15">
<td colspan="3">
<input class="optional-block-control block-control " type="checkbox">
<label class="attach-previous">Block build when upstream project is building</label>
</td>
</tr>
<tr class="rowvg-start" style="display: none;"></tr>
<tr class=" rowvg-end optional-block-end row-group-end"></tr>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb16">
<td colspan="3"><input class="optional-block-control block-control " type="checkbox">
<label class="attach-previous">Block build when downstream project is building</label>
</td>
</tr>
<tr class="rowvg-start" style="display: none;"></tr>
<tr class=" rowvg-end optional-block-end row-group-end"></tr>
<tr class="optional-block-start row-group-start " hashelp="true" ref="cb17">
<td colspan="3">
<input class="optional-block-control block-control " type="checkbox">
<label class="attach-previous">Use custom workspace</label>
</td>
</tr>
<tr class="rowvg-start" style="display: none;"></tr>
<tr style="display: none;">
<td class="setting-name">Directory</td>
<td class="setting-main"></td>
</tr>
<tr class=" rowvg-end optional-block-end row-group-end"></tr>
<tr>
<td class="setting-name">Display Name</td>
<td class="setting-main"></td>
</tr>
<tr class="optional-block-start row-group-start row-set-start">
<td colspan="3">
<input class="optional-block-control block-control " type="checkbox">
<label class="attach-previous">Keep the build logs of dependencies</label></td>
</tr>
<tr class="rowvg-start" nameref="cb18" style="display: none;"></tr>
<tr class="row-set-end rowvg-end optional-block-end row-group-end"></tr>
</tbody>
</table>
</td>
<td></td>
</tr>
<tr style="display:none" class="row-set-end radio-block-end row-group-end"></tr>
<tr>
<td colspan="4">
<div class="section-header"><a id="section2" class="section-anchor">#</a>Build Triggers</div>
</td>
</tr>
<tr class="optional-block-start row-group-start row-set-start" hashelp="true" ref="cb19">
<td colspan="3">
<input class="optional-block-control block-control "type="checkbox">
<!-- We added the text "Trigger" here for testing the finder -->
<label class="attach-previous">Build (Trigger) after other projects are built</label>
</td>
</tr>
<tr>
<td colspan="4">
<div class="section-header"><a id="section3" class="section-anchor">#</a>Build</div>
</td>
</tr>
<tr>
<td colspan="4">
<div style="height: 74px;"></div>
<div id="bottom-sticker" style="position: fixed; bottom: 83px; left: 378px;">
<div class="bottom-sticker-edge"></div>
<div class="bottom-sticker-inner"><span
class="yui-button yui-submit-button submit-button primary"
id="yui-gen17" name="Submit"><span class="first-child"><button
type="button" tabindex="0" id="yui-gen17-button">Save All
</button></span></span>
<script src="/jenkins/adjuncts/5a08e6fd/lib/form/apply/apply.js"
type="text/javascript"></script>
<input type="hidden" name="core:apply" value=""><span
class="yui-button yui-push-button apply-button applyButton"
id="yui-gen11" name="Apply"><span class="first-child"><button
type="button" tabindex="0" id="yui-gen11-button">Apply All
</button></span></span></div>
</div>
</td>
</tr>
</tbody>
</table>
</form>
\ No newline at end of file
......@@ -10,15 +10,15 @@ describe("tabbar-spec tests", function () {
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
expect($('.section-header-row', firstTableMetadata.configTable).size()).toBe(6);
expect($('.section-header-row', firstTableMetadata.configTable).size()).toBe(4);
expect(firstTableMetadata.sectionCount()).toBe(4);
expect($('.tabBar .tab').size()).toBe(8);
expect($('.tabBar .tab').size()).toBe(4);
expect(firstTableMetadata.sectionIds().toString())
.toBe('config_general,config__build_triggers,config__advanced_project_options,config__workflow');
.toBe('config_general,config__advanced_project_options,config__build_triggers,config__build');
done();
}, 'widgets/config/workflow-config.html');
}, 'widgets/config/freestyle-config.html');
});
it("- test section activation", function (done) {
......@@ -31,40 +31,175 @@ describe("tabbar-spec tests", function () {
expect(firstTableMetadata.activeSectionCount()).toBe(1);
firstTableMetadata.onShowSection(function() {
expect(this.id).toBe('config__workflow');
expect(this.id).toBe('config__build');
expect(firstTableMetadata.activeSectionCount()).toBe(1);
var activeSection = firstTableMetadata.activeSection();
expect(activeSection.id).toBe('config__workflow');
expect(activeSection.activeRowCount()).toBe(4);
expect(firstTableMetadata.getTopRows().filter('.active').size()).toBe(3); // should be the same as activeSection.activeRowCount()
expect(activeSection.id).toBe('config__build');
expect(activeSection.activeRowCount()).toBe(2);
expect(firstTableMetadata.getTopRows().filter('.active').size()).toBe(1); // should be activeSection.activeRowCount() - 1
done();
});
// Mimic the user clicking on one of the tabs. Should make that section active,
// with all of the rows in that section having an "active" class.
firstTableMetadata.activateSection('config__workflow');
firstTableMetadata.activateSection('config__build');
// above 'firstTableMetadata.onShowSection' handler should get called now
}, 'widgets/config/workflow-config.html');
}, 'widgets/config/freestyle-config.html');
});
it("- test row-set activation", function (done) {
it("- test row-group modeling", function (done) {
jsTest.onPage(function() {
var configTabBar = jsTest.requireSrcModule('widgets/config/tabbar');
var firstTableMetadata = configTabBar.addTabsOnFirst();
var generalSection = firstTableMetadata.activeSection();
expect(generalSection.id).toBe('config_general');
expect(generalSection.rowGroups.length).toBe(3);
expect(generalSection.getRowGroupLabels().toString()).toBe('Discard Old Builds,This build is parameterized,Execute concurrent builds if necessary,Quiet period');
expect(generalSection.rowGroups[0].getRowCount()).toBe(6);
expect(generalSection.rowGroups[1].getRowCount()).toBe(1);
var sectionRowGroups = generalSection.rowGroups;
expect(sectionRowGroups.length).toBe(1);
expect(sectionRowGroups[0].getRowCount(false)).toBe(0); // zero because it does not have any non row-group rows nested immediately inside i.e. does not have any "normal" rows
expect(sectionRowGroups[0].getRowCount(true)).toBe(4); // there are some nested down in the children. see below
expect(sectionRowGroups[0].rowGroups.length).toBe(1);
expect(sectionRowGroups[0].rowGroups[0].getRowCount(false)).toBe(4); // The inner grouping has rows
expect(sectionRowGroups[0].rowGroups[0].getRowCount()).toBe(4); // Same as above ... just making sure they're direct child rows and not nested below
expect(generalSection.getRowGroupLabels().toString()).toBe('Discard Old Builds');
done();
}, 'widgets/config/freestyle-config.html');
});
it("- test finder - via handler triggering", function (done) {
jsTest.onPage(function() {
var configTabBarWidget = jsTest.requireSrcModule('widgets/config/tabbar');
var configTabBar = configTabBarWidget.addTabsOnFirst();
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
var tabBar = $('.tabBar');
// All tabs should be visible...
expect($('.tab', tabBar).size()).toBe(4);
expect($('.tab.hidden', tabBar).size()).toBe(0);
var finder = configTabBar.findInput;
expect(finder.size()).toBe(1);
// Find sections that have the text "trigger" in them...
keydowns('trigger', finder);
// Need to wait for the change to happen ... there's a 300ms delay.
// We could just call configTabBar.showSections(), but ...
setTimeout(function() {
expect($('.tab.hidden', tabBar).size()).toBe(3);
expect(textCleanup($('.tab.hidden', tabBar).text())).toBe('General|#Advanced Project Options|#Build');
var activeSection = configTabBar.activeSection();
expect(textCleanup(activeSection.title)).toBe('#Build Triggers');
expect($('.highlight-split .highlight').text()).toBe('Trigger');
done();
}, 600);
}, 'widgets/config/freestyle-config.html');
});
it("- test finder - via showSections()", function (done) {
jsTest.onPage(function() {
var configTabBarWidget = jsTest.requireSrcModule('widgets/config/tabbar');
var configTabBar = configTabBarWidget.addTabsOnFirst();
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
var tabBar = $('.tabBar');
configTabBar.showSections('quiet period');
expect($('.tab.hidden', tabBar).size()).toBe(3);
expect(textCleanup($('.tab.hidden', tabBar).text())).toBe('General|#Build Triggers|#Build');
var activeSection = configTabBar.activeSection();
expect(textCleanup(activeSection.title)).toBe('#Advanced Project Options');
done();
}, 'widgets/config/workflow-config.html');
}, 'widgets/config/freestyle-config.html');
});
it("- test finder - via showSections() - in inner row-group", function (done) {
jsTest.onPage(function() {
var configTabBarWidget = jsTest.requireSrcModule('widgets/config/tabbar');
var configTabBar = configTabBarWidget.addTabsOnFirst();
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
var tabBar = $('.tabBar');
configTabBar.showSections('Strategy');
expect($('.tab.hidden', tabBar).size()).toBe(3);
expect(textCleanup($('.tab.hidden', tabBar).text())).toBe('#Advanced Project Options|#Build Triggers|#Build');
var activeSection = configTabBar.activeSection();
expect(textCleanup(activeSection.title)).toBe('General');
done();
}, 'widgets/config/freestyle-config.html');
});
it("- test adopt sections ", function (done) {
jsTest.onPage(function() {
var configTabBarWidget = jsTest.requireSrcModule('widgets/config/tabbar');
var configTabBar = configTabBarWidget.addTabsOnFirst();
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
var tabBar = $('.tabBar');
// Move the advanced stuff into the general section
var general = configTabBar.getSection('config_general');
general.adoptSection('config__advanced_project_options');
// Only 3 tabs should be visible
// (used to be 4 before the merge/adopt)...
expect($('.tab', tabBar).size()).toBe(3);
expect(textCleanup($('.tab', tabBar).text())).toBe('General|#Build Triggers|#Build');
// And if we try to use the finder now to find something
// that was in the advanced section, it should now appear in the
// General section ...
configTabBar.showSections('quiet period');
expect($('.tab.hidden', tabBar).size()).toBe(2);
expect(textCleanup($('.tab.hidden', tabBar).text())).toBe('#Build Triggers|#Build');
var activeSection = configTabBar.activeSection();
expect(textCleanup(activeSection.title)).toBe('General');
done();
}, 'widgets/config/freestyle-config.html');
});
function keydowns(text, onInput) {
var jQD = require('jquery-detached');
var $ = jQD.getJQuery();
// hmmm, for some reason, the key events do not result in the text being
// set in the input, so setting it manually.
onInput.val(text);
// Now fire a keydown event to trigger the handler
var e = $.Event("keydown");
e.which = 116;
onInput.trigger(e);
}
function textCleanup(text) {
return text.trim().replace(/(\r\n|\n|\r)/gm, "").replace(/ +/g, "|");
}
});
// TODO: lots more tests !!!
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册