Merge lp:~bac/juju-gui/fix-dnd-bundles-wrt-id into lp:juju-gui/experimental

Proposed by Brad Crittenden
Status: Merged
Merged at revision: 1207
Proposed branch: lp:~bac/juju-gui/fix-dnd-bundles-wrt-id
Merge into: lp:juju-gui/experimental
Diff against target: 114 lines (+29/-8)
4 files modified
app/views/topology/service.js (+1/-0)
app/widgets/token.js (+7/-1)
test/test_service_module.js (+6/-4)
test/utils.js (+15/-3)
To merge this branch: bzr merge lp:~bac/juju-gui/fix-dnd-bundles-wrt-id
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+196139@code.launchpad.net

Description of the change

Send bundle id when d'n'd from sidebar.

This path was initially missed. The Token had to be fixed to include the
ID in the drag data.

Note, for selfish reasons, test/utils.js loadFixtures was updated to retry on
failures. The reason for the occassional 404 in this function when run by
lbox is still unknown. Hopefully the dumb retry will help.

QA Instructions:

# Use juju-quickstart trunk
% cd projects/juju-quickstart
% bzr pull
% make
# Deploy on EC2
% juju switch ec2
% .venv/bin/python juju-quickstart --gui-charm-url cs:~juju-gui/precise/juju-gui-128
% juju set juju-gui "juju-gui-source=lp:~bac/juju-gui/fix-dnd-bundles-wrt-id"
# May want to wait a bit. Perhaps it isn't necessary.
% juju set juju-gui "charmworld-url=http://staging.jujucharms.com"

Find one of Jorge's bundles on http://staging.jujucharms.com.
(wordpress-simple is a fast one.) Look at the deployment counts.

In the GUI search for 'jorge', find the bundle from above, and *drag* it onto
the canvas. Have a light snack. When everything is green and happy, look at
the page again on staging and see that the count has increased by one. NOTE:
in my QA I didn't see the incremented values reflected immediately which is
really strange. A few minutes later they were updated.

https://codereview.appspot.com/29960045/

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :
Download full text (6.2 KiB)

Reviewers: mp+196139_code.launchpad.net,

Message:
Please take a look.

Description:
Send bundle id when d'n'd from sidebar.

This path was initially missed. The Token had to be fixed to include
the
ID in the drag data.

Note, for selfish reasons, test/utils.js loadFixtures was updated to
retry on
failures. The reason for the occassional 404 in this function when run
by
lbox is still unknown. Hopefully the dumb retry will help.

QA Instructions:

# Use juju-quickstart trunk
% cd projects/juju-quickstart
% bzr pull
% make
# Deploy on EC2
% juju switch ec2
% .venv/bin/python juju-quickstart --gui-charm-url
cs:~juju-gui/precise/juju-gui-128
% juju set juju-gui
"juju-gui-source=lp:~bac/juju-gui/fix-dnd-bundles-wrt-id"
# May want to wait a bit. Perhaps it isn't necessary.
% juju set juju-gui "charmworld-url=http://staging.jujucharms.com"

Find one of Jorge's bundles on http://staging.jujucharms.com.
(wordpress-simple is a fast one.) Look at the deployment counts.

In the GUI search for 'jorge', find the bundle from above, and *drag* it
onto
the canvas. Have a light snack. When everything is green and happy,
look at
the page again on staging and see that the count has increased by one.
NOTE:
in my QA I didn't see the incremented values reflected immediately which
is
really strange. A few minutes later they were updated.

https://code.launchpad.net/~bac/juju-gui/fix-dnd-bundles-wrt-id/+merge/196139

(do not edit description out of merge proposal)

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

Affected files (+31, -8 lines):
   A [revision details]
   M app/views/topology/service.js
   M app/widgets/token.js
   M test/test_service_module.js
   M test/utils.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_service_module.js
=== modified file 'test/test_service_module.js'
--- test/test_service_module.js 2013-11-19 17:00:32 +0000
+++ test/test_service_module.js 2013-11-21 12:18:26 +0000
@@ -316,7 +316,8 @@
              dataTransfer: {
                getData: function(name) {
                  return JSON.stringify({
- data: '{"basket_name": "foo", "data": "BUNDLE DATA"}',
+ data: '{"basket_name": "foo", "data": "BUNDLE DATA",' +
+ ' "id": "~jorge/basket/thing"}',
                    dataType: 'token-drag-and-drop',
                    iconSrc: src
                  });
@@ -330,8 +331,9 @@

      // mock out the Y.BundleHelpers call.
      var _deployBundle = juju.BundleHelpers.deployBundle;
- juju.BundleHelpers.deployBundle = function(deployerData, env, db) {
+ juju.BundleHelpers.deployBundle = function(deployerData, id, env, db) {
        assert.include(deployerData, 'BUNDLE DATA');
+ assert.equal(id, '~jorge/basket/thing');
        // Restore the deployBundle call for future tests.
        juju.BundleHelpers.deployBundle = _deployBundle;
        done();
@@ -353,11 +355,11 @...

Read more...

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

*** Submitted:

Send bundle id when d'n'd from sidebar.

This path was initially missed. The Token had to be fixed to include
the
ID in the drag data.

Note, for selfish reasons, test/utils.js loadFixtures was updated to
retry on
failures. The reason for the occassional 404 in this function when run
by
lbox is still unknown. Hopefully the dumb retry will help.

QA Instructions:

# Use juju-quickstart trunk
% cd projects/juju-quickstart
% bzr pull
% make
# Deploy on EC2
% juju switch ec2
% .venv/bin/python juju-quickstart --gui-charm-url
cs:~juju-gui/precise/juju-gui-128
% juju set juju-gui
"juju-gui-source=lp:~bac/juju-gui/fix-dnd-bundles-wrt-id"
# May want to wait a bit. Perhaps it isn't necessary.
% juju set juju-gui "charmworld-url=http://staging.jujucharms.com"

Find one of Jorge's bundles on http://staging.jujucharms.com.
(wordpress-simple is a fast one.) Look at the deployment counts.

In the GUI search for 'jorge', find the bundle from above, and *drag* it
onto
the canvas. Have a light snack. When everything is green and happy,
look at
the page again on staging and see that the count has increased by one.
NOTE:
in my QA I didn't see the incremented values reflected immediately which
is
really strange. A few minutes later they were updated.

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

https://codereview.appspot.com/29960045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/views/topology/service.js'
2--- app/views/topology/service.js 2013-11-19 16:54:54 +0000
3+++ app/views/topology/service.js 2013-11-21 15:20:57 +0000
4@@ -675,6 +675,7 @@
5 Y.JSON.stringify({
6 bundle: entityData.data
7 }),
8+ entityData.id,
9 env,
10 db
11 );
12
13=== modified file 'app/widgets/token.js'
14--- app/widgets/token.js 2013-10-31 19:01:36 +0000
15+++ app/widgets/token.js 2013-11-21 15:20:57 +0000
16@@ -48,15 +48,19 @@
17 // Extract the charm/bundle values from the jumble of widget
18 // cfg options.
19 var attributes;
20+ var type;
21 if (utils.determineEntityDataType(cfg) === 'charm') {
22 attributes = Y.Object.keys(Y.juju.models.Charm.ATTRS);
23 this.TEMPLATE = templates['charm-token'];
24+ type = 'charm';
25 } else {
26 attributes = Y.Object.keys(Y.juju.models.Bundle.ATTRS);
27 this.TEMPLATE = templates['bundle-token'];
28+ type = 'bundle';
29 }
30 // @property tokenData Contains the extracted information.
31 this.tokenData = Y.aggregate({}, cfg, false, attributes);
32+ this.tokenData.type = type;
33 },
34
35 /**
36@@ -137,7 +141,9 @@
37 var tokenData,
38 container = this.get('boundingBox');
39 // Adjust the ID to meet model expectations.
40- this.tokenData.id = this.tokenData.url;
41+ if (this.tokenData.type === 'charm') {
42+ this.tokenData.id = this.tokenData.url;
43+ }
44 // Since the browser's dataTransfer mechanism only accepts string values
45 // we have to JSON encode the data. This passed-in config includes
46 // charm/bundle attributes.
47
48=== modified file 'test/test_service_module.js'
49--- test/test_service_module.js 2013-11-19 17:00:32 +0000
50+++ test/test_service_module.js 2013-11-21 15:20:57 +0000
51@@ -316,7 +316,8 @@
52 dataTransfer: {
53 getData: function(name) {
54 return JSON.stringify({
55- data: '{"basket_name": "foo", "data": "BUNDLE DATA"}',
56+ data: '{"basket_name": "foo", "data": "BUNDLE DATA",' +
57+ ' "id": "~jorge/basket/thing"}',
58 dataType: 'token-drag-and-drop',
59 iconSrc: src
60 });
61@@ -330,8 +331,9 @@
62
63 // mock out the Y.BundleHelpers call.
64 var _deployBundle = juju.BundleHelpers.deployBundle;
65- juju.BundleHelpers.deployBundle = function(deployerData, env, db) {
66+ juju.BundleHelpers.deployBundle = function(deployerData, id, env, db) {
67 assert.include(deployerData, 'BUNDLE DATA');
68+ assert.equal(id, '~jorge/basket/thing');
69 // Restore the deployBundle call for future tests.
70 juju.BundleHelpers.deployBundle = _deployBundle;
71 done();
72@@ -353,11 +355,11 @@
73 };
74
75 // mock out the Y.BundleHelpers call.
76- var _deployBundle = juju.BundleHelpers.deployBundleFiles;
77+ var _deployBundleFiles = juju.BundleHelpers.deployBundleFiles;
78 juju.BundleHelpers.deployBundleFiles = function(files, env, db) {
79 assert.deepEqual(files, [1]);
80 // Restore the deployBundleFiles call for future tests.
81- juju.BundleHelpers.deployBundleFiles = _deployBundle;
82+ juju.BundleHelpers.deployBundleFiles = _deployBundleFiles;
83 done();
84 };
85
86
87=== modified file 'test/utils.js'
88--- test/utils.js 2013-11-05 18:10:05 +0000
89+++ test/utils.js 2013-11-21 15:20:57 +0000
90@@ -101,9 +101,21 @@
91 * @return {Object} fixture data resulting from call.
92 */
93 loadFixture: function(url, parseJson) {
94- var response = Y.io(url, {sync: true}).responseText;
95- if (parseJson) {
96- response = Y.JSON.parse(response);
97+ var tries = 3;
98+ var response;
99+ while (true) {
100+ try {
101+ response = Y.io(url, {sync: true}).responseText;
102+ if (parseJson) {
103+ response = Y.JSON.parse(response);
104+ }
105+ break;
106+ } catch (e) {
107+ tries -= 1;
108+ if (tries <= 0) {
109+ throw e;
110+ }
111+ }
112 }
113 return response;
114 },

Subscribers

People subscribed via source and target branches