Merge lp:~frankban/juju-gui/bug-1103204-remove-relation into lp:juju-gui/experimental
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 340 | ||||
Proposed branch: | lp:~frankban/juju-gui/bug-1103204-remove-relation | ||||
Merge into: | lp:juju-gui/experimental | ||||
Diff against target: |
35 lines (+7/-4) 1 file modified
app/views/topology/relation.js (+7/-4) |
||||
To merge this branch: | bzr merge lp:~frankban/juju-gui/bug-1103204-remove-relation | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju GUI Hackers | Pending | ||
Review via email: mp+144484@code.launchpad.net |
Description of the change
Fix error while removing relations.
When removing a relation sometimes an exception
is raised: "Uncaught TypeError: Cannot call method
'one' of null".
I was able to reproduce the bug following these steps:
1) click on a relation, the remove relation modal
dialog appears;
2) open the GUI in another tab, and force a delta stream
event (e.g. add/remove another relation,
destroy a service...);
3) on delta, the relation nodes are redrawn on both tabs,
so the element stored in the dialog no longer exists
in the DOM;
4) on the first tab, click to confirm the relation removal,
you'll see the error.
In this branch, the relation node is retrieved again in
removeRelation using its relation id. This way we ensure
the element actually exists in the DOM.
Reviewers: mp+144484_ code.launchpad. net,
Message:
Please take a look.
Description:
Fix error while removing relations.
When removing a relation sometimes an exception
is raised: "Uncaught TypeError: Cannot call method
'one' of null".
I was able to reproduce the bug following these steps:
1) click on a relation, the remove relation modal
dialog appears;
2) open the GUI in another tab, and force a delta stream
event (e.g. add/remove another relation,
destroy a service...);
3) on delta, the relation nodes are redrawn on both tabs,
so the element stored in the dialog no longer exists
in the DOM;
4) on the first tab, click to confirm the relation removal,
you'll see the error.
In this branch, the relation node is retrieved again in
removeRelation using its relation id. This way we ensure
the element actually exists in the DOM.
https:/ /code.launchpad .net/~frankban/ juju-gui/ bug-1103204- remove- relation/ +merge/ 144484
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/7199043/
Affected files: topology/ relation. js
A [revision details]
M app/views/
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/views/ topology/ relation. js topology/ relation. js' topology/ relation. js 2013-01-22 20:25:32 +0000 topology/ relation. js 2013-01-23 12:16:30 +0000
self. addRelation( ); // Will clear the state. 'component' ).get(' env'); parentNode) .one('. relation' ); 'container' ).one(' #' + relationId);
utils. addSVGClass( relationElement , 'to-remove pending-relation');
env.remove_ relation(
endpoints[ 0][0] + ':' + endpoints[ 0][1].name,
endpoints[ 1][0] + ':' + endpoints[ 1][1].name,
Y. bind(this. _removeRelation Callback, this, view,
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -439,16 +439,19 @@
}
},
- removeRelation: function(d, context, view, confirmButton) {
+ removeRelation: function(d, view, confirmButton) {
var env = this.get(
var endpoints = d.endpoints;
- var relationElement = Y.one(context.
+ var relationId = d.relation_id;
+ // At this time, relations may have been redrawn, so here we have to
+ // retrieve the relation DOM element again.
+ var relationElement = view.get(
- relationElement, d.relation_id, confirmButton));
+ relationElement, relationId, confirmButton));
},
_ removeRelationC allback: function(view,
ev.preventDefau lt();
confirmButton. set('disabled' , true); tion(d, context, view, confirmButton); tion(d, view, confirmButton);
this) ));
@@ -491,7 +494,7 @@
var confirmButton = ev.target;
- view.removeRela
+ view.removeRela
},
},