Merge lp:~jcsackett/juju-gui/browse-will-not-open-from-minimized into lp:juju-gui/experimental

Proposed by j.c.sackett
Status: Merged
Merge reported by: j.c.sackett
Merged at revision: not available
Proposed branch: lp:~jcsackett/juju-gui/browse-will-not-open-from-minimized
Merge into: lp:juju-gui/experimental
Diff against target: 188 lines (+139/-2)
2 files modified
app/subapps/browser/views/minimized.js (+73/-2)
test/test_browser_app.js (+66/-0)
To merge this branch: bzr merge lp:~jcsackett/juju-gui/browse-will-not-open-from-minimized
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+181151@code.launchpad.net

Description of the change

Fixes the view nav for browse/build from minimized

-Adds viewmode controls to minimized
-Binds viewmode events into minimized
-Adds tests

https://codereview.appspot.com/13092044/

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Reviewers: mp+181151_code.launchpad.net,

Message:
Please take a look.

Description:
Fixes the view nav for browse/build from minimized

-Adds viewmode controls to minimized
-Binds viewmode events into minimized
-Adds tests

https://code.launchpad.net/~jcsackett/juju-gui/browse-will-not-open-from-minimized/+merge/181151

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/13092044/

Affected files:
   A [revision details]
   M app/subapps/browser/views/minimized.js
   M test/test_browser_app.js

Revision history for this message
Richard Harding (rharding) wrote :

LGTM with the test fixes to use done() vs the assert that might not get
hit based on the speed of the test run.

https://codereview.appspot.com/13092044/diff/1/test/test_browser_app.js
File test/test_browser_app.js (right):

https://codereview.appspot.com/13092044/diff/1/test/test_browser_app.js#newcode87
test/test_browser_app.js:87: it('can toggle back to oldviewmode via the
toggle', function() {
shouldn't these take done and then call it in the
view.on('viewNavigate')? Does this really assert anything or just pass
through? This is the same on all three tests.

https://codereview.appspot.com/13092044/

Revision history for this message
Jeff Pihach (hatch) wrote :

LGTM however I'm a little concerned about the duplication of code -
possibly create a follow-up to normalize this stuff?

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js
File app/subapps/browser/views/minimized.js (right):

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js#newcode52
app/subapps/browser/views/minimized.js:52: Binds the viewmode control
events to navigation.
This code appears to be duplicated in other parts of the application -
can it not be split out into a mixin and then mixed into all classes
which need it?

https://codereview.appspot.com/13092044/

Revision history for this message
Richard Harding (rharding) wrote :

LGTM with the test fixes to use done() vs the assert that might not get
hit based on the speed of the test run.

https://codereview.appspot.com/13092044/

Revision history for this message
j.c.sackett (jcsackett) wrote :

On 2013/08/20 20:44:46, jeff.pihach wrote:
> LGTM however I'm a little concerned about the duplication of code -
possibly
> create a follow-up to normalize this stuff?

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js
> File app/subapps/browser/views/minimized.js (right):

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js#newcode52
> app/subapps/browser/views/minimized.js:52: Binds the viewmode control
events to
> navigation.
> This code appears to be duplicated in other parts of the application -
can it
> not be split out into a mixin and then mixed into all classes which
need it?

I agree it should be deduped, but the best way to do that is actually to
just have minimized also use MainView; since MainView sets up all the
search stuff, this should probably be done when we do the card "Make
search bar stay when sidebar is minimized". I'll add a comment to that
effect.

https://codereview.appspot.com/13092044/

971. By j.c.sackett

Test changes from review.

972. By j.c.sackett

Comment about code duplication and future cleanup.

Revision history for this message
Richard Harding (rharding) wrote :

On 2013/08/21 12:57:03, j.c.sackett wrote:
> On 2013/08/20 20:44:46, jeff.pihach wrote:
> > LGTM however I'm a little concerned about the duplication of code -
possibly
> > create a follow-up to normalize this stuff?
> >
> >

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js
> > File app/subapps/browser/views/minimized.js (right):
> >
> >

https://codereview.appspot.com/13092044/diff/1/app/subapps/browser/views/minimized.js#newcode52
> > app/subapps/browser/views/minimized.js:52: Binds the viewmode
control events
> to
> > navigation.
> > This code appears to be duplicated in other parts of the application
- can it
> > not be split out into a mixin and then mixed into all classes which
need it?

> I agree it should be deduped, but the best way to do that is actually
to just
> have minimized also use MainView; since MainView sets up all the
search stuff,
> this should probably be done when we do the card "Make search bar stay
when
> sidebar is minimized". I'll add a comment to that effect.

I was wondering if the viewmode-controls widget module could provide a
view extension that could be used to provide the setup/bind event
helpers for Views to use? I thought we had done this with another module
before.

https://codereview.appspot.com/13092044/

973. By j.c.sackett

Merged trunk.

Revision history for this message
j.c.sackett (jcsackett) wrote :

*** Submitted:

Fixes the view nav for browse/build from minimized

-Adds viewmode controls to minimized
-Binds viewmode events into minimized
-Adds tests

R=rharding
CC=
https://codereview.appspot.com/13092044

https://codereview.appspot.com/13092044/

Revision history for this message
j.c.sackett (jcsackett) wrote :

*** Submitted:

Fixes the view nav for browse/build from minimized

-Adds viewmode controls to minimized
-Binds viewmode events into minimized
-Adds tests

R=rharding
CC=
https://codereview.appspot.com/13092044

https://codereview.appspot.com/13092044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/subapps/browser/views/minimized.js'
--- app/subapps/browser/views/minimized.js 2013-08-02 15:34:18 +0000
+++ app/subapps/browser/views/minimized.js 2013-08-21 14:26:55 +0000
@@ -30,6 +30,11 @@
30 var ns = Y.namespace('juju.browser.views'),30 var ns = Y.namespace('juju.browser.views'),
31 views = Y.namespace('juju.views');31 views = Y.namespace('juju.views');
3232
33 // XXX jcsackett Aug 21 2013 The minimized view currently dupes a bunch of
34 // code from the Mainview. We can't just use mainview here b/c mainview
35 // expects search stuff to exist, which is only true for the sidebar and
36 // fullscreen views. When we add the search bar to always be present, we
37 // should remove this duplication.
33 /**38 /**
34 * The minimized state view.39 * The minimized state view.
35 *40 *
@@ -37,7 +42,9 @@
37 * @extends {Y.View}42 * @extends {Y.View}
38 *43 *
39 */44 */
40 ns.MinimizedView = Y.Base.create('browser-view-minimized', Y.View, [], {45 ns.MinimizedView = Y.Base.create('browser-view-minimized', Y.View, [
46 Y.Event.EventTracker
47 ], {
41 template: views.Templates.minimized,48 template: views.Templates.minimized,
4249
43 events: {50 events: {
@@ -47,6 +54,62 @@
47 },54 },
4855
49 /**56 /**
57 Binds the viewmode control events to navigation.
58
59 @method _bindViewmodeControls
60 */
61 _bindViewmodeControls: function() {
62 var container = this.get('container');
63 this.addEvent(
64 this.controls.on(
65 this.controls.EVT_TOGGLE_VIEWABLE, this._toggleViewState, this)
66 );
67
68 this.addEvent(
69 this.controls.on(
70 this.controls.EVT_FULLSCREEN, this._goFullscreen, this)
71 );
72 this.addEvent(
73 this.controls.on(
74 this.controls.EVT_SIDEBAR, this._goSidebar, this)
75 );
76 },
77
78 /**
79 Upon clicking the browser icon make sure we re-route to the
80 new form of the UX.
81
82 @method _goFullscreen
83 @param {Event} ev the click event handler on the button.
84
85 */
86 _goFullscreen: function(ev) {
87 ev.halt();
88 this.fire('viewNavigate', {
89 change: {
90 viewmode: 'fullscreen'
91 }
92 });
93 },
94
95 /**
96 Upon clicking the build icon make sure we re-route to the
97 new form of the UX.
98
99 @method _goSidebar
100 @param {Event} ev the click event handler on the button.
101
102 */
103 _goSidebar: function(ev) {
104 ev.halt();
105 this.fire('viewNavigate', {
106 change: {
107 viewmode: 'sidebar'
108 }
109 });
110 },
111
112 /**
50 * Toggle the visibility of the browser. Bound to nav controls in the113 * Toggle the visibility of the browser. Bound to nav controls in the
51 * view, however this will be expanded to be controlled from the new114 * view, however this will be expanded to be controlled from the new
52 * constant nav menu outside of the view once it's completed.115 * constant nav menu outside of the view once it's completed.
@@ -88,6 +151,13 @@
88 var tpl = this.template(),151 var tpl = this.template(),
89 tplNode = Y.Node.create(tpl);152 tplNode = Y.Node.create(tpl);
90 this.get('container').setHTML(tplNode);153 this.get('container').setHTML(tplNode);
154 // Make sure the controls starts out setting the correct active state
155 // based on the current viewmode for our View.
156 this.controls = new Y.juju.widgets.ViewmodeControls({
157 currentViewmode: this.get('oldViewMode')
158 });
159 this.controls.render();
160 this._bindViewmodeControls();
91 }161 }
92162
93 }, {163 }, {
@@ -116,6 +186,7 @@
116 'base',186 'base',
117 'juju-templates',187 'juju-templates',
118 'juju-views',188 'juju-views',
119 'view'189 'view',
190 'viewmode-controls'
120 ]191 ]
121});192});
122193
=== modified file 'test/test_browser_app.js'
--- test/test_browser_app.js 2013-08-19 17:15:16 +0000
+++ test/test_browser_app.js 2013-08-21 14:26:55 +0000
@@ -33,6 +33,72 @@
33 };33 };
3434
35 (function() {35 (function() {
36 describe('browser minimized view', function() {
37 var browser, container, Minimized, view, views, Y;
38
39 before(function(done) {
40 Y = YUI(GlobalConfig).use(
41 'juju-views',
42 'juju-browser',
43 'juju-tests-utils',
44 'subapp-browser-minimized', function(Y) {
45 browser = Y.namespace('juju.browser');
46 views = Y.namespace('juju.browser.views');
47 Minimized = views.MinimizedView;
48 done();
49 });
50 });
51
52 beforeEach(function() {
53 container = Y.namespace('juju-tests.utils').makeContainer('container');
54 addBrowserContainer(Y, container);
55 // Mock out a dummy location for the Store used in view instances.
56 window.juju_config = {
57 charmworldURL: 'http://localhost'
58 };
59
60 });
61
62 afterEach(function() {
63 view.destroy();
64 Y.one('#subapp-browser').remove(true);
65 delete window.juju_config;
66 container.remove(true);
67 });
68
69 it('can route to fullscreen', function(done) {
70 view = new Minimized();
71 view.render();
72 view.on('viewNavigate', function(ev) {
73 assert.equal(ev.change.viewmode, 'fullscreen');
74 done();
75 });
76 view.controls._goFullscreen({halt: function() {} });
77 });
78
79 it('can route to sidebar via view controls', function(done) {
80 view = new Minimized();
81 view.render();
82 view.on('viewNavigate', function(ev) {
83 assert.equal(ev.change.viewmode, 'sidebar');
84 done();
85 });
86 view.controls._goSidebar({halt: function() {} });
87 });
88
89 it('can toggle back to oldviewmode via the toggle', function(done) {
90 view = new Minimized({oldViewmode: 'sidebar'});
91 view.render();
92 view.on('viewNavigate', function(ev) {
93 assert.equal(ev.change.viewmode, 'sidebar');
94 done();
95 });
96 view.controls._toggleViewable({halt: function() {} });
97 });
98 });
99 })();
100
101 (function() {
36 describe('browser fullscreen view', function() {102 describe('browser fullscreen view', function() {
37 var browser, container, FullScreen, view, views, Y;103 var browser, container, FullScreen, view, views, Y;
38104

Subscribers

People subscribed via source and target branches