Left: | ||
Right: |
OLD | NEW |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 YUI.add('juju-topology-service', function(Y) { | 3 YUI.add('juju-topology-service', function(Y) { |
4 var views = Y.namespace('juju.views'), | 4 var views = Y.namespace('juju.views'), |
5 models = Y.namespace('juju.models'), | 5 models = Y.namespace('juju.models'), |
6 utils = Y.namespace('juju.views.utils'), | 6 utils = Y.namespace('juju.views.utils'), |
7 d3ns = Y.namespace('d3'), | 7 d3ns = Y.namespace('d3'), |
8 Templates = views.Templates; | 8 Templates = views.Templates; |
9 | 9 |
10 /** | 10 /** |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 .show_service(service, context); | 68 .show_service(service, context); |
69 }} | 69 }} |
70 }, | 70 }, |
71 '.destroy-service': { | 71 '.destroy-service': { |
72 /** The user clicked on the "Destroy" menu item. */ | 72 /** The user clicked on the "Destroy" menu item. */ |
73 click: {callback: function(data, context) { | 73 click: {callback: function(data, context) { |
74 // Get the service element | 74 // Get the service element |
75 var topo = context.get('component'); | 75 var topo = context.get('component'); |
76 var box = topo.get('active_service'); | 76 var box = topo.get('active_service'); |
77 var service = topo.serviceForBox(box); | 77 var service = topo.serviceForBox(box); |
78 // The user is not allowed to destroy the Juju GUI service because | |
79 // it would break the application they are currently using. | |
gary.poster
2013/01/17 17:34:06
I'm not sure yet from the code, but I'm hoping tha
benji
2013/01/17 19:19:50
Nope, this is really the code that keeps the destr
gary.poster
2013/01/17 20:02:50
Ah, OK, cool.
| |
80 if (utils.isGuiService(service)) { | |
81 return; | |
82 } | |
78 context.service_click_actions | 83 context.service_click_actions |
79 .toggleControlPanel(box, context); | 84 .toggleControlPanel(box, context); |
80 context.service_click_actions | 85 context.service_click_actions |
81 .destroyServiceConfirm(service, context); | 86 .destroyServiceConfirm(service, context); |
82 }} | 87 }} |
83 } | 88 } |
84 }, | 89 }, |
85 d3: { | 90 d3: { |
86 '.service': { | 91 '.service': { |
87 'mousedown.addrel': {callback: function(d, context) { | 92 'mousedown.addrel': {callback: function(d, context) { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 (menu_left ? service.w * z : -(cp_width)) + tr[0] | 722 (menu_left ? service.w * z : -(cp_width)) + tr[0] |
718 }); | 723 }); |
719 } | 724 } |
720 }, | 725 }, |
721 | 726 |
722 /* | 727 /* |
723 * Actions to be called on clicking a service. | 728 * Actions to be called on clicking a service. |
724 */ | 729 */ |
725 service_click_actions: { | 730 service_click_actions: { |
726 /* | 731 /* |
727 * Default action: show or hide control panel. | 732 * Default action: show or hide control panel (service menu). |
733 * | |
734 * @method toggleControlPanel | |
735 * @param {Object} service The service in question (if any). | |
736 * @param {Object} view The current view. | |
737 * @param {object} context The active context. | |
728 */ | 738 */ |
729 toggleControlPanel: function(m, view, context) { | 739 toggleControlPanel: function(service, view, context) { |
730 var container = view.get('container'), | 740 var menu = view.get('container').one('#service-menu'), |
gary.poster
2013/01/17 17:34:06
nicer variable name, thank you :-)
| |
731 topo = view.get('component'), | 741 topo = view.get('component'); |
732 cp = container.one('#service-menu'); | |
733 | 742 |
734 if (cp.hasClass('active') || !m) { | 743 if (menu.hasClass('active') || !service) { |
735 cp.removeClass('active'); | 744 menu.removeClass('active'); |
736 topo.set('active_service', null); | 745 topo.set('active_service', null); |
737 topo.set('active_context', null); | 746 topo.set('active_context', null); |
747 // Most services can be destroyed via the GUI. | |
748 menu.one('.destroy-service').removeClass('disabled'); | |
738 } else { | 749 } else { |
739 topo.set('active_service', m); | 750 topo.set('active_service', service); |
740 topo.set('active_context', context); | 751 topo.set('active_context', context); |
741 cp.addClass('active'); | 752 menu.addClass('active'); |
753 // We do not want the user destroying the Juju GUI service. | |
754 if (utils.isGuiService(service)) { | |
755 menu.one('.destroy-service').addClass('disabled'); | |
gary.poster
2013/01/17 17:34:06
Per my previous comment, yep, I see you disable it
| |
756 } | |
742 view.updateServiceMenuLocation(); | 757 view.updateServiceMenuLocation(); |
743 } | 758 } |
744 }, | 759 }, |
745 | 760 |
746 /* | 761 /* |
747 * View a service | 762 * View a service |
748 */ | 763 */ |
749 show_service: function(m, context) { | 764 show_service: function(m, context) { |
750 var topo = context.get('component'); | 765 var topo = context.get('component'); |
751 topo.detachContainer(); | 766 topo.detachContainer(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 views.ServiceModule = ServiceModule; | 836 views.ServiceModule = ServiceModule; |
822 }, '0.1.0', { | 837 }, '0.1.0', { |
823 requires: [ | 838 requires: [ |
824 'd3', | 839 'd3', |
825 'd3-components', | 840 'd3-components', |
826 'juju-templates', | 841 'juju-templates', |
827 'juju-models', | 842 'juju-models', |
828 'juju-env' | 843 'juju-env' |
829 ] | 844 ] |
830 }); | 845 }); |
OLD | NEW |