Merge lp:~jcsackett/juju-gui/abstract-default-viewmode into lp:juju-gui/experimental

Proposed by j.c.sackett
Status: Merged
Merged at revision: 795
Proposed branch: lp:~jcsackett/juju-gui/abstract-default-viewmode
Merge into: lp:juju-gui/experimental
Diff against target: 175 lines (+47/-19)
2 files modified
app/subapps/browser/browser.js (+26/-12)
test/test_browser_app.js (+21/-7)
To merge this branch: bzr merge lp:~jcsackett/juju-gui/abstract-default-viewmode
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+172560@code.launchpad.net

Description of the change

Changes browser subapp default to be configurable

Rather than using sidebar, the browser subapp has a default viewmode as an attr.
Where sidebar was used before, this attr is instead used. You can qa it by
setting the default for the attr to fullscreen. For now at least, the default
for the attr remains "sidebar".

https://codereview.appspot.com/10870043/

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

Reviewers: mp+172560_code.launchpad.net,

Message:
Please take a look.

Description:
Changes browser subapp default to be configurable

Rather than using sidebar, the browser subapp has a default viewmode as
an attr.
Where sidebar was used before, this attr is instead used. You can qa it
by
setting the default for the attr to fullscreen. For now at least, the
default
for the attr remains "sidebar".

https://code.launchpad.net/~jcsackett/juju-gui/abstract-default-viewmode/+merge/172560

(do not edit description out of merge proposal)

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

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

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: test/test_browser_app.js
=== modified file 'test/test_browser_app.js'
--- test/test_browser_app.js 2013-06-27 17:40:21 +0000
+++ test/test_browser_app.js 2013-07-02 13:25:43 +0000
@@ -242,29 +242,43 @@
        });
      });

- it('* route set sidebar by default', function() {
- app = new browser.Browser();
- // Stub out the sidebar so we don't render anything.
+ it('* route uses the default viewmode', function() {
+ app = new browser.Browser({default_viewmode: 'sidebar'});
        app.sidebar = function() {};
        var req = {
          path: '/'
        };

- app.routeSidebarDefault(req, null, next);
+ app.routeDefault(req, null, next);
        // The viewmode should be populated now to the default.
        assert.equal(req.params.viewmode, 'sidebar');
+
+ app = new browser.Browser({default_viewmode: 'fullscreen'});
+ app.fullscreen = function() {};
+ req = {
+ path: '/'
+ };
+ app.routeDefault(req, null, next);
+ assert.equal(req.params.viewmode, 'fullscreen');
      });

- it('prevents * route from doing more than sidebar by default',
function() {
- app = new browser.Browser();
+ it('prevents * route from doing more than the default', function() {
+ app = new browser.Browser({default_viewmode: 'sidebar'});
        var req = {
          path: '/sidebar'
        };

- app.routeSidebarDefault(req, null, next);
+ app.routeDefault(req, null, next);
        // The viewmode is ignored. This path isn't meant for this route
        // callable to deal with at all.
        assert.equal(req.params, undefined);
+
+ app = new browser.Browser({default_viewmode: 'fullscreen'});
+ req = {
+ path: '/fullscreen'
+ };
+ app.routeDefault(req, null, next);
+ assert.equal(req.params, undefined);
      });

      it('/charm/id routes to a sidebar view correcetly', function() {

Index: app/subapps/browser/browser.js
=== modified file 'app/subapps/browser/browser.js'
--- app/subapps/browser/browser.js 2013-06-27 18:47:57 +0000
+++ app/subapps/browser/browser.js 2013-07-01 19:04:02 +0000
@@ -81,8 +81,9 @@

        th...

Read more...

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

LGTM with the change to the var name to defaultViewmode.

I'd prefer to see this along with the introduction of the config param
so that qa'ing it could be done with a change to the config file vs the
actual View's default ATTR value.

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

https://codereview.appspot.com/10870043/diff/1/app/subapps/browser/browser.js#newcode964
app/subapps/browser/browser.js:964: default_viewmode: {
camelCase please

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

https://codereview.appspot.com/10870043/diff/1/test/test_browser_app.js#newcode266
test/test_browser_app.js:266: app = new
browser.Browser({default_viewmode: 'sidebar'});
you don't need to add this here as it's picking up the default value.
Removing it verifies the default value is correct.

https://codereview.appspot.com/10870043/

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

On 2013/07/02 13:55:48, rharding wrote:
> LGTM with the change to the var name to defaultViewmode.

> I'd prefer to see this along with the introduction of the config param
so that
> qa'ing it could be done with a change to the config file vs the actual
View's
> default ATTR value.

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

https://codereview.appspot.com/10870043/diff/1/app/subapps/browser/browser.js#newcode964
> app/subapps/browser/browser.js:964: default_viewmode: {
> camelCase please

Got it.

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

https://codereview.appspot.com/10870043/diff/1/test/test_browser_app.js#newcode266
> test/test_browser_app.js:266: app = new
browser.Browser({default_viewmode:
> 'sidebar'});
> you don't need to add this here as it's picking up the default value.
Removing
> it verifies the default value is correct.

I only passed it in so you can see the correlation between the set value
and the results of the test.

https://codereview.appspot.com/10870043/

789. By j.c.sackett

camelCase

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

LGTM'd thanks for this improvement!

As mentioned in IRC - next step being able to be set via the config.js
files.

https://codereview.appspot.com/10870043/diff/7001/test/test_browser_app.js
File test/test_browser_app.js (right):

https://codereview.appspot.com/10870043/diff/7001/test/test_browser_app.js#newcode245
test/test_browser_app.js:245: it('* route uses the default viewmode',
function() {
it('routes * by using the default viewmode' ...

PTDD (pedantic tdd) ;-)

https://codereview.appspot.com/10870043/

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

On 2013/07/02 15:13:15, jeff.pihach wrote:
> LGTM'd thanks for this improvement!

> As mentioned in IRC - next step being able to be set via the config.js
files.

https://codereview.appspot.com/10870043/diff/7001/test/test_browser_app.js
> File test/test_browser_app.js (right):

https://codereview.appspot.com/10870043/diff/7001/test/test_browser_app.js#newcode245
> test/test_browser_app.js:245: it('* route uses the default viewmode',
function()
> {
> it('routes * by using the default viewmode' ...

> PTDD (pedantic tdd) ;-)

I think that's probably pedantic bdd. :-P I've fixed it.

https://codereview.appspot.com/10870043/

790. By j.c.sackett

Merged colo:trunk

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

*** Submitted:

Changes browser subapp default to be configurable

Rather than using sidebar, the browser subapp has a default viewmode as
an attr.
Where sidebar was used before, this attr is instead used. You can qa it
by
setting the default for the attr to fullscreen. For now at least, the
default
for the attr remains "sidebar".

R=rharding, jeff.pihach
CC=
https://codereview.appspot.com/10870043

https://codereview.appspot.com/10870043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/subapps/browser/browser.js'
2--- app/subapps/browser/browser.js 2013-06-27 18:47:57 +0000
3+++ app/subapps/browser/browser.js 2013-07-03 16:37:36 +0000
4@@ -81,8 +81,9 @@
5
6 this._viewState = Y.merge(this._viewState, change);
7
8- if (this._viewState.viewmode !== 'sidebar' || this._viewState.search) {
9- // Sidebar is the default viewmode. There's no need to add it if we
10+ if (this._viewState.viewmode !== this.get('defaultViewmode') ||
11+ this._viewState.search) {
12+ //There's no need to add the default view if we
13 // don't need it. However it's currently required for search views to
14 // match our current routes.
15 urlParts.push(this._viewState.viewmode);
16@@ -701,27 +702,28 @@
17 },
18
19 /**
20- When there's no charm or viewmode default to a sidebar view for all
21+ When there's no charm or viewmode default to the default viewmode for all
22 pages.
23
24- @method routeSidebarDefault
25+ @method routeDefault
26 @param {Request} req current request object.
27 @param {Response} res current response object.
28 @param {function} next callable for the next route in the chain.
29
30 */
31- routeSidebarDefault: function(req, res, next) {
32+ routeDefault: function(req, res, next) {
33 // Check if there's any path. If there is, someone else will handle
34 // routing it. Just carry on.
35+ var viewmode = this.get('defaultViewmode');
36 if (req.path.replace(/\//, '') !== '') {
37 next();
38 return;
39 }
40
41 // For the * request there will be no req.params. Update it forcing
42- // sidebar default viewmode.
43+ // the default viewmode.
44 req.params = {
45- viewmode: 'sidebar'
46+ viewmode: viewmode
47 };
48
49 // Update the state for the rest of things to figure out what to do.
50@@ -732,7 +734,7 @@
51
52 // Don't bother routing if we're hidden.
53 if (!this.hidden) {
54- this.sidebar(req, res, next);
55+ this[viewmode](req, res, next);
56 } else {
57 // Let the next route go on.
58 next();
59@@ -755,6 +757,7 @@
60 */
61 routeDirectCharmId: function(req, res, next) {
62 // If we don't have a valid store we can't do any work here.
63+ var viewmode = this.get('defaultViewmode');
64 if (!this._hasValidStore()) {
65 return;
66 }
67@@ -775,7 +778,7 @@
68 // We've got a valid id. Setup the params for our view state.
69 req.params = {
70 id: id,
71- viewmode: 'sidebar'
72+ viewmode: viewmode
73 };
74 }
75
76@@ -787,7 +790,7 @@
77
78 // Don't bother routing if we're hidden.
79 if (!this.hidden) {
80- this.sidebar(req, res, next);
81+ this[viewmode](req, res, next);
82 } else {
83 // Let the next route go on.
84 next();
85@@ -809,7 +812,7 @@
86 }
87
88 if (!req.params.viewmode) {
89- req.params.viewmode = 'sidebar';
90+ req.params.viewmode = this.get('defaultViewmode');
91 }
92
93 // If the viewmode isn't found, it's not one of our urls. Carry on.
94@@ -923,7 +926,7 @@
95 value: [
96 // Show the sidebar on all places if its not manually shut off or
97 // turned into a fullscreen route.
98- { path: '*', callbacks: 'routeSidebarDefault'},
99+ { path: '*', callbacks: 'routeDefault'},
100 { path: '/*id/', callbacks: 'routeDirectCharmId'},
101 { path: '/:viewmode/', callbacks: 'routeView' },
102 { path: '/:viewmode/search/', callbacks: 'routeView' },
103@@ -952,6 +955,17 @@
104 deploy: {},
105
106 /**
107+ The default viewmode
108+
109+ @attribute defaultViewmode
110+ @default sidebar
111+ @type {String}
112+ */
113+ defaultViewmode: {
114+ value: 'sidebar'
115+ },
116+
117+ /**
118 @attribute minNode
119 @default Node
120 @type {Node}
121
122=== modified file 'test/test_browser_app.js'
123--- test/test_browser_app.js 2013-07-02 17:10:25 +0000
124+++ test/test_browser_app.js 2013-07-03 16:37:36 +0000
125@@ -255,29 +255,43 @@
126 });
127 });
128
129- it('* route set sidebar by default', function() {
130- app = new browser.Browser();
131- // Stub out the sidebar so we don't render anything.
132+ it('* route uses the default viewmode', function() {
133+ app = new browser.Browser({defaultViewmode: 'sidebar'});
134 app.sidebar = function() {};
135 var req = {
136 path: '/'
137 };
138
139- app.routeSidebarDefault(req, null, next);
140+ app.routeDefault(req, null, next);
141 // The viewmode should be populated now to the default.
142 assert.equal(req.params.viewmode, 'sidebar');
143+
144+ app = new browser.Browser({defaultViewmode: 'fullscreen'});
145+ app.fullscreen = function() {};
146+ req = {
147+ path: '/'
148+ };
149+ app.routeDefault(req, null, next);
150+ assert.equal(req.params.viewmode, 'fullscreen');
151 });
152
153- it('prevents * route from doing more than sidebar by default', function() {
154- app = new browser.Browser();
155+ it('prevents * route from doing more than the default', function() {
156+ app = new browser.Browser({defaultViewmode: 'sidebar'});
157 var req = {
158 path: '/sidebar'
159 };
160
161- app.routeSidebarDefault(req, null, next);
162+ app.routeDefault(req, null, next);
163 // The viewmode is ignored. This path isn't meant for this route
164 // callable to deal with at all.
165 assert.equal(req.params, undefined);
166+
167+ app = new browser.Browser({defaultViewmode: 'fullscreen'});
168+ req = {
169+ path: '/fullscreen'
170+ };
171+ app.routeDefault(req, null, next);
172+ assert.equal(req.params, undefined);
173 });
174
175 it('/charm/id routes to a sidebar view correcetly', function() {

Subscribers

People subscribed via source and target branches