Description:
Sync relation menu with inspector open and close
While the relation menu is going away soonish, if the plans are to be
believed, meanwhile it is what we have. This branch makes it so that
when the inspector is first opened--after a ghost or when you click on a
service--the relation menu appears. Similarly, when you close the
inspector, relation menus close.
It is still possible to hide the relation menu while the inspector is
open. If you begin to create a relation, the option will disappear; and
if you click the canvas it will disappear. These seem like pretty good
interactions for me, given the fundamental oddity (to me) of having the
relation menu and the inspector separate entities, at least given the
current design.
Affected files (+30, -48 lines):
A [revision details]
M app/index.html
M app/views/environment.js
M app/views/topology/service.js
M test/test_environment_view.js
M test/test_service_module.js
Index: app/index.html
=== modified file 'app/index.html'
--- app/index.html 2013-09-12 18:15:47 +0000
+++ app/index.html 2013-09-17 15:44:32 +0000
@@ -39,9 +39,8 @@
<meta name="author" content="Juju team">
<link
href='https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700|
Ubuntu:300,400,500,300italic,400italic,500italic' rel='stylesheet'
type='text/css'>
<link rel="shortcut icon" href="/favicon.ico">
- <!-- Remove the query strings below after release 0.9.0. -->
- <link rel="stylesheet"
href="/juju-ui/assets/combined-css/all-static.css?reload=temporary">
- <link rel="stylesheet"
href="/juju-ui/assets/juju-gui.css?reload=temporary">
+ <link rel="stylesheet"
href="/juju-ui/assets/combined-css/all-static.css">
+ <link rel="stylesheet" href="/juju-ui/assets/juju-gui.css">
<link rel="stylesheet" href="/juju-ui/assets/sprites.css">
<!-- Make sure the config is loaded before other JS for use in the page
below.
@@ -363,9 +362,8 @@
because we want the browser warning to execute before spending the
time
to download an app the user might not be able to use anyway.
-->
- <!-- Remove the query strings below after release 0.9.0. -->
- <script src="/juju-ui/assets/all-yui.js?reload=temporary"></script>
- <script src="/juju-ui/assets/modules.js?reload=temporary"></script>
+ <script src="/juju-ui/assets/all-yui.js"></script>
+ <script src="/juju-ui/assets/modules.js"></script>
<script>
// Now that all of the above JS is loaded we can define the real
start
// function which will be picked up by the setTimeout, and the app
will
// Since the service's charm is not loaded the 'Build Relation'
link
// is disabled.
@@ -787,8 +787,8 @@
charm = db.charms.getById(service.charm); charm.loaded = true;
// Toggle the service menu twice to cause re-rendering.
- sm.toggleServiceMenu(service);
- sm.toggleServiceMenu(service);
+ sm.hideServiceMenu(service);
+ sm.showServiceMenu(service);
// Now that the charm is loaded and the menu is re-rendered, the
// Build Relation link is no longer disabled. assert.isFalse(add_rel.hasClass('disabled'));
@@ -815,7 +815,7 @@
// Toggle the service menu for the Add Relation button.
var sm = view.topo.modules.ServiceModule;
- sm.toggleServiceMenu(service);
+ sm.showServiceMenu(service);
// Mock an event object so that d3.mouse does not throw a NPE.
d3.event = {}; add_rel.simulate('click');
@@ -878,7 +878,7 @@
var module = view.topo.modules.RelationModule;
var sm = view.topo.modules.ServiceModule;
- sm.toggleServiceMenu(service);
+ sm.showServiceMenu(service);
// Mock an event object so that d3.mouse does not throw a NPE.
d3.event = {}; add_rel.simulate('click');
- it('should toggle the service menu',
- function() {
- var box = topo.service_boxes.haproxy;
- var menu = viewContainer.one('#service-menu');
- assert.isFalse(menu.hasClass('active'));
- serviceModule.toggleServiceMenu(box);
- assert(menu.hasClass('active'));
- serviceModule.toggleServiceMenu(box);
- assert.isFalse(menu.hasClass('active'));
- });
-
it('should show the service menu',
function() {
var box = topo.service_boxes.haproxy;
@@ -315,7 +304,7 @@
var menu = view.get('container').one('#service-menu');
view.topo.set('active_service', service);
Index: app/views/environment.js
=== modified file 'app/views/environment.js'
--- app/views/environment.js 2013-09-13 20:11:50 +0000
+++ app/views/environment.js 2013-09-17 15:44:32 +0000
@@ -144,6 +144,11 @@
// listen for the event and remove it from the list of open
inspectors serviceInspector.viewletManager.after('destroy', function(e) { this.setInspector(e.currentTarget, true);
+ // We want the service menu to hide when the inspector does.
+ // For now, at least, with only one inspector, we can simply
close
+ // all service menus. We expect the service menus to go away
+ // soon-ish anyway in favor of a new approach.
+ this.topo.fire('hideServiceMenu');
}, this);
// Restrict to a single inspector instance
Index: app/views/topology/service.js
=== modified file 'app/views/topology/service.js'
--- app/views/topology/service.js 2013-09-17 00:54:58 +0000
+++ app/views/topology/service.js 2013-09-17 17:06:13 +0000
@@ -107,12 +107,6 @@
// Only update position if we're not already in a drag state (the
// current drag supercedes any previous annotations).
var fromGhost = d.model.get('placeFromGhostPosition');
- if (fromGhost) {
- // This flag has served its purpose, at initialization time on
the
- // canvas. Remove it, so future changes will have the usual
- // behavior.
- d.model.set('placeFromGhostPosition', false);
- }
if (!d.inDrag) {
var useTransitions = self.get('useTransitions') && !fromGhost; self.drag.call(this, d, self, {x: x, y: y}, useTransitions);
@@ -173,6 +167,18 @@
'x': 64,
'y': 47 * 0.8});
+ // Handle the last step of models that were made locally from ghosts.
+ node.filter(function(d) {
+ return d.model.get('placeFromGhostPosition');
+ }).each(function(d) {
+ // Show the service menu from the start.
+ self.showServiceMenu(d);
+ // This flag has served its purpose, at initialization time on the
+ // canvas. Remove it, so future changes will have the usual
+ // behavior.
+ d.model.set('placeFromGhostPosition', false);
+ });
+
// Landscape badge
if (landscape) { node.each(function(d) {
@@ -454,8 +460,7 @@
initializer: function(options) { ServiceModule.superclass.constructor.apply(this, arguments);
// Set a default
- this.set('currentServiceClickAction', 'toggleServiceMenu');
-
+ this.set('currentServiceClickAction', 'showServiceMenu');
},
/**
@@ -1329,23 +1334,6 @@
},
/**
- * Show (if hidden) or hide (if shown) the service menu.
- *
- * @method toggleServiceMenu
- * @param {object} box The presentation state for the service.
- * @return {undefined} Side effects only.
- */
- toggleServiceMenu: function(box) {
- var serviceMenu = this.get('container').one('#service-menu');
-
- if (serviceMenu.hasClass('active') || !box) {
- this.hideServiceMenu();
- } else {
- this.showServiceMenu(box);
- }
- },
-
- /**
* Show the service menu.
*
* @method showServiceMenu
Reviewers: mp+186107_ code.launchpad. net,
Message:
Please take a look.
Description:
Sync relation menu with inspector open and close
While the relation menu is going away soonish, if the plans are to be
believed, meanwhile it is what we have. This branch makes it so that
when the inspector is first opened--after a ghost or when you click on a
service--the relation menu appears. Similarly, when you close the
inspector, relation menus close.
It is still possible to hide the relation menu while the inspector is
open. If you begin to create a relation, the option will disappear; and
if you click the canvas it will disappear. These seem like pretty good
interactions for me, given the fundamental oddity (to me) of having the
relation menu and the inspector separate entities, at least given the
current design.
https:/ /code.launchpad .net/~gary/ juju-gui/ syncMenu/ +merge/ 186107
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/13583044/
Affected files (+30, -48 lines): environment. js topology/ service. js environment_ view.js service_ module. js
A [revision details]
M app/index.html
M app/views/
M app/views/
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/index.html /fonts. googleapis. com/css? family= Ubuntu+ Mono:400, 700| 300,400, 500,300italic, 400italic, 500italic' rel='stylesheet' favicon. ico"> juju-ui/ assets/ combined- css/all- static. css?reload= temporary" > juju-ui/ assets/ juju-gui. css?reload= temporary" > juju-ui/ assets/ combined- css/all- static. css"> juju-ui/ assets/ juju-gui. css"> juju-ui/ assets/ sprites. css"> ui/assets/ all-yui. js?reload= temporary" ></script> ui/assets/ modules. js?reload= temporary" ></script> ui/assets/ all-yui. js"></script> ui/assets/ modules. js"></script>
=== modified file 'app/index.html'
--- app/index.html 2013-09-12 18:15:47 +0000
+++ app/index.html 2013-09-17 15:44:32 +0000
@@ -39,9 +39,8 @@
<meta name="author" content="Juju team">
<link
href='https:/
Ubuntu:
type='text/css'>
<link rel="shortcut icon" href="/
- <!-- Remove the query strings below after release 0.9.0. -->
- <link rel="stylesheet"
href="/
- <link rel="stylesheet"
href="/
+ <link rel="stylesheet"
href="/
+ <link rel="stylesheet" href="/
<link rel="stylesheet" href="/
<!-- Make sure the config is loaded before other JS for use in the page
below.
@@ -363,9 +362,8 @@
because we want the browser warning to execute before spending the
time
to download an app the user might not be able to use anyway.
-->
- <!-- Remove the query strings below after release 0.9.0. -->
- <script src="/juju-
- <script src="/juju-
+ <script src="/juju-
+ <script src="/juju-
<script>
// Now that all of the above JS is loaded we can define the real
start
// function which will be picked up by the setTimeout, and the app
will
Index: test/test_ environment_ view.js environment_ view.js' environment_ view.js 2013-09-13 13:47:51 +0000 environment_ view.js 2013-09-17 17:06:13 +0000
loaded: false};
db. charms. add(charm) ; eMenu(service) ; enu(service) ;
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -779,7 +779,7 @@
var charm = {'id': service.charm,
- sm.toggleServic
+ sm.showServiceM
// Since the service's charm is not loaded the 'Build Relation' getById( service. charm);
charm. loaded = true; eMenu(service) ; eMenu(service) ; enu(service) ; enu(service) ;
assert. isFalse( add_rel. hasClass( 'disabled' ));
link
// is disabled.
@@ -787,8 +787,8 @@
charm = db.charms.
// Toggle the service menu twice to cause re-rendering.
- sm.toggleServic
- sm.toggleServic
+ sm.hideServiceM
+ sm.showServiceM
// Now that the charm is loaded and the menu is re-rendered, the
// Build Relation link is no longer disabled.
@@ -815,7 +815,7 @@
// Toggle the service menu for the Add Relation button. modules. ServiceModule; eMenu(service) ; enu(service) ;
add_ rel.simulate( 'click' ); modules. RelationModule; modules. ServiceModule;
var sm = view.topo.
- sm.toggleServic
+ sm.showServiceM
// Mock an event object so that d3.mouse does not throw a NPE.
d3.event = {};
@@ -878,7 +878,7 @@
var module = view.topo.
var sm = view.topo.
- sm.toggleServic eMenu(service) ; enu(service) ;
add_ rel.simulate( 'click' );
+ sm.showServiceM
// Mock an event object so that d3.mouse does not throw a NPE.
d3.event = {};
Index: test/test_ service_ module. js service_ module. js' service_ module. js 2013-09-03 09:41:49 +0000 service_ module. js 2013-09-17 17:06:13 +0000
=== modified file 'test/test_
--- test/test_
+++ test/test_
@@ -147,17 +147,6 @@
}
});
- it('should toggle the service menu', boxes.haproxy; one('#service- menu'); isFalse( menu.hasClass( 'active' )); toggleServiceMe nu(box) ; menu.hasClass( 'active' )); toggleServiceMe nu(box) ; isFalse( menu.hasClass( 'active' )); boxes.haproxy; 'container' ).one(' #service- menu'); topo.set( 'active_ service' , service);
- function() {
- var box = topo.service_
- var menu = viewContainer.
- assert.
- serviceModule.
- assert(
- serviceModule.
- assert.
- });
-
it('should show the service menu',
function() {
var box = topo.service_
@@ -315,7 +304,7 @@
var menu = view.get(
view.
- serviceModule. toggleServiceMe nu(box) ; showServiceMenu (box); one('.destroy- service' ).hasClass( 'disabled' ).should. equal(true) ;
+ serviceModule.
menu.
});
Index: app/views/ environment. js environment. js' environment. js 2013-09-13 20:11:50 +0000 environment. js 2013-09-17 15:44:32 +0000
serviceIns pector. viewletManager. after(' destroy' , function(e) {
this.setInspect or(e.currentTar get, true); fire('hideServi ceMenu' );
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -144,6 +144,11 @@
// listen for the event and remove it from the list of open
inspectors
+ // We want the service menu to hide when the inspector does.
+ // For now, at least, with only one inspector, we can simply
close
+ // all service menus. We expect the service menus to go away
+ // soon-ish anyway in favor of a new approach.
+ this.topo.
}, this);
// Restrict to a single inspector instance
Index: app/views/ topology/ service. js topology/ service. js' topology/ service. js 2013-09-17 00:54:58 +0000 topology/ service. js 2013-09-17 17:06:13 +0000 get('placeFromG hostPosition' ); set('placeFromG hostPosition' , false); 'useTransitions ') && !fromGhost;
self. drag.call( this, d, self, {x: x, y: y}, useTransitions);
=== modified file 'app/views/
--- app/views/
+++ app/views/
@@ -107,12 +107,6 @@
// Only update position if we're not already in a drag state (the
// current drag supercedes any previous annotations).
var fromGhost = d.model.
- if (fromGhost) {
- // This flag has served its purpose, at initialization time on
the
- // canvas. Remove it, so future changes will have the usual
- // behavior.
- d.model.
- }
if (!d.inDrag) {
var useTransitions = self.get(
@@ -173,6 +167,18 @@
'x': 64,
'y': 47 * 0.8});
+ // Handle the last step of models that were made locally from ghosts. function( d) { get('placeFromG hostPosition' ); eMenu(d) ; set('placeFromG hostPosition' , false);
node.each( function( d) {
ServiceModule. superclass. constructor. apply(this, arguments); 'currentService ClickAction' , 'toggleServiceM enu'); 'currentService ClickAction' , 'showServiceMenu');
+ node.filter(
+ return d.model.
+ }).each(function(d) {
+ // Show the service menu from the start.
+ self.showServic
+ // This flag has served its purpose, at initialization time on the
+ // canvas. Remove it, so future changes will have the usual
+ // behavior.
+ d.model.
+ });
+
// Landscape badge
if (landscape) {
@@ -454,8 +460,7 @@
initializer: function(options) {
// Set a default
- this.set(
-
+ this.set(
},
/**
@@ -1329,23 +1334,6 @@
},
/** 'container' ).one(' #service- menu'); hasClass( 'active' ) || !box) { eMenu() ; eMenu(box) ;
- * Show (if hidden) or hide (if shown) the service menu.
- *
- * @method toggleServiceMenu
- * @param {object} box The presentation state for the service.
- * @return {undefined} Side effects only.
- */
- toggleServiceMenu: function(box) {
- var serviceMenu = this.get(
-
- if (serviceMenu.
- this.hideServic
- } else {
- this.showServic
- }
- },
-
- /**
* Show the service menu.
*
* @method showServiceMenu