Merge lp:~rharding/juju-gui/new-controls into lp:juju-gui/experimental
- new-controls
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 792 |
Proposed branch: | lp:~rharding/juju-gui/new-controls |
Merge into: | lp:juju-gui/experimental |
Prerequisite: | lp:~huwshimi/juju-gui/visual-update-1 |
Diff against target: |
672 lines (+365/-121) 12 files modified
app/index.html (+6/-4) app/modules-debug.js (+4/-0) app/subapps/browser/views/view.js (+43/-19) app/templates/browser-search.handlebars (+0/-1) app/widgets/charm-search.js (+3/-49) app/widgets/viewmode-controls.js (+170/-0) lib/views/browser/main.less (+0/-15) lib/views/stylesheet.less (+20/-0) test/index.html (+1/-0) test/test_browser_app.js (+18/-5) test/test_browser_search_widget.js (+1/-28) test/test_viewmode_controls_widget.js (+99/-0) |
To merge this branch: | bzr merge lp:~rharding/juju-gui/new-controls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Richard Harding | Approve | ||
Review via email:
|
Commit message
Break up the search widget to work with updated UX.
- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.
This branch does not update the minimized search to work correctly in the grand scheme of things yet.
Description of the change
Break up the search widget to work with updated UX
- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.
This branch does not update the minimized search to work correctly in the grand scheme of things yet.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Richard Harding (rharding) wrote : | # |
- 790. By Richard Harding
-
update per review
- 791. By Richard Harding
-
More @event docs
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Curtis Hovey (sinzui) wrote : | # |
Thank you Rick. These changes LGTM with the additional changes that I
can see are already added at Lp.
I see the discussion about widget vs view. I think widget is fine at
this time. This is clearly more than a view. The widget might be too
heavy for this use, but that may change in the next few weeks. That is
to say, We are making this late change to accommodate a late design.
Given the urgency to get the UI looking good, I think it is wiser to
review what we don't need at the end of July.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Richard Harding (rharding) wrote : | # |
Curtis and Jeff approved. Will wait to land as part of Huw's work since this branch depends on his.
- 792. By Richard Harding
-
Update from trunk
- 793. By Richard Harding
-
remove block of css no longer needed
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Richard Harding (rharding) wrote : | # |
*** Submitted:
Break up the search widget to work with updated UX
- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct
fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.
This branch does not update the minimized search to work correctly in
the grand scheme of things yet.
R=curtis
CC=
https:/
Preview Diff
1 | === modified file 'app/index.html' |
2 | --- app/index.html 2013-07-02 05:47:25 +0000 |
3 | +++ app/index.html 2013-07-03 12:47:32 +0000 |
4 | @@ -126,10 +126,12 @@ |
5 | <i class="sprite juju_logo_dark" title="Juju GUI"></i> |
6 | </a> |
7 | </div> |
8 | - <ul id="browser-nav"> |
9 | - <li><a href="">Browse</a></li> |
10 | - <li><a href="">Build</a></li> |
11 | - </ul> |
12 | + <div id="browser-nav"> |
13 | + <ul> |
14 | + <li><a class="fullscreen" href="">Browse</a></li> |
15 | + <li><a class="sidebar" href="">Build</a></li> |
16 | + </ul> |
17 | + </div> |
18 | <div id="environment-switcher"> |
19 | <i class="sprite environment_icon"> </i> |
20 | <span id="environment-name" draggable="true"></span> |
21 | |
22 | === modified file 'app/modules-debug.js' |
23 | --- app/modules-debug.js 2013-06-24 22:53:39 +0000 |
24 | +++ app/modules-debug.js 2013-07-03 12:47:32 +0000 |
25 | @@ -153,6 +153,10 @@ |
26 | fullpath: '/juju-ui/widgets/charm-search.js' |
27 | }, |
28 | |
29 | + 'viewmode-controls': { |
30 | + fullpath: '/juju-ui/widgets/viewmode-controls.js' |
31 | + }, |
32 | + |
33 | 'browser-tabview': { |
34 | fullpath: '/juju-ui/widgets/browser-tabview.js' |
35 | }, |
36 | |
37 | === modified file 'app/subapps/browser/views/view.js' |
38 | --- app/subapps/browser/views/view.js 2013-06-10 15:04:39 +0000 |
39 | +++ app/subapps/browser/views/view.js 2013-07-03 12:47:32 +0000 |
40 | @@ -85,13 +85,17 @@ |
41 | */ |
42 | _bindSearchWidgetEvents: function() { |
43 | this.addEvent( |
44 | - this.search.on( |
45 | - this.search.EVT_TOGGLE_VIEWABLE, this._toggleBrowser, this) |
46 | + this.controls.on( |
47 | + this.controls.EVT_TOGGLE_VIEWABLE, this._toggleBrowser, this) |
48 | ); |
49 | |
50 | this.addEvent( |
51 | - this.search.on( |
52 | - this.search.EVT_TOGGLE_FULLSCREEN, this._toggleFullscreen, this) |
53 | + this.controls.on( |
54 | + this.controls.EVT_FULLSCREEN, this._goFullscreen, this) |
55 | + ); |
56 | + this.addEvent( |
57 | + this.controls.on( |
58 | + this.controls.EVT_SIDEBAR, this._goSidebar, this) |
59 | ); |
60 | |
61 | this.addEvent( |
62 | @@ -114,6 +118,9 @@ |
63 | fullscreenTarget: this._fullscreenTarget |
64 | }); |
65 | this.search.render(node.one('.bws-header')); |
66 | + |
67 | + this.controls = new widgets.ViewmodeControls(); |
68 | + this.controls.render(); |
69 | }, |
70 | |
71 | /** |
72 | @@ -153,20 +160,36 @@ |
73 | }, |
74 | |
75 | /** |
76 | - Upon clicking the fullscreen toggle icon make sure we re-route to the |
77 | - new form of the UX. |
78 | - |
79 | - @method _toggleFullscreen |
80 | - @param {Event} ev the click event handler on the button. |
81 | - |
82 | - */ |
83 | - _toggleFullscreen: function(ev) { |
84 | - ev.halt(); |
85 | - var change = { |
86 | - viewmode: this.isFullscreen() ? 'sidebar' : 'fullscreen' |
87 | - }; |
88 | - this.fire('viewNavigate', { |
89 | - change: change |
90 | + Upon clicking the browser icon make sure we re-route to the |
91 | + new form of the UX. |
92 | + |
93 | + @method _goFullscreen |
94 | + @param {Event} ev the click event handler on the button. |
95 | + |
96 | + */ |
97 | + _goFullscreen: function(ev) { |
98 | + ev.halt(); |
99 | + this.fire('viewNavigate', { |
100 | + change: { |
101 | + viewmode: 'fullscreen' |
102 | + } |
103 | + }); |
104 | + }, |
105 | + |
106 | + /** |
107 | + Upon clicking the build icon make sure we re-route to the |
108 | + new form of the UX. |
109 | + |
110 | + @method _goSidebar |
111 | + @param {Event} ev the click event handler on the button. |
112 | + |
113 | + */ |
114 | + _goSidebar: function(ev) { |
115 | + ev.halt(); |
116 | + this.fire('viewNavigate', { |
117 | + change: { |
118 | + viewmode: 'sidebar' |
119 | + } |
120 | }); |
121 | }, |
122 | |
123 | @@ -263,6 +286,7 @@ |
124 | 'juju-charm-store', |
125 | 'juju-models', |
126 | 'querystring-stringify', |
127 | - 'view' |
128 | + 'view', |
129 | + 'viewmode-controls' |
130 | ] |
131 | }); |
132 | |
133 | === modified file 'app/templates/browser-search.handlebars' |
134 | --- app/templates/browser-search.handlebars 2013-07-02 05:47:25 +0000 |
135 | +++ app/templates/browser-search.handlebars 2013-07-03 12:47:32 +0000 |
136 | @@ -1,3 +1,2 @@ |
137 | <a href="" class="bws-icon"></a> |
138 | -<a href="" class="toggle-fullscreen"></a> |
139 | {{> bws-searchbox }} |
140 | |
141 | === modified file 'app/widgets/charm-search.js' |
142 | --- app/widgets/charm-search.js 2013-07-02 05:47:25 +0000 |
143 | +++ app/widgets/charm-search.js 2013-07-03 12:47:32 +0000 |
144 | @@ -38,14 +38,15 @@ |
145 | * |
146 | * @class Search |
147 | * @extends {Y.Widget} |
148 | + * @event EV_CLEAR_SEARCH the widget requests all search reset. |
149 | + * @event EV_SEARCH_CHANGED the widgets notifies that the search input has |
150 | + * changed. |
151 | * |
152 | */ |
153 | ns.Search = Y.Base.create('search-widget', Y.Widget, [ |
154 | Y.Event.EventTracker |
155 | ], { |
156 | EVT_CLEAR_SEARCH: 'clear_search', |
157 | - EVT_TOGGLE_VIEWABLE: 'toggle_viewable', |
158 | - EVT_TOGGLE_FULLSCREEN: 'toggle_fullscreen', |
159 | EVT_SEARCH_CHANGED: 'search_changed', |
160 | |
161 | TEMPLATE: templates['browser-search'], |
162 | @@ -68,33 +69,6 @@ |
163 | }, |
164 | |
165 | /** |
166 | - * Expose to the outside world that we've got a request to go fullscreen. |
167 | - * |
168 | - * @method _toggleFullScreen |
169 | - * @param {Event} ev the click event from the control. |
170 | - * @private |
171 | - * |
172 | - */ |
173 | - _toggleFullScreen: function(ev) { |
174 | - ev.halt(); |
175 | - this.fire(this.EVT_TOGGLE_FULLSCREEN); |
176 | - }, |
177 | - |
178 | - /** |
179 | - * Expose to the outside world that we've got a request to hide from |
180 | - * sight. |
181 | - * |
182 | - * @method _toggleViewable |
183 | - * @param {Event} ev the click event from the control. |
184 | - * @private |
185 | - * |
186 | - */ |
187 | - _toggleViewable: function(ev) { |
188 | - ev.halt(); |
189 | - this.fire(this.EVT_TOGGLE_VIEWABLE); |
190 | - }, |
191 | - |
192 | - /** |
193 | * Set the form to active so that we can change the search appearance. |
194 | * |
195 | * @method _setActive |
196 | @@ -134,14 +108,6 @@ |
197 | var container = this.get('boundingBox'); |
198 | |
199 | this.addEvent( |
200 | - container.one('.bws-icon').on( |
201 | - 'click', this._toggleViewable, this) |
202 | - ); |
203 | - this.addEvent( |
204 | - container.one('.toggle-fullscreen').on( |
205 | - 'click', this._toggleFullScreen, this) |
206 | - ); |
207 | - this.addEvent( |
208 | container.one('form').on( |
209 | 'submit', this._handleSubmit, this) |
210 | ); |
211 | @@ -170,8 +136,6 @@ |
212 | * widget only needs to clear the search input box. |
213 | * |
214 | */ |
215 | - this.publish(this.EVT_TOGGLE_VIEWABLE); |
216 | - this.publish(this.EVT_TOGGLE_FULLSCREEN); |
217 | this.publish(this.EVT_SEARCH_CHANGED); |
218 | }, |
219 | |
220 | @@ -220,16 +184,6 @@ |
221 | value: { |
222 | text: '' |
223 | } |
224 | - }, |
225 | - /** |
226 | - @attribute fullscreeTarget |
227 | - @default undefined |
228 | - @type {Node} |
229 | - @required true |
230 | - |
231 | - */ |
232 | - fullscreenTarget: { |
233 | - required: true |
234 | } |
235 | } |
236 | }); |
237 | |
238 | === added file 'app/widgets/viewmode-controls.js' |
239 | --- app/widgets/viewmode-controls.js 1970-01-01 00:00:00 +0000 |
240 | +++ app/widgets/viewmode-controls.js 2013-07-03 12:47:32 +0000 |
241 | @@ -0,0 +1,170 @@ |
242 | +/* |
243 | +This file is part of the Juju GUI, which lets users view and manage Juju |
244 | +environments within a graphical interface (https://launchpad.net/juju-gui). |
245 | +Copyright (C) 2012-2013 Canonical Ltd. |
246 | + |
247 | +This program is free software: you can redistribute it and/or modify it under |
248 | +the terms of the GNU Affero General Public License version 3, as published by |
249 | +the Free Software Foundation. |
250 | + |
251 | +This program is distributed in the hope that it will be useful, but WITHOUT |
252 | +ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
253 | +SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero |
254 | +General Public License for more details. |
255 | + |
256 | +You should have received a copy of the GNU Affero General Public License along |
257 | +with this program. If not, see <http://www.gnu.org/licenses/>. |
258 | +*/ |
259 | + |
260 | +'use strict'; |
261 | + |
262 | + |
263 | +/** |
264 | + * The widget used across Browser view to manage the search box and the |
265 | + * controls for selecting which view you're in. |
266 | + * |
267 | + * @module widgets |
268 | + * @submodule browser |
269 | + * |
270 | + */ |
271 | +YUI.add('viewmode-controls', function(Y) { |
272 | + var ns = Y.namespace('juju.widgets'); |
273 | + |
274 | + |
275 | + /** |
276 | + * Search widget present in the Charm browser across both fullscreen and |
277 | + * sidebar views. |
278 | + * |
279 | + * @class ViewmodeControls |
280 | + * @extends {Y.Widget} |
281 | + * @event EV_TOGGLE_VIEWABLE toggle if the browser is visible. |
282 | + * @event EV_FULLSCREEN force fullscreen viewmode. |
283 | + * @event EV_SIDEBAR force the sidebar viewmode. |
284 | + * |
285 | + */ |
286 | + ns.ViewmodeControls = Y.Base.create('viewmode-controls', Y.Widget, [ |
287 | + Y.Event.EventTracker |
288 | + ], { |
289 | + CONTENT_TEMPLATE: null, |
290 | + EVT_TOGGLE_VIEWABLE: 'toggle_viewable', |
291 | + EVT_FULLSCREEN: 'fullscreen', |
292 | + EVT_SIDEBAR: 'sidebar', |
293 | + |
294 | + /** |
295 | + * Expose to the outside world that we've got a request to go fullscreen. |
296 | + * |
297 | + * @method _goFullscreen |
298 | + * @param {Event} ev the click event from the control. |
299 | + * @private |
300 | + * |
301 | + */ |
302 | + _goFullscreen: function(ev) { |
303 | + ev.halt(); |
304 | + this.fire(this.EVT_FULLSCREEN); |
305 | + }, |
306 | + |
307 | + /** |
308 | + * Expose to the outside world that we've got a request to go sidebar. |
309 | + * |
310 | + * @method _goSidebar |
311 | + * @param {Event} ev the click event from the control. |
312 | + * @private |
313 | + * |
314 | + */ |
315 | + _goSidebar: function(ev) { |
316 | + ev.halt(); |
317 | + this.fire(this.EVT_SIDEBAR); |
318 | + }, |
319 | + |
320 | + /** |
321 | + * Expose to the outside world that we've got a request to hide from |
322 | + * sight. |
323 | + * |
324 | + * @method _toggleViewable |
325 | + * @param {Event} ev the click event from the control. |
326 | + * @private |
327 | + * |
328 | + */ |
329 | + _toggleViewable: function(ev) { |
330 | + ev.halt(); |
331 | + this.fire(this.EVT_TOGGLE_VIEWABLE); |
332 | + }, |
333 | + |
334 | + /** |
335 | + * bind the UI events to the DOM making up the widget control. |
336 | + * |
337 | + * @method bindUI |
338 | + * |
339 | + */ |
340 | + bindUI: function() { |
341 | + var container = this.get('boundingBox'); |
342 | + |
343 | + this.addEvent( |
344 | + Y.one('#content').delegate( |
345 | + 'click', |
346 | + this._toggleViewable, |
347 | + '.bws-icon', |
348 | + this |
349 | + ) |
350 | + ); |
351 | + this.addEvent( |
352 | + container.one('.fullscreen').on( |
353 | + 'click', this._goFullscreen, this) |
354 | + ); |
355 | + this.addEvent( |
356 | + container.one('.sidebar').on( |
357 | + 'click', this._goSidebar, this) |
358 | + ); |
359 | + |
360 | + }, |
361 | + |
362 | + /** |
363 | + * Generic initializer for the widget. Publish events we expose for |
364 | + * outside use. |
365 | + * |
366 | + * @method initializer |
367 | + * @param {Object} cfg configuration override object. |
368 | + * |
369 | + */ |
370 | + initializer: function(cfg) { |
371 | + /* |
372 | + * Fires when the "Charm Browser" link is checked. Needs to communicate |
373 | + * with the parent view so that it can handle filters and the like. This |
374 | + * widget only needs to clear the search input box. |
375 | + * |
376 | + */ |
377 | + this.publish(this.EVT_TOGGLE_VIEWABLE); |
378 | + this.publish(this.EVT_SIDEBAR); |
379 | + this.publish(this.EVT_FULLSCREEN); |
380 | + } |
381 | + |
382 | + }, { |
383 | + ATTRS: { |
384 | + /** |
385 | + * @attribute boundingBox |
386 | + * @default {Node} the .browser-nav ul |
387 | + * @type {Node} |
388 | + * |
389 | + */ |
390 | + boundingBox: { |
391 | + /** |
392 | + * @method boundingBox.valueFn |
393 | + * @return {Node} The already present browser-nav node. |
394 | + * |
395 | + */ |
396 | + valueFn: function() { |
397 | + return Y.one('#browser-nav'); |
398 | + } |
399 | + } |
400 | + |
401 | + } |
402 | + }); |
403 | + |
404 | +}, '0.1.0', { |
405 | + requires: [ |
406 | + 'base', |
407 | + 'event', |
408 | + 'event-tracker', |
409 | + 'widget' |
410 | + ] |
411 | +}); |
412 | |
413 | === modified file 'lib/views/browser/main.less' |
414 | --- lib/views/browser/main.less 2013-07-02 05:47:25 +0000 |
415 | +++ lib/views/browser/main.less 2013-07-03 12:47:32 +0000 |
416 | @@ -41,21 +41,6 @@ |
417 | .bws-header { |
418 | padding: 20px; |
419 | border-bottom: 1px solid @bws-border; |
420 | - |
421 | - //XXX: this can be removed once the control has been moved to the header. |
422 | - .toggle-fullscreen { |
423 | - position: absolute; |
424 | - display: block; |
425 | - right: -40px; |
426 | - top: 20px; |
427 | - width: 40px; |
428 | - height: 40px; |
429 | - background: @bws-dark url(/juju-ui/assets/images/browser_min_max.png) |
430 | - no-repeat 0 0; |
431 | - box-shadow: 3px 0 2px rgba(0, 0, 0, 0.1); |
432 | - border-top-right-radius: 4px; |
433 | - border-bottom-right-radius: 4px; |
434 | - } |
435 | } |
436 | #bws-search { |
437 | .search-title { |
438 | |
439 | === modified file 'lib/views/stylesheet.less' |
440 | --- lib/views/stylesheet.less 2013-07-03 12:38:35 +0000 |
441 | +++ lib/views/stylesheet.less 2013-07-03 12:47:32 +0000 |
442 | @@ -255,6 +255,26 @@ |
443 | } |
444 | } |
445 | } |
446 | + #browser-nav { |
447 | + float: left; |
448 | + |
449 | + ul { |
450 | + margin: 0 20px 0 0; |
451 | + padding: 0; |
452 | + list-style: none; |
453 | + } |
454 | + |
455 | + li { |
456 | + float: left; |
457 | + |
458 | + a { |
459 | + display: block; |
460 | + padding: 25px 10px 0 10px; |
461 | + font-size: 12pt; |
462 | + color: #9b9b9b; |
463 | + } |
464 | + } |
465 | + } |
466 | #environment-switcher { |
467 | float: left; |
468 | height: 47px; |
469 | |
470 | === modified file 'test/index.html' |
471 | --- test/index.html 2013-06-28 13:54:34 +0000 |
472 | +++ test/index.html 2013-07-03 12:47:32 +0000 |
473 | @@ -131,6 +131,7 @@ |
474 | |
475 | <script src="test_utils.js"></script> |
476 | <script src="test_view_container.js"></script> |
477 | + <script src="test_viewmode_controls_widget.js"></script> |
478 | <script src="test_viewport_module.js"></script> |
479 | <script src="test_websocket_logging.js"></script> |
480 | <script> |
481 | |
482 | === modified file 'test/test_browser_app.js' |
483 | --- test/test_browser_app.js 2013-06-27 17:40:21 +0000 |
484 | +++ test/test_browser_app.js 2013-07-03 12:47:32 +0000 |
485 | @@ -47,8 +47,15 @@ |
486 | }); |
487 | |
488 | var addBrowserContainer = function(Y) { |
489 | - Y.Node.create('<div id="subapp-browser">' + |
490 | - '</div>').appendTo(container); |
491 | + Y.Node.create([ |
492 | + '<div id="content">', |
493 | + '<div id="browser-nav">', |
494 | + '<div class="sidebar"></div>', |
495 | + '<div class="fullscreen"</div>', |
496 | + '</div>', |
497 | + '<div id="subapp-browser"></div>', |
498 | + '</div>' |
499 | + ].join('')).appendTo(container); |
500 | }; |
501 | |
502 | afterEach(function() { |
503 | @@ -128,11 +135,17 @@ |
504 | }); |
505 | |
506 | var addBrowserContainer = function(Y) { |
507 | - Y.Node.create('<div id="subapp-browser">' + |
508 | - '</div>').appendTo(container); |
509 | + Y.Node.create([ |
510 | + '<div id="content">', |
511 | + '<div id="browser-nav">', |
512 | + '<div class="sidebar"></div>', |
513 | + '<div class="fullscreen"</div>', |
514 | + '</div>', |
515 | + '<div id="subapp-browser"></div>', |
516 | + '</div>' |
517 | + ].join('')).appendTo(container); |
518 | }; |
519 | |
520 | - |
521 | it('knows that it is not fullscreen', function() { |
522 | view = new Sidebar(); |
523 | view.isFullscreen().should.equal(false); |
524 | |
525 | === modified file 'test/test_browser_search_widget.js' |
526 | --- test/test_browser_search_widget.js 2013-07-02 05:47:25 +0000 |
527 | +++ test/test_browser_search_widget.js 2013-07-03 12:47:32 +0000 |
528 | @@ -24,7 +24,7 @@ |
529 | |
530 | before(function(done) { |
531 | Y = YUI(GlobalConfig).use(['browser-search-widget', |
532 | - 'juju-tests-utils', |
533 | + 'juju-tests-utils', |
534 | 'event-simulate', |
535 | 'node-event-simulate', |
536 | 'node'], function(Y) { |
537 | @@ -56,31 +56,4 @@ |
538 | container.one('input').get('value').should.eql('test'); |
539 | }); |
540 | |
541 | - it('should fire a toggle fullscreen event when expand clicked', function() { |
542 | - var search = new Search(), |
543 | - triggered = false; |
544 | - search.render(container); |
545 | - |
546 | - search.on(search.EVT_TOGGLE_FULLSCREEN, function(ev) { |
547 | - triggered = true; |
548 | - }); |
549 | - |
550 | - var toggle = container.one('.toggle-fullscreen'); |
551 | - toggle.simulate('click'); |
552 | - triggered.should.eql(true); |
553 | - }); |
554 | - |
555 | - it('should fire a toggle viewable event when icon clicked', function() { |
556 | - var search = new Search(), |
557 | - triggered = false; |
558 | - search.render(container); |
559 | - |
560 | - search.on(search.EVT_TOGGLE_VIEWABLE, function(ev) { |
561 | - triggered = true; |
562 | - }); |
563 | - |
564 | - var toggle = container.one('.bws-icon'); |
565 | - toggle.simulate('click'); |
566 | - triggered.should.eql(true); |
567 | - }); |
568 | }); |
569 | |
570 | === added file 'test/test_viewmode_controls_widget.js' |
571 | --- test/test_viewmode_controls_widget.js 1970-01-01 00:00:00 +0000 |
572 | +++ test/test_viewmode_controls_widget.js 2013-07-03 12:47:32 +0000 |
573 | @@ -0,0 +1,99 @@ |
574 | +/* |
575 | +This file is part of the Juju GUI, which lets users view and manage Juju |
576 | +environments within a graphical interface (https://launchpad.net/juju-gui). |
577 | +Copyright (C) 2012-2013 Canonical Ltd. |
578 | + |
579 | +This program is free software: you can redistribute it and/or modify it under |
580 | +the terms of the GNU Affero General Public License version 3, as published by |
581 | +the Free Software Foundation. |
582 | + |
583 | +This program is distributed in the hope that it will be useful, but WITHOUT |
584 | +ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
585 | +SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero |
586 | +General Public License for more details. |
587 | + |
588 | +You should have received a copy of the GNU Affero General Public License along |
589 | +with this program. If not, see <http://www.gnu.org/licenses/>. |
590 | +*/ |
591 | + |
592 | +'use strict'; |
593 | + |
594 | + |
595 | +describe('viewmode controls widgets', function() { |
596 | + var Y, container, controls, ViewmodeControls; |
597 | + |
598 | + before(function(done) { |
599 | + Y = YUI(GlobalConfig).use(['viewmode-controls', |
600 | + 'juju-tests-utils', |
601 | + 'event-simulate', |
602 | + 'node-event-simulate', |
603 | + 'node'], function(Y) { |
604 | + ViewmodeControls = Y.juju.widgets.ViewmodeControls; |
605 | + done(); |
606 | + }); |
607 | + }); |
608 | + |
609 | + beforeEach(function() { |
610 | + container = Y.namespace('juju-tests.utils').makeContainer('container'); |
611 | + Y.Node.create([ |
612 | + '<div id="content">', |
613 | + '<div id="browser-nav">', |
614 | + '<div class="sidebar"></div>', |
615 | + '<div class="fullscreen"</div>', |
616 | + '</div>' |
617 | + ].join('')).appendTo(container); |
618 | + }); |
619 | + |
620 | + afterEach(function() { |
621 | + container.remove(true); |
622 | + if (controls) { |
623 | + controls.destroy(); |
624 | + } |
625 | + }); |
626 | + |
627 | + it('should fire a fullscreen event when expand clicked', function() { |
628 | + var triggered = false; |
629 | + controls = new ViewmodeControls(); |
630 | + controls.render(); |
631 | + |
632 | + controls.on(controls.EVT_FULLSCREEN, function(ev) { |
633 | + triggered = true; |
634 | + }); |
635 | + |
636 | + var toggle = container.one('.fullscreen'); |
637 | + toggle.simulate('click'); |
638 | + triggered.should.eql(true); |
639 | + }); |
640 | + |
641 | + it('should fire a sidebar event when expand clicked', function() { |
642 | + var triggered = false; |
643 | + controls = new ViewmodeControls(); |
644 | + controls.render(); |
645 | + |
646 | + controls.on(controls.EVT_SIDEBAR, function(ev) { |
647 | + triggered = true; |
648 | + }); |
649 | + |
650 | + var toggle = container.one('.sidebar'); |
651 | + toggle.simulate('click'); |
652 | + triggered.should.eql(true); |
653 | + }); |
654 | + |
655 | + it('should fire a toggle viewable event when icon clicked', function() { |
656 | + var triggered = false; |
657 | + controls = new ViewmodeControls(); |
658 | + controls.render(); |
659 | + |
660 | + controls.on(controls.EVT_TOGGLE_VIEWABLE, function(ev) { |
661 | + triggered = true; |
662 | + }); |
663 | + |
664 | + // The toggle button is a delegate, so verify it works for a node inserted |
665 | + // after the instance of the widget is created. |
666 | + container.one('#content').append(Y.Node.create('<a class="bws-icon"/>')); |
667 | + var toggle = container.one('.bws-icon'); |
668 | + |
669 | + toggle.simulate('click'); |
670 | + triggered.should.eql(true); |
671 | + }); |
672 | +}); |
Reviewers: mp+172631_ code.launchpad. net,
Message:
Please take a look.
Description:
Break up the search widget to work with updated UX
- Split up the viewmode controls from the search widget itself.
- Update the viewmode controls widget to handle distinct
fullscreen/sidebar events vs a toggle event
- Update the tests to work with both widgets properly.
This branch does not update the minimized search to work correctly in
the grand scheme of things yet.
https:/ /code.launchpad .net/~rharding/ juju-gui/ new-controls/ +merge/ 172631
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/10877043/
Affected files: debug.js browser/ templates/ browser_ charm.handlebar s browser/ views/view. js browser- search. handlebars charm-token. handlebars topology/ importexport. js topology/ service. js charm-search. js charm-token. js viewmode- controls. js stylesheet. less browsercharm. json related. json browser_ app.js browser_ charm_details. js browser_ search_ widget. js charm_token. js charm_token_ drag_and_ drop.js viewmode_ controls_ widget. js
A [revision details]
M app/index.html
M app/modules-
M app/subapps/
M app/subapps/
M app/templates/
M app/templates/
M app/views/
M app/views/
M app/widgets/
M app/widgets/
A app/widgets/
M lib/views/
M test/data/
M test/data/
M test/index.html
M test/test_
M test/test_
M test/test_
M test/test_
M test/test_
M test/test_model.js
A test/test_