Merge lp:~benji/juju-gui/stand-in-bundle-token into lp:juju-gui/experimental

Proposed by Benji York
Status: Merged
Merged at revision: 1087
Proposed branch: lp:~benji/juju-gui/stand-in-bundle-token
Merge into: lp:juju-gui/experimental
Diff against target: 111 lines (+47/-7)
3 files modified
app/templates/bundle-token.handlebars (+6/-0)
app/widgets/token.js (+13/-5)
test/test_token.js (+28/-2)
To merge this branch: bzr merge lp:~benji/juju-gui/stand-in-bundle-token
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+186589@code.launchpad.net

Description of the change

More renaming in preparation for bundle tokens.

This branch consists primarily of removing more "charm" from "charm token".
The only non-mechanical changes are in app/widgets/token.js.

https://codereview.appspot.com/13627053/

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

LGTM, thank you. I'll try QA now.

I can't help but wish that we had some more descriptive name for this
than "Token". Hopefully we don't confuse ourselves with some semantic
overlap in the future.

https://codereview.appspot.com/13627053/

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

On 2013/09/19 18:05:57, gary.poster wrote:
> LGTM, thank you. I'll try QA now.

> I can't help but wish that we had some more descriptive name for this
than
> "Token". Hopefully we don't confuse ourselves with some semantic
overlap in the
> future.

QA good. thanks!

https://codereview.appspot.com/13627053/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'app/templates/bundle-token.handlebars'
2--- app/templates/bundle-token.handlebars 1970-01-01 00:00:00 +0000
3+++ app/templates/bundle-token.handlebars 2013-09-25 14:55:25 +0000
4@@ -0,0 +1,6 @@
5+{{! The token class is used by the deploy method in
6+ test/test_charm_running.py. If you change this name, change the other
7+ one too! }}
8+<a href="/{{storeId}}" class="token {{size}}" data-charmid="{{storeId}}">
9+ This is a bundle token. Deal.
10+</a>
11
12=== modified file 'app/widgets/token.js'
13--- app/widgets/token.js 2013-09-24 19:58:07 +0000
14+++ app/widgets/token.js 2013-09-25 14:55:25 +0000
15@@ -29,6 +29,16 @@
16 */
17 YUI.add('browser-token', function(Y) {
18
19+ var determineTokenDataType = function(tokenData) {
20+ // It would be nice to restructure the token widget so that it takes
21+ // a model instead of a jumble of attributes. If we did so, this
22+ // would just be a type check over the class of the model.
23+ if (tokenData && 'basket_name' in tokenData) {
24+ return 'bundle';
25+ }
26+ return 'charm';
27+ };
28+
29 var ns = Y.namespace('juju.widgets.browser');
30 ns.EVENT_CHARM_ADD = 'charm-token-add'; // XXX Is this used?
31 ns.Token = Y.Base.create('Token', Y.Widget, [
32@@ -47,11 +57,10 @@
33 // Extract the charm/bundle values from the jumble of widget
34 // cfg options.
35 var attributes;
36- if (this.get('type') === 'charm') {
37+ if (determineTokenDataType(cfg) === 'charm') {
38 attributes = Y.Object.keys(Y.juju.models.Charm.ATTRS);
39 this.TEMPLATE = templates['charm-token'];
40 } else {
41- // XXX This doesn't actually work yet, but soon. (benji 2013-09-24)
42 attributes = Y.Object.keys(Y.juju.models.Bundle.ATTRS);
43 this.TEMPLATE = templates['bundle-token'];
44 }
45@@ -273,9 +282,7 @@
46 type: {
47 // The function name is quoted to keep the yuidoc linter happy.
48 'getter': function() {
49- // TODO When we wire in the bundle handling code this will be a
50- // non-constant value.
51- return 'charm';
52+ return determineTokenDataType(this.tokenData);
53 }
54 }
55
56@@ -288,6 +295,7 @@
57 'event-tracker',
58 'handlebars',
59 'juju-charm-models',
60+ 'juju-bundle-models',
61 'juju-templates',
62 'juju-view-utils',
63 'widget',
64
65=== modified file 'test/test_token.js'
66--- test/test_token.js 2013-09-24 16:41:26 +0000
67+++ test/test_token.js 2013-09-25 14:55:25 +0000
68@@ -19,7 +19,7 @@
69 'use strict';
70
71
72-describe('charm token', function() {
73+describe('charm/bundle token', function() {
74 var token_container, Token, cleanIconHelper, token, utils, Y;
75
76 before(function(done) {
77@@ -142,7 +142,33 @@
78 assert.equal(
79 token_container.one('img').getAttribute('src'),
80 'http://localhost.svg');
81-
82+ });
83+
84+ it('can report the kind of object it represents', function() {
85+ var charmToken = new Token({
86+ size: 'tiny',
87+ description: 'some description',
88+ mainCategory: 'app-servers',
89+ iconUrl: 'http://localhost.svg'
90+ });
91+
92+ var bundleToken = new Token({
93+ size: 'small',
94+ basket_name: 'BASKET-NAME'
95+ });
96+
97+ assert.equal(charmToken.get('type'), 'charm');
98+ assert.equal(bundleToken.get('type'), 'bundle');
99+ });
100+
101+ it('can render bundles', function() {
102+ var token = new Token({
103+ size: 'small',
104+ basket_name: 'BASKET-NAME'
105+ });
106+
107+ token.render(token_container);
108+ assert.match(token_container.getHTML(), /This is a bundle token./);
109 });
110
111 });

Subscribers

People subscribed via source and target branches