Merge lp:~abentley/launchpad/sharing-spinners into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 12854
Proposed branch: lp:~abentley/launchpad/sharing-spinners
Merge into: lp:launchpad
Diff against target: 308 lines (+94/-20)
4 files modified
lib/lp/translations/javascript/sourcepackage_sharing_details.js (+31/-15)
lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html (+14/-5)
lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.js (+33/-0)
lib/lp/translations/templates/sourcepackage-sharing-details.pt (+16/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/sharing-spinners
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+57888@code.launchpad.net

Commit message

Add spinners to translation-sharing actions.

Description of the change

= Summary =
Fix bug #758922: Missing spinners on translations +sharing-details js actions

== Proposed fix ==
Add hidden spinners to web page, show them as needed.

== Pre-implementation notes ==
None

== Implementation details ==
Added a new "pending" boolean to checklist items. When this is true, the TranslationSharingController will show the spinner and hide the picker. When this is false, the TranslationSharingController will hide the spinner and may show the picker.

== Tests ==
firefox lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html

== Demo and Q/A ==
Go to the +sharing-details page for a SourcePackage. Ensure that when each setting is changed, a spinner is shown. This should happen both when the list item was formlerly uncheckd and when it was formerly checked.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/templates/sourcepackage-sharing-details.pt
  lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.js
  lib/lp/translations/javascript/sourcepackage_sharing_details.js
  lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/javascript/sourcepackage_sharing_details.js'
2--- lib/lp/translations/javascript/sourcepackage_sharing_details.js 2011-04-18 13:27:33 +0000
3+++ lib/lp/translations/javascript/sourcepackage_sharing_details.js 2011-04-18 13:41:39 +0000
4@@ -26,7 +26,8 @@
5 }
6 },
7 // The HTML identifier of the item.
8- identifier: null
9+ identifier: null,
10+ pending: {value: false}
11 };
12 Y.extend(CheckItem, Y.Base, {
13 });
14@@ -224,9 +225,8 @@
15 }
16
17
18-function IOHandler(flash_target, error_handler) {
19+function IOHandler(controller, check, error_handler) {
20 that = this;
21- this.flash_target = flash_target;
22 if (!Y.Lang.isValue(error_handler)){
23 this.error_handler = new Y.lp.client.ErrorHandler();
24 }
25@@ -234,7 +234,10 @@
26 this.error_handler = error_handler;
27 }
28 this.error_handler.showError = function(error_msg) {
29- Y.lp.app.errors.display_error(Y.one(that.flash_target), error_msg);
30+ check.set('pending', false);
31+ controller.update_check(check);
32+ var flash_target = Y.one(controller.visible_check_selector(check));
33+ Y.lp.app.errors.display_error(Y.one(flash_target), error_msg);
34 };
35 }
36
37@@ -373,6 +376,8 @@
38 var productseries_check = that.get('tsconfig').get('product_series');
39 var lp_client = new Y.lp.client.Launchpad();
40 function save_productseries(config) {
41+ productseries_check.set('pending', true);
42+ that.update_check(productseries_check);
43 var source_package = that.get('source_package');
44 config.parameters = {
45 productseries: productseries_summary.api_uri};
46@@ -398,11 +403,11 @@
47 }
48 function set_usage(product) {
49 that.replace_product(product);
50+ productseries_check.set('pending', false);
51 that.update();
52 that.flash_check_green(productseries_check);
53 }
54- var css_selector = this.visible_check_selector(productseries_check);
55- var io_handler = new IOHandler(css_selector);
56+ var io_handler = new IOHandler(this, productseries_check);
57 save_productseries(io_handler.chain_config(
58 get_productseries, cache_productseries, cache_branch, set_usage));
59 },
60@@ -421,6 +426,8 @@
61 * closure, such as "that" and "branch_summary".
62 */
63 function save_branch(config) {
64+ branch_check.set('pending', true);
65+ that.update_check(branch_check);
66 productseries.set('branch_link', branch_summary.api_uri);
67 productseries.lp_save(config);
68 }
69@@ -433,11 +440,11 @@
70 }
71 function finish(new_productseries){
72 that.replace_productseries(new_productseries);
73+ branch_check.set('pending', false);
74 that.update();
75 that.flash_check_green(branch_check);
76 }
77- css_selector = that.visible_check_selector(branch_check);
78- var io_handler = new IOHandler(css_selector);
79+ var io_handler = new IOHandler(this, branch_check);
80 save_branch(io_handler.chain_config(get_branch, set_link, finish));
81 },
82 /**
83@@ -475,6 +482,7 @@
84 */
85 update_check: function(check){
86 var complete = Y.one(this.check_selector(check, true));
87+ var hide_picker = !check.get('enabled') || check.get('pending');
88 var link = complete.one('.link a');
89 if (link !== null){
90 link.set('href', check.get('url'));
91@@ -484,14 +492,19 @@
92 complete.toggleClass('lowlight', !check.get('enabled'));
93 var complete_picker = Y.one(this.picker_selector(check, true));
94 if (complete_picker !== null) {
95- complete_picker.toggleClass('unseen', !check.get('enabled'));
96+ complete_picker.toggleClass('unseen', hide_picker);
97 }
98 var incomplete = Y.one(this.check_selector(check, false));
99 incomplete.toggleClass('unseen', check.get('complete'));
100 incomplete.toggleClass('lowlight', !check.get('enabled'));
101 var incomplete_picker = Y.one(this.picker_selector(check, false));
102 if (incomplete_picker !== null) {
103- incomplete_picker.toggleClass('unseen', !check.get('enabled'));
104+ incomplete_picker.toggleClass('unseen', hide_picker);
105+ }
106+ var selector = this.visible_check_selector(check) + '-spinner';
107+ var spinner = Y.one(selector);
108+ if (Y.Lang.isValue(spinner)){
109+ spinner.toggleClass('unseen', !check.get('pending'));
110 }
111 },
112 flash_check_green: function(check) {
113@@ -542,14 +555,15 @@
114 product_series.set('translations_autoimport_mode', mode);
115 var autoimport_check = sharing_controller.get(
116 'tsconfig').get('autoimport');
117- var css_selector = sharing_controller.visible_check_selector(
118- autoimport_check);
119- handler = new IOHandler(css_selector);
120+ handler = new IOHandler(sharing_controller, autoimport_check);
121 function update_controller() {
122 sharing_controller.set_autoimport_mode(mode);
123+ autoimport_check.set('pending', false);
124 sharing_controller.update();
125 sharing_controller.flash_check_green(autoimport_check);
126 }
127+ autoimport_check.set('pending', true);
128+ sharing_controller.update_check(autoimport_check);
129 /* XXX: AaronBentley 2011-04-04 bug=369293: Avoid 412 on repeated
130 * changes. This does not increase the risk of changing from a
131 * stale value, because the staleness check is not reasonable.
132@@ -581,12 +595,14 @@
133 }
134 function replace_product(new_product) {
135 sharing_controller.replace_product(new_product);
136+ usage.set('pending', false);
137 sharing_controller.update();
138 sharing_controller.flash_check_green(usage);
139 }
140- css_selector = sharing_controller.visible_check_selector(usage);
141 var io_handler = new IOHandler(
142- css_selector, new Y.lp.client.FormErrorHandler());
143+ sharing_controller, usage, new Y.lp.client.FormErrorHandler());
144+ usage.set('pending', true);
145+ sharing_controller.update_check(usage);
146 var config = io_handler.chain_config(
147 get_productseries, replace_productseries, get_product,
148 replace_product);
149
150=== modified file 'lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html'
151--- lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html 2011-04-04 19:36:27 +0000
152+++ lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.html 2011-04-18 13:41:39 +0000
153@@ -46,8 +46,13 @@
154 <div id="branch-complete">Branch selected: <span class="link"><a
155 href="#" class="link"></a></span>
156 <span id="branch-complete-picker"><a href="#"></a></span>
157- </div>
158- <div id="branch-incomplete">No branch selected.</div>
159+ <img src="../../../../canonical/launchpad/images/spinner.gif"
160+ id="branch-complete-spinner"/>
161+ </div>
162+ <div id="branch-incomplete">No branch selected.
163+ <img src="../../../../canonical/launchpad/images/spinner.gif"
164+ id="branch-incomplete-spinner"/>
165+ </div>
166 <span id="branch-incomplete-picker"><a href="#"></a></span>
167 <div id="translation-incomplete">
168 Translations are not enabled on the upstream project.
169@@ -58,12 +63,16 @@
170 <a href="#enable-translations"></a>
171 </div>
172 <div id="upstream-sync-incomplete">
173- Automatic synchronization of translations is not enabled.
174- <a href="#enable-sync"></a>
175+ Automatic synchronization of translations is not enabled.
176+ <img src="../../../../canonical/launchpad/images/spinner.gif"
177+ id="upstream-sync-incomplete-spinner"/>
178+ <span id="upstream-sync-incomplete-picker"><a href="#enable-sync"></a></span>
179 </div>
180 <div id="upstream-sync-complete">
181 Automatic synchronization of translations is enabled.
182- <a href="#enable-sync"></a>
183+ <span id="upstream-sync-complete-picker"><a href="#enable-sync"></a></span>
184+ <img src="../../../../canonical/launchpad/images/spinner.gif"
185+ id="upstream-sync-complete-spinner"/>
186 </div>
187 </div>
188 <!-- The test output -->
189
190=== modified file 'lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.js'
191--- lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.js 2011-04-14 15:43:14 +0000
192+++ lib/lp/translations/javascript/tests/test_sourcepackage_sharing_details.js 2011-04-18 13:41:39 +0000
193@@ -210,6 +210,39 @@
194 ctrl.update_check(branch);
195 Y.Assert.isFalse(incomplete.hasClass('lowlight'));
196 },
197+ test_update_check_pending: function(){
198+ var incomplete_spinner = Y.one(
199+ '#upstream-sync-incomplete-spinner');
200+ var ctrl = new TranslationSharingController();
201+ var autoimport = ctrl.get('tsconfig').get('autoimport');
202+ var branch = ctrl.get('tsconfig').get('branch');
203+ branch.set_link('a', 'b');
204+ var incomplete_picker = Y.one(
205+ ctrl.picker_selector(autoimport, false));
206+ ctrl.update_check(autoimport);
207+ Y.Assert.isTrue(
208+ incomplete_spinner.hasClass('unseen'), 'spinner unseen');
209+ Y.Assert.isFalse(
210+ incomplete_picker.hasClass('unseen'), 'picker seen');
211+ autoimport.set('pending', true);
212+ ctrl.update_check(autoimport);
213+ Y.Assert.isFalse(
214+ incomplete_spinner.hasClass('unseen'), 'spinner seen');
215+ Y.Assert.isTrue(
216+ incomplete_picker.hasClass('unseen'), 'picker unseen');
217+ autoimport.set('complete', true);
218+ var complete_spinner = Y.one(
219+ '#upstream-sync-complete-spinner');
220+ var complete_picker = Y.one(
221+ ctrl.picker_selector(autoimport, true));
222+ ctrl.update_check(autoimport);
223+ Y.Assert.isFalse(complete_spinner.hasClass('unseen'));
224+ Y.Assert.isTrue(complete_picker.hasClass('unseen'));
225+ autoimport.set('pending', false);
226+ ctrl.update_check(autoimport);
227+ Y.Assert.isTrue(complete_spinner.hasClass('unseen'));
228+ Y.Assert.isFalse(complete_picker.hasClass('unseen'));
229+ },
230 test_set_autoimport_mode: function() {
231 var ctrl = new TranslationSharingController();
232 var check = ctrl.get('tsconfig').get('autoimport');
233
234=== modified file 'lib/lp/translations/templates/sourcepackage-sharing-details.pt'
235--- lib/lp/translations/templates/sourcepackage-sharing-details.pt 2011-04-11 17:16:28 +0000
236+++ lib/lp/translations/templates/sourcepackage-sharing-details.pt 2011-04-18 13:41:39 +0000
237@@ -39,6 +39,8 @@
238 <span id="packaging-incomplete-picker">
239 <a tal:replace="structure view/set_packaging_link/escapedtext" />
240 </span>
241+ <img src="/@@/spinner" class="unseen"
242+ id="packaging-incomplete-spinner"/>
243 </li>
244 <li tal:attributes="class view/packaging_complete_class"
245 id="packaging-complete">
246@@ -51,6 +53,8 @@
247 <span id="packaging-complete-picker">
248 <a tal:replace="structure view/change_packaging_link/escapedtext" />
249 </span>
250+ <img src="/@@/spinner" class="unseen"
251+ id="packaging-complete-spinner"/>
252 <a tal:replace="structure view/remove_packaging_link/escapedtext" />
253 </li>
254 <li tal:attributes="class view/branch_incomplete_class"
255@@ -59,6 +63,8 @@
256 <span id="branch-incomplete-picker">
257 <a tal:replace="structure view/new_branch_link/escapedtext" />
258 </span>
259+ <img src="/@@/spinner" class="unseen"
260+ id="branch-incomplete-spinner"/>
261 </li>
262 <li tal:attributes="class view/branch_complete_class"
263 id="branch-complete">
264@@ -69,6 +75,8 @@
265 <span id="branch-complete-picker">
266 <a tal:replace="structure view/change_branch_link/escapedtext" />
267 </span>
268+ <img src="/@@/spinner" class="unseen"
269+ id="branch-complete-spinner"/>
270 </li>
271 <li tal:attributes="class view/translations_disabled_class"
272 id="translation-incomplete">
273@@ -76,6 +84,8 @@
274 <span id="translation-incomplete-picker">
275 <a tal:replace="structure view/configure_translations_link_unconfigured/escapedtext" />
276 </span>
277+ <img src="/@@/spinner" class="unseen"
278+ id="translation-incomplete-spinner"/>
279 </li>
280 <li tal:attributes="class view/translations_enabled_class"
281 id="translation-complete">
282@@ -83,6 +93,8 @@
283 <span id="translation-complete-picker">
284 <a tal:replace="structure view/configure_translations_link_configured/escapedtext" />
285 </span>
286+ <img src="/@@/spinner" class="unseen"
287+ id="translation-complete-spinner"/>
288 </li>
289 <li tal:attributes="class view/upstream_sync_disabled_class"
290 id="upstream-sync-incomplete">
291@@ -90,6 +102,8 @@
292 <span id="upstream-sync-incomplete-picker">
293 <a tal:replace="structure view/translation_sync_link_unconfigured/escapedtext" />
294 </span>
295+ <img src="/@@/spinner" class="unseen"
296+ id="upstream-sync-incomplete-spinner"/>
297 </li>
298 <li tal:attributes="class view/upstream_sync_enabled_class"
299 id="upstream-sync-complete">
300@@ -97,6 +111,8 @@
301 <span id="upstream-sync-complete-picker">
302 <a tal:replace="structure view/translation_sync_link_configured/escapedtext" />
303 </span>
304+ <img src="/@@/spinner" class="unseen"
305+ id="upstream-sync-complete-spinner"/>
306 </li>
307 </ul>
308 </dd>