Merge lp:~rharding/juju-gui/qa-bundle-charms into lp:juju-gui/experimental

Proposed by Richard Harding
Status: Merged
Merged at revision: 1139
Proposed branch: lp:~rharding/juju-gui/qa-bundle-charms
Merge into: lp:juju-gui/experimental
Diff against target: 317 lines (+190/-43)
4 files modified
app/subapps/browser/views/bundle.js (+47/-0)
app/templates/bundle.handlebars (+27/-1)
lib/views/browser/charm-full.less (+55/-42)
test/test_bundle_details_view.js (+61/-0)
To merge this branch: bzr merge lp:~rharding/juju-gui/qa-bundle-charms
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+191649@code.launchpad.net

Description of the change

Added charm details to bundle

Browse to a charm and view the "Charms" tab. There is no direction for what
this page is supposed to contain yet so I've added tokens for each charm and
also display the config options and number of units.'

https://codereview.appspot.com/14654046/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Reviewers: mp+191649_code.launchpad.net,

Message:
Please take a look.

Description:
Added charm details to bundle

Browse to a charm and view the "Charms" tab. There is no direction for
what
this page is supposed to contain yet so I've added tokens for each charm
and
also display the config options and number of units.'

https://code.launchpad.net/~rharding/juju-gui/qa-bundle-charms/+merge/191649

(do not edit description out of merge proposal)

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

Affected files (+192, -43 lines):
   A [revision details]
   M app/subapps/browser/views/bundle.js
   M app/templates/bundle.handlebars
   M lib/views/browser/charm-full.less
   M test/test_bundle_details_view.js

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

LGTM, added test and cleanup. Original branch is from huw over at
https://codereview.appspot.com/14673044/

https://codereview.appspot.com/14654046/

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

*** Submitted:

Added charm details to bundle

Browse to a charm and view the "Charms" tab. There is no direction for
what
this page is supposed to contain yet so I've added tokens for each charm
and
also display the config options and number of units.'

R=
CC=
https://codereview.appspot.com/14654046

https://codereview.appspot.com/14654046/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/subapps/browser/views/bundle.js'
2--- app/subapps/browser/views/bundle.js 2013-10-11 22:48:51 +0000
3+++ app/subapps/browser/views/bundle.js 2013-10-17 14:16:02 +0000
4@@ -137,6 +137,26 @@
5 },
6
7 /**
8+ Render the list of charms in the bundle.
9+
10+ @method _renderCharmListing
11+
12+ */
13+ _renderCharmListing: function() {
14+ var attrs = this.get('entity').getAttrs();
15+ Y.Object.each(attrs.charm_metadata, function(charm, key) {
16+ var charmModel = new Y.juju.models.Charm(charm);
17+ charm = charmModel.getAttrs();
18+ charm.size = 'tiny';
19+ charm.isDraggable = false;
20+ var token = new widgets.browser.Token(charm);
21+ var node = Y.one('[data-config="' + key + '"]');
22+ token.render(node);
23+ this._cleanup.tokens.push(token);
24+ }, this);
25+ },
26+
27+ /**
28 Renders the bundle view template into the DOM.
29
30 @method _renderBundleView
31@@ -184,6 +204,7 @@
32 this.tabview.selectChild(2);
33 }
34 this._dispatchTabEvents(this.tabview);
35+ this._renderCharmListing();
36
37 this.set('rendered', true);
38 },
39@@ -211,6 +232,31 @@
40 },
41
42 /**
43+ Destroy things when the view is destroyed.
44+
45+ @method destructor
46+
47+ */
48+ destructor: function() {
49+ this._cleanup.tokens.forEach(function(token) {
50+ token.destroy();
51+ });
52+ },
53+
54+ /**
55+ Generic initializer method for the View.
56+
57+ @method initializer
58+ @param {Object} cfg the config object to create the View with.
59+
60+ */
61+ initializer: function(cfg) {
62+ this._cleanup = {
63+ tokens: []
64+ };
65+ },
66+
67+ /**
68 Renders the loading indicator into the DOM and then calls
69 the _prepareData method to fetch/parse the bundle data for
70 the real view rendering.
71@@ -244,6 +290,7 @@
72 }, '', {
73 requires: [
74 'browser-overlay-indicator',
75+ 'juju-charm-models',
76 'juju-view-utils',
77 'view',
78 'juju-env-fakebackend',
79
80=== modified file 'app/templates/bundle.handlebars'
81--- app/templates/bundle.handlebars 2013-10-10 04:44:18 +0000
82+++ app/templates/bundle.handlebars 2013-10-17 14:16:02 +0000
83@@ -119,7 +119,33 @@
84 </div>
85 </div>
86 <div id="bws-readme"></div>
87- <div id="bws-charms"></div>
88+ <div id="bws-charms">
89+ <div class="yui3-g">
90+ <div class="interfaces-heading yui3-u-1-2">
91+ <h3>Charm</h3>
92+ </div>
93+ <div class="interfaces-heading yui3-u-1-2">
94+ <h3>Config</h3>
95+ </div>
96+ </div>
97+ <ul class="interface-list">
98+ {{#arrayObject services}}
99+ <li class="interface-row yui3-g">
100+ <div class="yui3-u-1-2" data-config="{{ key }}"></div>
101+ <div class="yui3-u-1-2 charm-config">
102+ <ul>
103+ <li>Number of units: {{ value.num_units }}</li>
104+ {{#if value.config}}
105+ {{#arrayObject value.options}}
106+ <li>{{ key }}: {{ value }}</li>
107+ {{/arrayObject}}
108+ {{/if}}
109+ </ul>
110+ </div>
111+ </li>
112+ {{/arrayObject}}
113+ </ul>
114+ </div>
115 <div id="bws-code">
116 <p class="intro">
117 The source code of the bundle includes scripts, metadata,
118
119=== modified file 'lib/views/browser/charm-full.less'
120--- lib/views/browser/charm-full.less 2013-10-09 04:05:57 +0000
121+++ lib/views/browser/charm-full.less 2013-10-17 14:16:02 +0000
122@@ -124,6 +124,59 @@
123 margin-top: 9px;
124 margin-bottom: 26px;
125 }
126+ .interfaces-heading,
127+ .interface,
128+ .related {
129+ .border-box;
130+ padding: 0 20px;
131+ }
132+ .interfaces-heading {
133+ padding-top: 0;
134+ padding-bottom: 0;
135+ border-bottom: 1px solid @bws-border;
136+
137+ h3 {
138+ margin: 0;
139+ padding: 0;
140+ border: none;
141+ }
142+ }
143+ .interface-list {
144+ h4 {
145+ margin: 0;
146+ padding: 0;
147+ border: none;
148+ }
149+ .interface-row {
150+ border-bottom: 1px solid @bws-border;
151+
152+ .interface {
153+ padding-top: 10px;
154+ padding-bottom: 10px;
155+ font-size: 10.5pt;
156+ }
157+ .charm-config {
158+ .border-box;
159+ min-height: 87px;
160+ padding: 20px;
161+ border-left: 1px solid @bws-border;
162+
163+ li {
164+ margin-bottom: 5px;
165+ }
166+ }
167+ .yui3-token {
168+ width: 100%;
169+
170+ .title {
171+ max-width: 150px;
172+ }
173+ }
174+ &:last-child {
175+ border: none;
176+ }
177+ }
178+ }
179 #bws-features,
180 #bws-summary,
181 #bws-readme {
182@@ -135,46 +188,6 @@
183 padding-left: 2em;
184 }
185 }
186- #bws-related-charms {
187- .interfaces-heading,
188- .interface,
189- .related {
190- .border-box;
191- padding: 0 20px;
192- }
193- h4,
194- h3 {
195- margin: 0;
196- padding: 0;
197- border: none;
198- }
199- .interfaces-heading {
200- padding-top: 0;
201- padding-bottom: 15px;
202- border-bottom: 1px solid @bws-border;
203- }
204- .interface-list {
205- .interface-row {
206- border-bottom: 1px solid @bws-border;
207-
208- .interface {
209- padding-top: 10px;
210- padding-bottom: 10px;
211- font-size: 10.5pt;
212- }
213- .yui3-token {
214- width: 100%;
215-
216- .title {
217- max-width: 150px;
218- }
219- }
220- &:last-child {
221- border: none;
222- }
223- }
224- }
225- }
226 #bws-configuration {
227 dt {
228 margin: 20px 0 15px 0;
229@@ -246,7 +259,7 @@
230 padding: 17px 70px 16px 16px;
231
232 a {
233- padding-right: 5px;
234+ padding-right: 5px;
235 }
236 }
237 }
238@@ -326,7 +339,7 @@
239 }
240 span {
241 color: @bws-text;
242- text-decoration: underline;
243+ text-decoration: underline;
244 }
245 }
246 }
247
248=== modified file 'test/test_bundle_details_view.js'
249--- test/test_bundle_details_view.js 2013-10-11 22:48:51 +0000
250+++ test/test_bundle_details_view.js 2013-10-17 14:16:02 +0000
251@@ -237,5 +237,66 @@
252 view.render();
253 });
254
255+ it('renders the charm list tab properly', function(done) {
256+ view._parseData = function() {
257+ return new Y.Promise(function(resolve) { resolve(); });
258+ };
259+ view.set('entity', {
260+ getAttrs: function() {
261+ return {
262+ charm_metadata: {
263+ foo: {
264+ id: 'precise/foo-9',
265+ storeId: 'testid',
266+ name: 'foo'
267+ },
268+ bar: {
269+ id: 'precise/bar-10',
270+ storeId: 'testid',
271+ name: 'bar'
272+ }
273+ },
274+ files: [],
275+ data: {
276+ services: {
277+ foo: {
278+ annotations: {
279+ 'gui-x': '1',
280+ 'gui-y': '2'
281+ }
282+ },
283+ bar: {
284+ annotations: {
285+ 'gui-x': '3',
286+ 'gui-y': '4'
287+ }
288+ }
289+ }
290+ },
291+ services: {
292+ foo: {
293+ annotations: {
294+ 'gui-x': '1',
295+ 'gui-y': '2'
296+ }
297+ },
298+ bar: {
299+ annotations: {
300+ 'gui-x': '3',
301+ 'gui-y': '4'
302+ }
303+ }
304+ }
305+ };
306+ }});
307+ view.after('renderedChange', function(e) {
308+ var tab = container.one('#bws-charms');
309+ assert.equal(tab.all('.token').size(), 2);
310+ done();
311+ });
312+ view.render();
313+ });
314+
315+
316
317 });

Subscribers

People subscribed via source and target branches