Merge lp:~gary/juju-gui/bug1204331 into lp:juju-gui/experimental

Proposed by Gary Poster
Status: Merged
Merged at revision: 893
Proposed branch: lp:~gary/juju-gui/bug1204331
Merge into: lp:juju-gui/experimental
Diff against target: 208 lines (+64/-11)
10 files modified
app/index.html (+2/-2)
app/models/charm.js (+4/-1)
app/store/endpoints.js (+2/-0)
app/templates/ghost-config-wrapper.handlebars (+2/-0)
app/views/charm-panel.js (+2/-1)
app/views/environment.js (+2/-1)
app/views/ghost-inspector.js (+7/-3)
app/views/inspector.js (+6/-3)
app/views/utils.js (+12/-0)
test/test_endpoints.js (+25/-0)
To merge this branch: bzr merge lp:~gary/juju-gui/bug1204331
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+176830@code.launchpad.net

Description of the change

Fix subordinate behavior in Juju Core

The biggest change here is that we update service data with the charm subordinate flag, because juju core does not include that information in the service. This includes a test.

Other changes here are fly-by.
- The yui3-skin-sam class on the body was causing issues by adding styles unnecessarily. I put it on the subapp-browser, where it is sufficient.
- The sandbox sends is_subordinate, not subordinate, for charms. I'm not sure if that is correct, but for now I changed charm.js to handle it. I'd welcome opinions on pushing this back down into the pyjuju sandbox, where I could test it. I'm kind of inclined to do that, actually, but I want to get this branch proposed.
- I made a few changes to the inspector code to handle subordinates a bit better, particularly in the ghost inspector. the ghost inspector has no tests at all, and we have a card for adding them, so I did not try to tack that effort on to this branch.
- I made a small tweak to charm-panel.js so that new services start looking like subordinates immediately.
- I added a small hack that came in handy to track down behavior in a handlebars template. Just add {{debugger}} in the template and you will have a breakpoint there. handy. hopefully not too dangerous! We definitely don't want to check in a template that uses this, and the linter won't check our template code...

https://codereview.appspot.com/11804043/

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (10.0 KiB)

Reviewers: mp+176830_code.launchpad.net,

Message:
Please take a look.

Description:
Fix subordinate behavior in Juju Core

The biggest change here is that we update service data with the charm
subordinate flag, because juju core does not include that information in
the service. This includes a test.

Other changes here are fly-by.
- The yui3-skin-sam class on the body was causing issues by adding
styles unnecessarily. I put it on the subapp-browser, where it is
sufficient.
- The sandbox sends is_subordinate, not subordinate, for charms. I'm
not sure if that is correct, but for now I changed charm.js to handle
it. I'd welcome opinions on pushing this back down into the pyjuju
sandbox, where I could test it. I'm kind of inclined to do that,
actually, but I want to get this branch proposed.
- I made a few changes to the inspector code to handle subordinates a
bit better, particularly in the ghost inspector. the ghost inspector
has no tests at all, and we have a card for adding them, so I did not
try to tack that effort on to this branch.
- I made a small tweak to charm-panel.js so that new services start
looking like subordinates immediately.
- I added a small hack that came in handy to track down behavior in a
handlebars template. Just add {{debugger}} in the template and you will
have a breakpoint there. handy. hopefully not too dangerous! We
definitely don't want to check in a template that uses this, and the
linter won't check our template code...

https://code.launchpad.net/~gary/juju-gui/bug1204331/+merge/176830

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M app/index.html
   M app/models/charm.js
   M app/store/endpoints.js
   M app/templates/ghost-config-wrapper.handlebars
   M app/views/charm-panel.js
   M app/views/environment.js
   M app/views/ghost-inspector.js
   M app/views/inspector.js
   M app/views/utils.js
   M test/test_endpoints.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: app/index.html
=== modified file 'app/index.html'
--- app/index.html 2013-07-24 14:30:06 +0000
+++ app/index.html 2013-07-24 21:46:12 +0000
@@ -67,7 +67,7 @@
      </script>
    </head>

- <body class="yui3-skin-sam">
+ <body>
        <!-- This <img> tag is here just to force early loading of the
background
          image so it displays more quickly. This makes a large improvement
to
          the way the app looks while loading on a slow connection. -->
@@ -164,7 +164,7 @@
            <div id="content">
                <div id="shortcut-help" style="display:none"></div>
                <div id="subapp-browser-min" style="display: none;"></div>
- <div id="subapp-browser"></div>
+ <div id="subapp-browser" class="yui3-skin-sam"></div>
                <div id="main">
                </div> <!-- /container -->
           ...

Revision history for this message
Brad Crittenden (bac) wrote :

LGTM for code. QA shows the dismiss [X] on the inspector has dropped
50px or so out of place. The issues you meant to solve are fixed.

https://codereview.appspot.com/11804043/diff/1/app/index.html
File app/index.html (right):

https://codereview.appspot.com/11804043/diff/1/app/index.html#newcode70
app/index.html:70: <body>
I'm glad you resolved this issue.

https://codereview.appspot.com/11804043/diff/1/app/models/charm.js
File app/models/charm.js (right):

https://codereview.appspot.com/11804043/diff/1/app/models/charm.js#newcode178
app/models/charm.js:178: // fakebackend and/or sandbox to send the
expected thing there.
Trivial but this should be an XXX with your name on it.

https://codereview.appspot.com/11804043/

Revision history for this message
Gary Poster (gary) wrote :

*** Submitted:

Fix subordinate behavior in Juju Core

The biggest change here is that we update service data with the charm
subordinate flag, because juju core does not include that information in
the service. This includes a test.

Other changes here are fly-by.
- The yui3-skin-sam class on the body was causing issues by adding
styles unnecessarily. I put it on the subapp-browser, where it is
sufficient.
- The sandbox sends is_subordinate, not subordinate, for charms. I'm
not sure if that is correct, but for now I changed charm.js to handle
it. I'd welcome opinions on pushing this back down into the pyjuju
sandbox, where I could test it. I'm kind of inclined to do that,
actually, but I want to get this branch proposed.
- I made a few changes to the inspector code to handle subordinates a
bit better, particularly in the ghost inspector. the ghost inspector
has no tests at all, and we have a card for adding them, so I did not
try to tack that effort on to this branch.
- I made a small tweak to charm-panel.js so that new services start
looking like subordinates immediately.
- I added a small hack that came in handy to track down behavior in a
handlebars template. Just add {{debugger}} in the template and you will
have a breakpoint there. handy. hopefully not too dangerous! We
definitely don't want to check in a template that uses this, and the
linter won't check our template code...

R=benji
CC=
https://codereview.appspot.com/11804043

https://codereview.appspot.com/11804043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/index.html'
2--- app/index.html 2013-07-24 14:30:06 +0000
3+++ app/index.html 2013-07-25 01:15:36 +0000
4@@ -67,7 +67,7 @@
5 </script>
6 </head>
7
8- <body class="yui3-skin-sam">
9+ <body>
10 <!-- This <img> tag is here just to force early loading of the background
11 image so it displays more quickly. This makes a large improvement to
12 the way the app looks while loading on a slow connection. -->
13@@ -164,7 +164,7 @@
14 <div id="content">
15 <div id="shortcut-help" style="display:none"></div>
16 <div id="subapp-browser-min" style="display: none;"></div>
17- <div id="subapp-browser"></div>
18+ <div id="subapp-browser" class="yui3-skin-sam"></div>
19 <div id="main">
20 </div> <!-- /container -->
21 </div>
22
23=== modified file 'app/models/charm.js'
24--- app/models/charm.js 2013-07-19 20:22:52 +0000
25+++ app/models/charm.js 2013-07-25 01:15:36 +0000
26@@ -173,7 +173,10 @@
27 parse: function() {
28 var data = Charm.superclass.parse.apply(this, arguments),
29 self = this;
30- data.is_subordinate = data.subordinate;
31+ // TODO: verify whether is_subordinate is ever passed by pyjuju or juju
32+ // core. If not, remove the "|| data.is_subordinate" and change in the
33+ // fakebackend and/or sandbox to send the expected thing there.
34+ data.is_subordinate = data.subordinate || data.is_subordinate;
35 Y.each(data, function(value, key) {
36 if (!value ||
37 !self.attrAdded(key) ||
38
39=== modified file 'app/store/endpoints.js'
40--- app/store/endpoints.js 2013-05-17 14:51:05 +0000
41+++ app/store/endpoints.js 2013-07-25 01:15:36 +0000
42@@ -141,6 +141,8 @@
43
44 servicePromise.then(
45 function(data) {
46+ data.service.set(
47+ 'subordinate', data.charm.get('is_subordinate'));
48 self.addServiceToEndpointsMap(
49 data.service.get('id'), data.charm);
50 },
51
52=== modified file 'app/templates/ghost-config-wrapper.handlebars'
53--- app/templates/ghost-config-wrapper.handlebars 2013-07-22 19:42:33 +0000
54+++ app/templates/ghost-config-wrapper.handlebars 2013-07-25 01:15:36 +0000
55@@ -6,6 +6,7 @@
56 <input value="Confirm" type="submit"
57 class="btn btn-primary deploy">
58 </div>
59+ {{#unless isSubordinate}}
60 <div class="charm-entry">
61 <div class="control-group">
62 <div class="well control-description">
63@@ -18,6 +19,7 @@
64 </div>
65 </div>
66 </div>
67+ {{/unless}}
68 </div>
69 <div class="viewlet-container"></div>
70 <div class="viewlet-manager-footer"></div>
71
72=== modified file 'app/views/charm-panel.js'
73--- app/views/charm-panel.js 2013-07-24 03:22:41 +0000
74+++ app/views/charm-panel.js 2013-07-25 01:15:36 +0000
75@@ -274,7 +274,8 @@
76 charm: charm.get('id'),
77 unit_count: 0, // No units yet.
78 loaded: false,
79- config: options
80+ config: options,
81+ subordinate: charm.get('is_subordinate')
82 });
83 // If we have been given coordinates at which the ghost should be
84 // created, respect them.
85
86=== modified file 'app/views/environment.js'
87--- app/views/environment.js 2013-07-22 15:15:51 +0000
88+++ app/views/environment.js 2013-07-25 01:15:36 +0000
89@@ -240,7 +240,8 @@
90 // the configuration for the view manager template
91 templateConfig: {
92 packageName: model.get('package_name'),
93- id: model.get('id')
94+ id: model.get('id'),
95+ isSubordinate: model.get('is_subordinate')
96 }
97 }
98 };
99
100=== modified file 'app/views/ghost-inspector.js'
101--- app/views/ghost-inspector.js 2013-07-20 00:08:41 +0000
102+++ app/views/ghost-inspector.js 2013-07-25 01:15:36 +0000
103@@ -94,9 +94,13 @@
104 deployCharm: function() {
105 var options = this.options,
106 container = options.container,
107+ model = options.model,
108 serviceName = container.one('input[name=service-name]').get('value'),
109- numUnits = parseInt(
110- container.one('input[name=number-units]').get('value'), 10),
111+ isSubordinate = model.get('is_subordinate'),
112+ numUnits = (
113+ isSubordinate ? 0 :
114+ parseInt(
115+ container.one('input[name=number-units]').get('value'), 10)),
116 config;
117
118 if (this.checkForExistingService(serviceName)) {
119@@ -118,7 +122,7 @@
120 }
121
122 options.env.deploy(
123- this.options.model.get('id'),
124+ model.get('id'),
125 serviceName, config, this.configFileContent,
126 numUnits, Y.bind(
127 this._deployCallbackHandler, this, serviceName, config));
128
129=== modified file 'app/views/inspector.js'
130--- app/views/inspector.js 2013-07-24 15:40:51 +0000
131+++ app/views/inspector.js 2013-07-25 01:15:36 +0000
132@@ -1066,9 +1066,12 @@
133 units: {
134 depends: ['aggregated_status'],
135 'update': function(node, value) {
136- // called under the databinding context
137- var statuses = this.viewlet.updateUnitList(value);
138- this.viewlet.generateAndBindUnitHeaders(node, statuses);
139+ // Called under the databinding context.
140+ // Subordinates may not have a value.
141+ if (value) {
142+ var statuses = this.viewlet.updateUnitList(value);
143+ this.viewlet.generateAndBindUnitHeaders(node, statuses);
144+ }
145 }
146 }
147 },
148
149=== modified file 'app/views/utils.js'
150--- app/views/utils.js 2013-07-24 14:30:06 +0000
151+++ app/views/utils.js 2013-07-25 01:15:36 +0000
152@@ -1427,6 +1427,18 @@
153 return options.fn(this);
154 }
155 });
156+
157+ /*
158+ * Dev tool: dump to debugger in template.
159+ *
160+ * {{debugger}}
161+ *
162+ */
163+ Y.Handlebars.registerHelper('debugger', function() {
164+ /*jshint debug:true */
165+ debugger;
166+ /*jshint debug:false */
167+ });
168 /*
169 * Extension for views to provide an apiFailure method.
170 *
171
172=== modified file 'test/test_endpoints.js'
173--- test/test_endpoints.js 2013-06-19 15:44:25 +0000
174+++ test/test_endpoints.js 2013-07-25 01:15:36 +0000
175@@ -393,8 +393,33 @@
176
177 var svc = app.db.services.getById(service_name);
178 svc.set('pending', false);
179+ destroyMe.push(svc);
180 });
181
182+ it('should update is_subordinate value when non-pending services are added',
183+ function(done) {
184+ var service_name = 'puppet';
185+ var charm_id = 'cs:precise/puppet-2';
186+ app.db.charms.add({id: charm_id, is_subordinate: true});
187+ var charm = app.db.charms.getById(charm_id);
188+ destroyMe.push(charm);
189+ charm.loaded = true;
190+ app.db.services.add({
191+ id: service_name,
192+ pending: true,
193+ loaded: true,
194+ charm: charm_id});
195+
196+ controller.on('endpointMapAdded', function() {
197+ assert.isTrue(svc.get('subordinate'));
198+ done();
199+ });
200+
201+ var svc = app.db.services.getById(service_name);
202+ svc.set('pending', false);
203+ destroyMe.push(svc);
204+ });
205+
206 it('should update endpoints map when a service\'s charm changes', function() {
207 var service_name = 'wordpress';
208 var charm_id = 'cs:precise/wordpress-2';

Subscribers

People subscribed via source and target branches