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
1=== modified file 'app/subapps/browser/views/minimized.js'
2--- app/subapps/browser/views/minimized.js 2013-08-02 15:34:18 +0000
3+++ app/subapps/browser/views/minimized.js 2013-08-21 14:26:55 +0000
4@@ -30,6 +30,11 @@
5 var ns = Y.namespace('juju.browser.views'),
6 views = Y.namespace('juju.views');
7
8+ // XXX jcsackett Aug 21 2013 The minimized view currently dupes a bunch of
9+ // code from the Mainview. We can't just use mainview here b/c mainview
10+ // expects search stuff to exist, which is only true for the sidebar and
11+ // fullscreen views. When we add the search bar to always be present, we
12+ // should remove this duplication.
13 /**
14 * The minimized state view.
15 *
16@@ -37,7 +42,9 @@
17 * @extends {Y.View}
18 *
19 */
20- ns.MinimizedView = Y.Base.create('browser-view-minimized', Y.View, [], {
21+ ns.MinimizedView = Y.Base.create('browser-view-minimized', Y.View, [
22+ Y.Event.EventTracker
23+ ], {
24 template: views.Templates.minimized,
25
26 events: {
27@@ -47,6 +54,62 @@
28 },
29
30 /**
31+ Binds the viewmode control events to navigation.
32+
33+ @method _bindViewmodeControls
34+ */
35+ _bindViewmodeControls: function() {
36+ var container = this.get('container');
37+ this.addEvent(
38+ this.controls.on(
39+ this.controls.EVT_TOGGLE_VIEWABLE, this._toggleViewState, this)
40+ );
41+
42+ this.addEvent(
43+ this.controls.on(
44+ this.controls.EVT_FULLSCREEN, this._goFullscreen, this)
45+ );
46+ this.addEvent(
47+ this.controls.on(
48+ this.controls.EVT_SIDEBAR, this._goSidebar, this)
49+ );
50+ },
51+
52+ /**
53+ Upon clicking the browser icon make sure we re-route to the
54+ new form of the UX.
55+
56+ @method _goFullscreen
57+ @param {Event} ev the click event handler on the button.
58+
59+ */
60+ _goFullscreen: function(ev) {
61+ ev.halt();
62+ this.fire('viewNavigate', {
63+ change: {
64+ viewmode: 'fullscreen'
65+ }
66+ });
67+ },
68+
69+ /**
70+ Upon clicking the build icon make sure we re-route to the
71+ new form of the UX.
72+
73+ @method _goSidebar
74+ @param {Event} ev the click event handler on the button.
75+
76+ */
77+ _goSidebar: function(ev) {
78+ ev.halt();
79+ this.fire('viewNavigate', {
80+ change: {
81+ viewmode: 'sidebar'
82+ }
83+ });
84+ },
85+
86+ /**
87 * Toggle the visibility of the browser. Bound to nav controls in the
88 * view, however this will be expanded to be controlled from the new
89 * constant nav menu outside of the view once it's completed.
90@@ -88,6 +151,13 @@
91 var tpl = this.template(),
92 tplNode = Y.Node.create(tpl);
93 this.get('container').setHTML(tplNode);
94+ // Make sure the controls starts out setting the correct active state
95+ // based on the current viewmode for our View.
96+ this.controls = new Y.juju.widgets.ViewmodeControls({
97+ currentViewmode: this.get('oldViewMode')
98+ });
99+ this.controls.render();
100+ this._bindViewmodeControls();
101 }
102
103 }, {
104@@ -116,6 +186,7 @@
105 'base',
106 'juju-templates',
107 'juju-views',
108- 'view'
109+ 'view',
110+ 'viewmode-controls'
111 ]
112 });
113
114=== modified file 'test/test_browser_app.js'
115--- test/test_browser_app.js 2013-08-19 17:15:16 +0000
116+++ test/test_browser_app.js 2013-08-21 14:26:55 +0000
117@@ -33,6 +33,72 @@
118 };
119
120 (function() {
121+ describe('browser minimized view', function() {
122+ var browser, container, Minimized, view, views, Y;
123+
124+ before(function(done) {
125+ Y = YUI(GlobalConfig).use(
126+ 'juju-views',
127+ 'juju-browser',
128+ 'juju-tests-utils',
129+ 'subapp-browser-minimized', function(Y) {
130+ browser = Y.namespace('juju.browser');
131+ views = Y.namespace('juju.browser.views');
132+ Minimized = views.MinimizedView;
133+ done();
134+ });
135+ });
136+
137+ beforeEach(function() {
138+ container = Y.namespace('juju-tests.utils').makeContainer('container');
139+ addBrowserContainer(Y, container);
140+ // Mock out a dummy location for the Store used in view instances.
141+ window.juju_config = {
142+ charmworldURL: 'http://localhost'
143+ };
144+
145+ });
146+
147+ afterEach(function() {
148+ view.destroy();
149+ Y.one('#subapp-browser').remove(true);
150+ delete window.juju_config;
151+ container.remove(true);
152+ });
153+
154+ it('can route to fullscreen', function(done) {
155+ view = new Minimized();
156+ view.render();
157+ view.on('viewNavigate', function(ev) {
158+ assert.equal(ev.change.viewmode, 'fullscreen');
159+ done();
160+ });
161+ view.controls._goFullscreen({halt: function() {} });
162+ });
163+
164+ it('can route to sidebar via view controls', function(done) {
165+ view = new Minimized();
166+ view.render();
167+ view.on('viewNavigate', function(ev) {
168+ assert.equal(ev.change.viewmode, 'sidebar');
169+ done();
170+ });
171+ view.controls._goSidebar({halt: function() {} });
172+ });
173+
174+ it('can toggle back to oldviewmode via the toggle', function(done) {
175+ view = new Minimized({oldViewmode: 'sidebar'});
176+ view.render();
177+ view.on('viewNavigate', function(ev) {
178+ assert.equal(ev.change.viewmode, 'sidebar');
179+ done();
180+ });
181+ view.controls._toggleViewable({halt: function() {} });
182+ });
183+ });
184+ })();
185+
186+ (function() {
187 describe('browser fullscreen view', function() {
188 var browser, container, FullScreen, view, views, Y;
189

Subscribers

People subscribed via source and target branches