launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04476
[Merge] lp:~wallyworld/launchpad/revert-broken-picker-search-revs into lp:launchpad
Ian Booth has proposed merging lp:~wallyworld/launchpad/revert-broken-picker-search-revs into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/revert-broken-picker-search-revs/+merge/70385
This branch rolls back rev 13573 which breaks the picker - the picker is stuck in search mode when opened a second time.
Downstream rev 13591 is also rolled back because it depends on rev 13573.
--
https://code.launchpad.net/~wallyworld/launchpad/revert-broken-picker-search-revs/+merge/70385
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/revert-broken-picker-search-revs into lp:launchpad.
=== modified file 'lib/lp/app/javascript/picker/picker.js'
--- lib/lp/app/javascript/picker/picker.js 2011-07-29 18:50:58 +0000
+++ lib/lp/app/javascript/picker/picker.js 2011-08-04 00:31:37 +0000
@@ -55,7 +55,6 @@
FOOTER_SLOT = 'footer_slot',
SELECTED_BATCH = 'selected_batch',
SEARCH_MODE = 'search_mode',
- NUM_SEARCHES = 'num_searches',
NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message',
RENDERUI = "renderUI",
BINDUI = "bindUI",
@@ -637,13 +636,7 @@
// clear the search mode.
this.after('resultsChange', function (e) {
this._syncResultsUI();
- this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)-1);
- this.set(SEARCH_MODE, this._isSearchOngoing());
- }, this);
-
- this.after('search', function (e) {
- this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)+1);
- this.set(SEARCH_MODE, this._isSearchOngoing());
+ this.set(SEARCH_MODE, false);
}, this);
// Update the search slot box whenever the "search_slot" property
@@ -758,17 +751,7 @@
*/
_defaultSearch: function(e) {
this.set(ERROR, null);
- this.set(SEARCH_MODE, this._isSearchOngoing());
- },
-
- /**
- * Are there any outstanding searches at the moment?
- *
- * @method _isSearchOngoing
- * @protected
- */
- _isSearchOngoing: function() {
- return this.get(NUM_SEARCHES) !== 0;
+ this.set(SEARCH_MODE, true);
},
/**
@@ -801,6 +784,17 @@
if ( this.get('clear_on_save') ) {
this._clear();
}
+ },
+
+ /**
+ * By default, the select-batch event turns on search-mode.
+ *
+ * @method _defaultSelectBatch
+ * @param e {Event.Facade} An Event Facade object.
+ * @protected
+ */
+ _defaultSelectBatch: function(e) {
+ this.set(SEARCH_MODE, true);
}
});
@@ -999,14 +993,6 @@
search_mode: { value: false },
/**
- * The current number of outstanding searches.
- *
- * @attribute num_searches
- * @type Integer
- */
- num_searches: { value: 0 },
-
- /**
* The current error message. This puts the widget in 'error-mode',
* setting this value to null clears that state.
*
=== modified file 'lib/lp/app/javascript/picker/tests/test_picker.js'
--- lib/lp/app/javascript/picker/tests/test_picker.js 2011-07-29 18:50:58 +0000
+++ lib/lp/app/javascript/picker/tests/test_picker.js 2011-08-04 00:31:37 +0000
@@ -421,30 +421,10 @@
'CSS class should be removed from the widget.');
},
- test_simultanious_searches: function () {
- // It is possible that an automated search will overlap (temporally)
- // with a user-initiated search. If so, the picker will stay in
- // search mode until until all outstanding searches are finished.
- this.picker.render();
- // Show that we start with search mode disabled.
- Assert.isFalse(this.picker.get('search_mode'));
- this.picker.fire('search', 1);
- this.picker.fire('search', 2);
- // We should be in search mode now.
- Assert.isTrue(this.picker.get('search_mode'));
- // If one of the searches gets results...
- this.picker.set('results', []);
- // ...we're still in search mode.
- Assert.isTrue(this.picker.get('search_mode'));
- // If the second search gets results, then we're out of search mode.
- this.picker.set('results', []);
- Assert.isFalse(this.picker.get('search_mode'));
- },
-
test_set_results_remove_search_mode: function () {
this.picker.render();
- this.picker.fire('search');
+ this.picker.set('search_mode', true);
this.picker.set('results', []);
Assert.isFalse(
=== modified file 'lib/lp/bugs/javascript/tests/test_pre_search.html'
--- lib/lp/bugs/javascript/tests/test_pre_search.html 2011-07-29 18:09:27 +0000
+++ lib/lp/bugs/javascript/tests/test_pre_search.html 2011-08-04 00:31:37 +0000
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
- <title>Branch picker pre-search.</title>
+ <title>Status Editor</title>
<!-- YUI and test setup -->
<script type="text/javascript"
=== modified file 'lib/lp/code/javascript/branch.bugspeclinks.js'
--- lib/lp/code/javascript/branch.bugspeclinks.js 2011-08-02 21:12:40 +0000
+++ lib/lp/code/javascript/branch.bugspeclinks.js 2011-08-04 00:31:37 +0000
@@ -18,34 +18,6 @@
var error_handler;
/*
- * Extract the best candidate for a bug number from the branch name.
- */
-function extract_candidate_bug_id(branch_name) {
- // Extract all the runs of numbers in the branch name and sort by
- // descending length.
- var chunks = branch_name.split(/\D/g).sort(function (a, b) {
- return b.length - a.length;
- });
- var chunk, i;
- for (i=0; i<chunks.length; i++) {
- chunk = chunks[i];
- // Bugs with fewer than six digits aren't being created any more (by
- // Canonical's LP at least), but there are lots of open five digit
- // bugs so ignore runs of fewer than five digits in the branch name.
- if (chunk.length < 5) {
- break;
- }
- // Bug IDs don't start with a zero.
- if (chunk[0] !== '0') {
- return chunk;
- }
- }
- return null;
-}
-// Expose in the namespace so we can test it.
-namespace._extract_candidate_bug_id = extract_candidate_bug_id;
-
-/*
* Connect the links to the javascript events.
*/
namespace.connect_branchlinks = function() {
@@ -78,19 +50,10 @@
linkbug_handle.on('click', function(e) {
e.preventDefault();
link_bug_overlay.show();
- var field = Y.DOM.byId('field.bug');
- field.focus();
- var guessed_bug_id = extract_candidate_bug_id(LP.cache.context.name);
- if (Y.Lang.isValue(guessed_bug_id)) {
- field.value = guessed_bug_id;
- // Select the pre-filled bug number (if any) so that it will be
- // replaced by anything the user types (getting the guessed bug
- // number out of the way quickly if we guessed incorrectly).
- field.selectionStart = 0;
- field.selectionEnd = 999;
- }
+ Y.DOM.byId('field.bug').focus();
});
connect_remove_links();
+
};
/*
@@ -160,10 +123,9 @@
on: {
success: function(id, response) {
destroy_temporary_spinner();
- Y.one('#linkbug')
- .set('innerHTML', 'Link to another bug report');
- Y.one('#buglink-list')
- .set('innerHTML', response.responseText);
+ Y.one('#linkbug').set(
+ 'innerHTML', 'Link to another bug report');
+ Y.one('#buglink-list').set('innerHTML', response.responseText);
var new_buglink = Y.one('#buglink-' + bug.get('id'));
var anim = Y.lazr.anim.green_flash({node: new_buglink});
anim.on('end', connect_remove_links);
=== removed file 'lib/lp/code/javascript/tests/test_bugspeclinks.html'
--- lib/lp/code/javascript/tests/test_bugspeclinks.html 2011-08-02 19:45:03 +0000
+++ lib/lp/code/javascript/tests/test_bugspeclinks.html 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
-<html>
- <head>
- <title>Test page for bug link functionality.</title>
-
- <!-- YUI and test setup -->
- <script type="text/javascript"
- src="../../../../canonical/launchpad/icing/yui/yui/yui.js">
- </script>
- <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />
- <script type="text/javascript"
- src="../../../app/javascript/testing/testrunner.js"></script>
-
- <script type="text/javascript" src="../../../app/javascript/client.js"></script>
- <script type="text/javascript"
- src="../../../app/javascript/overlay/overlay.js"></script>
-
- <!-- The module under test -->
- <script type="text/javascript" src="../branch.bugspeclinks.js"></script>
-
- <!-- The test suite -->
- <script type="text/javascript" src="test_bugspeclinks.js"></script>
- </head>
-
-<body class="yui3-skin-sam">
-</body>
-</html>
=== removed file 'lib/lp/code/javascript/tests/test_bugspeclinks.js'
--- lib/lp/code/javascript/tests/test_bugspeclinks.js 2011-08-02 21:12:40 +0000
+++ lib/lp/code/javascript/tests/test_bugspeclinks.js 1970-01-01 00:00:00 +0000
@@ -1,84 +0,0 @@
-/* Copyright 2011 Canonical Ltd. This software is licensed under the
- * GNU Affero General Public License version 3 (see the file LICENSE).
- *
- * Tests for lp.code.branch.bugspeclinks.
- *
- */
-
-YUI({
- base: '../../../../canonical/launchpad/icing/yui/',
- filter: 'raw', combine: false
- }).use('test', 'console', 'node-event-simulate',
- 'lp.code.branch.bugspeclinks', function(Y) {
-
- var module = Y.lp.code.branch.bugspeclinks;
- var extract_candidate_bug_id = module._extract_candidate_bug_id;
- var suite = new Y.Test.Suite("lp.code.branch.bugspeclinks Tests");
-
- suite.add(new Y.Test.Case({
- name: 'Test bug ID guessing',
-
- test_no_bug_id_present: function() {
- // If nothing that looks like a bug ID is present, null is
- // returned.
- Y.Assert.isNull(extract_candidate_bug_id('no-id-here'));
- },
-
- test_short_digit_rund_ignored: function() {
- Y.Assert.isNull(extract_candidate_bug_id('foo-1234-bar'));
- },
-
- test_leading_zeros_disqualify_potential_ids: function() {
- // Since bug IDs can't start with zeros, any string of numbers
- // with a leading zero are not considered as a potential ID.
- Y.Assert.isNull(extract_candidate_bug_id('foo-0123456-bar'));
- Y.Assert.areEqual(
- extract_candidate_bug_id('foo-0123456-999999-bar'), '999999');
- },
-
- test_five_digit_bug_ids_are_extracted: function() {
- Y.Assert.areEqual(
- extract_candidate_bug_id('foo-12345-bar'), '12345');
- },
-
- test_six_digit_bug_ids_are_extracted: function() {
- Y.Assert.areEqual(
- extract_candidate_bug_id('foo-123456-bar'), '123456');
- },
-
- test_seven_digit_bug_ids_are_extracted: function() {
- Y.Assert.areEqual(
- extract_candidate_bug_id('foo-1234567-bar'), '1234567');
- },
-
- test_eight_digit_bug_ids_are_extracted: function() {
- Y.Assert.areEqual(
- extract_candidate_bug_id('foo-12345678-bar'), '12345678');
- },
-
- test_longest_potential_id_is_extracted: function() {
- // Since there may be numbers other than a bug ID in a branch
- // name, we want to extract the longest string of digits.
- Y.Assert.areEqual(
- extract_candidate_bug_id('bug-123456-take-2'), '123456');
- Y.Assert.areEqual(
- extract_candidate_bug_id('123456-1234567'), '1234567');
- }
-
- }));
-
- var handle_complete = function(data) {
- window.status = '::::' + JSON.stringify(data);
- };
- Y.Test.Runner.on('complete', handle_complete);
- Y.Test.Runner.add(suite);
-
- var console = new Y.Console({newestOnTop: false});
- console.render('#log');
-
- // Start the test runner on Y.after to ensure all setup has had a
- // chance to complete.
- Y.after('domready', function() {
- Y.Test.Runner.run();
- });
-});