This branch attempts to fix the referenced bug. I was unable to
duplicate the symptoms locally exactly, but duplicated them closely
enough that I am optimistic that these changes address the issue.
Regardless, they seem like reasonable changes.
I also fixed a couple of landscape issues I saw with newly created
services without annotations.
The aspect of this branch I wonder most if reviewers (particularly Ben)
will like is the change to the route url algorithm. If it's not clear
why I chose it, I'm happy to discuss my rationale and other options.
Affected files:
A [revision details]
M app/app.js
M app/assets/javascripts/ns-routing-app-extension.js
M app/views/charm.js
M app/views/landscape.js
M app/views/service.js
M app/views/utils.js
M test/test_app_hotkeys.js
M test/test_charm_view.js
M test/test_landscape.js
M test/test_routing.js
M test/test_service_view.js
Index: app/views/charm.js
=== modified file 'app/views/charm.js'
--- app/views/charm.js 2013-03-19 21:58:04 +0000
+++ app/views/charm.js 2013-04-11 19:46:11 +0000
@@ -97,7 +97,7 @@
// The deploy call generates an event chain leading to a call to
// `app.on_database_changed()`, which re-dispatches the current view.
// For this reason we need to redirect to the root page right now.
- this.fire('navigateTo', {url: '/'});
+ this.fire('navigateTo', {url: '/:gui:/'}); env.deploy(charmUrl, serviceName, config, Y.bind(this._deployCallback, this)
);
Index: test/test_service_view.js
=== modified file 'test/test_service_view.js'
--- test/test_service_view.js 2013-03-21 15:32:06 +0000
+++ test/test_service_view.js 2013-04-11 19:46:11 +0000
@@ -349,20 +349,23 @@ destroy.simulate('click');
var called = false; view.on('navigateTo', function(ev) {
- assert.equal('/', ev.url);
+ assert.equal('/:gui:/', ev.url);
called = true;
});
var callbacks = Y.Object.values(env._txn_callbacks); callbacks.length.should.equal(1);
- // Since we don't have an app to listen to this event and tell the
- // view to re-render, we need to do it ourselves.
- db.on('update', view.render, view);
+ var dbUpdated = false;
+ db.on('update', function() {
+ dbUpdated = true;
+ }); callbacks[0]({result: true});
var _ =
expect(db.services.getById(service.get('id'))).to.not.exist; db.relations.map(function(u) {return u.get('id');}) .should.eql(['relation-0000000001']);
// Catch show environment event. called.should.equal(true);
+ // The db should be updated.
+ dbUpdated.should.equal(true);
});
it('should send an expose RPC call when exposeService is invoked',
Reviewers: mp+158468_ code.launchpad. net,
Message:
Please take a look.
Description:
Fix bug 1167967 (hopefully)
This branch attempts to fix the referenced bug. I was unable to
duplicate the symptoms locally exactly, but duplicated them closely
enough that I am optimistic that these changes address the issue.
Regardless, they seem like reasonable changes.
I also fixed a couple of landscape issues I saw with newly created
services without annotations.
The aspect of this branch I wonder most if reviewers (particularly Ben)
will like is the change to the route url algorithm. If it's not clear
why I chose it, I'm happy to discuss my rationale and other options.
Thank you.
https:/ /code.launchpad .net/~gary/ juju-gui/ bug1167967/ +merge/ 158468
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/8680043/
Affected files: javascripts/ ns-routing- app-extension. js landscape. js service. js app_hotkeys. js charm_view. js landscape. js routing. js service_ view.js
A [revision details]
M app/app.js
M app/assets/
M app/views/charm.js
M app/views/
M app/views/
M app/views/utils.js
M test/test_
M test/test_
M test/test_
M test/test_
M test/test_
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/app.js
=== modified file 'app/app.js'
--- app/app.js 2013-04-09 20:50:46 +0000
+++ app/app.js 2013-04-11 19:46:11 +0000
@@ -184,7 +184,7 @@
- this.fire(
+ this.fire(
}, this);
Index: test/test_ app_hotkeys. js app_hotkeys. js' app_hotkeys. js 2013-04-08 18:23:28 +0000 app_hotkeys. js 2013-04-11 19:46:11 +0000 on('navigateTo' , function(ev) {
altEtriggere d = true;
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -50,7 +50,7 @@
it('should listen for alt-E events', function() {
var altEtriggered = false;
app.
- if (ev && ev.url === '/') {
+ if (ev && ev.url === '/:gui:/') {
}
// Avoid URL change performed by additional listeners.
Index: test/test_ charm_view. js charm_view. js' charm_view. js 2013-02-15 11:58:05 +0000 charm_view. js 2013-04-11 19:46:11 +0000
charmView. on('navigateTo' , function(e) { equal(' /:gui:/ ', e.url);
redirected = true; get('container' ).one(' #charm- deploy' );
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -88,7 +88,7 @@
env: env});
var redirected = false;
- assert.equal('/', e.url);
+ assert.
});
var deployInput = charmView.
Index: app/views/charm.js charm.js' database_ changed( )`, which re-dispatches the current view. 'navigateTo' , {url: '/'}); 'navigateTo' , {url: '/:gui:/'});
env.deploy( charmUrl, serviceName, config,
Y. bind(this. _deployCallback , this)
=== modified file 'app/views/
--- app/views/charm.js 2013-03-19 21:58:04 +0000
+++ app/views/charm.js 2013-04-11 19:46:11 +0000
@@ -97,7 +97,7 @@
// The deploy call generates an event chain leading to a call to
// `app.on_
// For this reason we need to redirect to the root page right now.
- this.fire(
+ this.fire(
);
Index: app/assets/ javascripts/ ns-routing- app-extension. js javascripts/ ns-routing- app-extension. js' javascripts/ ns-routing- app-extension. js 2013-03-21 15:32:06 javascripts/ ns-routing- app-extension. js 2013-04-11 19:46:11 keys(base) .sort() ;
Y.each( keys, function(ns) {
=== modified file 'app/assets/
--- app/assets/
+0000
+++ app/assets/
+0000
@@ -167,7 +167,9 @@
var keys = Y.Object.
url = slash(url);
- url += ':' + ns + ':' + base[ns];
+ if (base[ns] !== '/') {
+ url += ':' + ns + ':' + base[ns];
+ }
});
url = slash(url);
Index: test/test_ landscape. js landscape. js' landscape. js 2013-03-26 21:20:28 +0000 landscape. js 2013-04-11 19:46:11 +0000 one('.updates- control' ).getStyle( 'display' ).should. equal(' none'); one('.restart- control' ).getStyle( 'display' ).should. equal(' block') ;
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -158,6 +158,14 @@
node.
node.
+ // We handle missing annotations on a service. 'annotations' , {}); updateLandscape BottomBar( landscape, env, mysql, node, '.machine- control' ).getStyle( 'display' ).should. equal(' none'); annotations = {'landscape- computer' : '+unit:mysql-0'}; .update( );
+ mysql.set(
+ landscape.update();
+ views.utils.
+ 'service');
+ node.one(
+
+ // We handle normal unit annotations.
unit.
landscape
@@ -171,6 +179,13 @@ one('.updates- control' ).getStyle( 'display' ).should. equal(' none'); one('.restart- control' ).getStyle( 'display' ).should. equal(' none');
node.
node.
+ // We handle completely missing annotations on a unit. updateLandscape BottomBar( landscape, env, unit, node, '.machine- control' ).getStyle( 'display' ).should. equal(' none'); remove( );
+ delete unit.annotations;
+ landscape.update();
+ views.utils.
+ 'unit');
+ node.one(
+
node.
});
Index: app/views/ landscape. js landscape. js' landscape. js 2013-04-09 20:22:01 +0000 landscape. js 2013-04-11 19:46:11 +0000 tation) ; ns['landscape- computer' ]; ns['landscape- computer' ]);
console. warn('Unit missing the landscape-computer annotation!');
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -128,7 +128,8 @@
}
url += slash(modelAnno
} else if (model.name === 'serviceUnit') {
- modelAnnotation = model.annotatio
+ modelAnnotation = (
+ model.annotations && model.annotatio
if (!modelAnnotation) {
return undefined;
Index: test/test_ routing. js routing. js' routing. js 2013-04-08 18:23:28 +0000 routing. js 2013-04-11 19:46:11 +0000 precise/ mediawiki/ :inspector: /services/ mysql/' );
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -46,6 +46,12 @@
var u = router.url(match);
assert(u === '/charms/
+ // Root keys are implicit. strictEqual( u, '/'); strictEqual( u, '/:foo:/shazam/'); url({charmstore : '/', gamma: 'g', a: 'alpha', b: 'beta'}); :b:beta/ :gamma: g/');
+ u = router.url({foo: '/'});
+ assert.
+ u = router.url({foo: '/shazam', bar: '/'});
+ assert.
+
// Sorted keys.
u = router.
assert(u === '/:a:alpha/
Index: app/views/ service. js service. js' service. js 2013-04-04 07:22:16 +0000 service. js 2013-04-11 19:46:11 +0000
this. panel.hide( );
this. panel.destroy( ); 'navigateTo' , {url: '/'}); 'navigateTo' , {url: '/:gui:/'});
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -225,7 +225,8 @@
));
- this.fire(
+ this.fire(
+ db.fire('update');
}
}
};
Index: app/views/utils.js utils.js'
=== modified file 'app/views/
--- app/views/utils.js 2013-04-11 12:47:10 +0000
+++ app/views/utils.js 2013-04-11 19:46:11 +0000
@@ -422,20 +422,22 @@
if (envAnnotations ['landscape- url']) {
controls. show(); one('a' ).setAttribute( 'href', getLandscapeURL (model) ); 'landscape- security- upgrades' ]) { one('a' ).setAttribute( 'href', getLandscapeURL (model, 'security')); 'landscape- needs-reboot' ]) { one('a' ).setAttribute( 'href', getLandscapeURL (model, 'reboot')); getLandscapeURL (model) ; one('a' ).setAttribute( 'href', baseLandscapeURL); 'landscape- security- upgrades' ]) { one('a' ).setAttribute( 'href', getLandscapeURL (model, 'security')); 'landscape- needs-reboot' ]) { one('a' ).setAttribute( 'href', getLandscapeURL (model, 'reboot'));
- machine.show();
- machine.
- landscape.
-
- if (annotations[
- updates.show();
- updates.
- landscape.
- }
-
- if (annotations[
- restart.show();
- restart.
- landscape.
+ var baseLandscapeURL = landscape.
+ if (baseLandscapeURL) {
+ machine.show();
+ machine.
+
+ if (annotations[
+ updates.show();
+ updates.
+ landscape.
+ }
+
+ if (annotations[
+ restart.show();
+ restart.
+ landscape.
+ }
}
}
};
Index: test/test_ service_ view.js service_ view.js' service_ view.js 2013-03-21 15:32:06 +0000 service_ view.js 2013-04-11 19:46:11 +0000
destroy. simulate( 'click' );
view. on('navigateTo' , function(ev) { equal(' /:gui:/ ', ev.url); values( env._txn_ callbacks) ;
callbacks. length. should. equal(1) ;
callbacks[ 0]({result: true}); db.services. getById( service. get('id' ))).to. not.exist;
db. relations. map(function( u) {return u.get('id');})
.should. eql(['relation- 0000000001' ]);
called. should. equal(true) ; should. equal(true) ;
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -349,20 +349,23 @@
var called = false;
- assert.equal('/', ev.url);
+ assert.
called = true;
});
var callbacks = Y.Object.
- // Since we don't have an app to listen to this event and tell the
- // view to re-render, we need to do it ourselves.
- db.on('update', view.render, view);
+ var dbUpdated = false;
+ db.on('update', function() {
+ dbUpdated = true;
+ });
var _ =
expect(
// Catch show environment event.
+ // The db should be updated.
+ dbUpdated.
});
it('should send an expose RPC call when exposeService is invoked',