Merge lp:~bac/juju-gui/1102640 into lp:juju-gui/experimental

Proposed by Brad Crittenden
Status: Merged
Merged at revision: 339
Proposed branch: lp:~bac/juju-gui/1102640
Merge into: lp:juju-gui/experimental
Diff against target: 62 lines (+16/-10)
2 files modified
app/views/topology/relation.js (+8/-10)
app/views/topology/service.js (+8/-0)
To merge this branch: bzr merge lp:~bac/juju-gui/1102640
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+144389@code.launchpad.net

Description of the change

When adding a relation, the service menu is shown.

If adding a relation using the 'Build Relation' action from the service menu
on the originating service, the click on the target service produces two
events. The dragend event is handled properly and sets up the relation. Then
the click event calls serviceClick.

Attempts to use the stopPropagation, stopEvent, and preventDefault methods on
the d3.event did not produce the desired results.

This work-around is pretty hacky but it does work. A more general solution
should be found.

Also, attempts to change the test 'must be able to add a relation from the
service menu' to simulate the click events and ensure the service menu was not
left displayed did not work.

This branch is submitted as is in an attempt to finish the last card blocking
the charm announcement.

https://codereview.appspot.com/7179049/

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

Reviewers: mp+144389_code.launchpad.net,

Message:
Please take a look.

Description:
When adding a relation, the service menu is shown.

If adding a relation using the 'Build Relation' action from the service
menu
on the originating service, the click on the target service produces two
events. The dragend event is handled properly and sets up the relation.
  Then
the click event calls serviceClick.

Attempts to use the stopPropagation, stopEvent, and preventDefault
methods on
the d3.event did not produce the desired results.

This work-around is pretty hacky but it does work. A more general
solution
should be found.

Also, attempts to change the test 'must be able to add a relation from
the
service menu' to simulate the click events and ensure the service menu
was not
left displayed did not work.

This branch is submitted as is in an attempt to finish the last card
blocking
the charm announcement.

https://code.launchpad.net/~bac/juju-gui/1102640/+merge/144389

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M app/views/topology/relation.js
   M app/views/topology/service.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: app/views/topology/relation.js
=== modified file 'app/views/topology/relation.js'
--- app/views/topology/relation.js 2013-01-22 14:09:00 +0000
+++ app/views/topology/relation.js 2013-01-22 20:25:32 +0000
@@ -420,8 +420,6 @@
                .attr('y2', d3.event.y);
        }
      },
-
-
      addRelationDragEnd: function() {
        // Get the line, the endpoint service, and the target <rect>.
        var self = this;
@@ -606,14 +604,14 @@

        if (endpoints && endpoints.length === 1) {
          // Create a relation with the only available endpoint.
- var ep = endpoints[0],
- endpoints_item = [
- [ep[0].service, {
- name: ep[0].name,
- role: 'server' }],
- [ep[1].service, {
- name: ep[1].name,
- role: 'client' }]];
+ var ep = endpoints[0];
+ var endpoints_item = [
+ [ep[0].service,
+ { name: ep[0].name,
+ role: 'server' }],
+ [ep[1].service,
+ { name: ep[1].name,
+ role: 'client' }]];
          view.addRelationEnd(endpoints_item, view, context);
          return;
        }

Index: app/views/topology/service.js
=== modified file 'app/views/topology/service.js'
--- app/views/topology/service.js 2013-01-22 13:38:47 +0000
+++ app/views/topology/service.js 2013-01-22 16:24:49 +0000
@@ -89,6 +89,12 @@
        if (!d.containsPoint(mouse_coords, topo.zoom)) {
          return;
        }
+ // serviceClick is being called after dragend is processed. In those
+ // cases the current click action should not be invoked.
+ if (topo.ign...

Read more...

Revision history for this message
Benjamin Saller (bcsaller) wrote :

LGTM, an unfortunate but needed work-around for the time being. Thanks.
Could you also add a card about (or just add now) a test ensuring the
behavior.

https://codereview.appspot.com/7179049/diff/1/app/views/topology/service.js
File app/views/topology/service.js (right):

https://codereview.appspot.com/7179049/diff/1/app/views/topology/service.js#newcode95
app/views/topology/service.js:95: topo.ignoreServiceClick = false;
If the state isn't shared it should be encapsulated at the module level,
meaning this.ignoreServiceClick. Nothing else need know about or check
this state.

https://codereview.appspot.com/7179049/diff/1/app/views/topology/service.js#newcode293
app/views/topology/service.js:293:
//d3.event.sourceEvent.preventDefault();
Prune.

https://codereview.appspot.com/7179049/

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

*** Submitted:

When adding a relation, the service menu is shown.

If adding a relation using the 'Build Relation' action from the service
menu
on the originating service, the click on the target service produces two
events. The dragend event is handled properly and sets up the relation.
  Then
the click event calls serviceClick.

Attempts to use the stopPropagation, stopEvent, and preventDefault
methods on
the d3.event did not produce the desired results.

This work-around is pretty hacky but it does work. A more general
solution
should be found.

Also, attempts to change the test 'must be able to add a relation from
the
service menu' to simulate the click events and ensure the service menu
was not
left displayed did not work.

This branch is submitted as is in an attempt to finish the last card
blocking
the charm announcement.

R=bcsaller
CC=
https://codereview.appspot.com/7179049

https://codereview.appspot.com/7179049/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/views/topology/relation.js'
2--- app/views/topology/relation.js 2013-01-22 14:09:00 +0000
3+++ app/views/topology/relation.js 2013-01-22 20:32:22 +0000
4@@ -420,8 +420,6 @@
5 .attr('y2', d3.event.y);
6 }
7 },
8-
9-
10 addRelationDragEnd: function() {
11 // Get the line, the endpoint service, and the target <rect>.
12 var self = this;
13@@ -606,14 +604,14 @@
14
15 if (endpoints && endpoints.length === 1) {
16 // Create a relation with the only available endpoint.
17- var ep = endpoints[0],
18- endpoints_item = [
19- [ep[0].service, {
20- name: ep[0].name,
21- role: 'server' }],
22- [ep[1].service, {
23- name: ep[1].name,
24- role: 'client' }]];
25+ var ep = endpoints[0];
26+ var endpoints_item = [
27+ [ep[0].service,
28+ { name: ep[0].name,
29+ role: 'server' }],
30+ [ep[1].service,
31+ { name: ep[1].name,
32+ role: 'client' }]];
33 view.addRelationEnd(endpoints_item, view, context);
34 return;
35 }
36
37=== modified file 'app/views/topology/service.js'
38--- app/views/topology/service.js 2013-01-22 13:38:47 +0000
39+++ app/views/topology/service.js 2013-01-22 20:32:22 +0000
40@@ -89,6 +89,12 @@
41 if (!d.containsPoint(mouse_coords, topo.zoom)) {
42 return;
43 }
44+ // serviceClick is being called after dragend is processed. In those
45+ // cases the current click action should not be invoked.
46+ if (topo.ignoreServiceClick) {
47+ topo.ignoreServiceClick = false;
48+ return;
49+ }
50 // Get the current click action
51 var curr_click_action = context.get('currentServiceClickAction');
52 // Fire the action named in the following scheme:
53@@ -282,7 +288,9 @@
54 dragend: function(d, self) {
55 var topo = self.get('component');
56 if (topo.buildingRelation) {
57+ topo.ignoreServiceClick = true;
58 topo.fire('addRelationDragEnd');
59+ //d3.event.sourceEvent.preventDefault();
60 }
61 else {
62 if (!d.inDrag ||

Subscribers

People subscribed via source and target branches