Merge lp:~gary/juju-gui/ghostDeploy into lp:juju-gui/experimental

Proposed by Gary Poster
Status: Merged
Merged at revision: 1050
Proposed branch: lp:~gary/juju-gui/ghostDeploy
Merge into: lp:juju-gui/experimental
Diff against target: 167 lines (+42/-15)
6 files modified
app/store/env/sandbox.js (+11/-3)
app/templates/service-constraints-viewlet.handlebars (+1/-1)
app/templates/service-relations-viewlet.handlebars (+1/-0)
app/views/ghost-inspector.js (+5/-0)
app/views/topology/service.js (+20/-5)
app/views/viewlets/inspector-header.js (+4/-6)
To merge this branch: bzr merge lp:~gary/juju-gui/ghostDeploy
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+185933@code.launchpad.net

Description of the change

Inspector shows up after ghost inspector

- Per UX, after ghost inspector finishes, real inspector starts
- Changed new service creation to not bounce the box around
- Made a couple of other small tweaks for sandbox edge cases and capitalization

https://codereview.appspot.com/13246050/

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (8.0 KiB)

Reviewers: mp+185933_code.launchpad.net,

Message:
Please take a look.

Description:
Inspector shows up after ghost inspector

- Per UX, after ghost inspector finishes, real inspector starts
- Changed new service creation to not bounce the box around
- Made a couple of other small tweaks for sandbox edge cases and
capitalization

https://code.launchpad.net/~gary/juju-gui/ghostDeploy/+merge/185933

(do not edit description out of merge proposal)

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

Affected files (+44, -15 lines):
   A [revision details]
   M app/store/env/sandbox.js
   M app/templates/service-constraints-viewlet.handlebars
   M app/templates/service-relations-viewlet.handlebars
   M app/views/ghost-inspector.js
   M app/views/topology/service.js
   M app/views/viewlets/inspector-header.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/templates/service-constraints-viewlet.handlebars
=== modified file 'app/templates/service-constraints-viewlet.handlebars'
--- app/templates/service-constraints-viewlet.handlebars 2013-09-16
07:36:24 +0000
+++ app/templates/service-constraints-viewlet.handlebars 2013-09-16
20:09:02 +0000
@@ -1,6 +1,6 @@
  <div class="settings-constraints">
    <div class="view-container">
- <h2>Constraints for New Units</h2>
+ <h2>Constraints for new units</h2>
      <div class="view-content">
        {{> service-constraints-viewlet}}
      </div>

Index: app/templates/service-relations-viewlet.handlebars
=== modified file 'app/templates/service-relations-viewlet.handlebars'
--- app/templates/service-relations-viewlet.handlebars 2013-09-07 14:53:02
+0000
+++ app/templates/service-relations-viewlet.handlebars 2013-09-16 20:09:02
+0000
@@ -1,3 +1,4 @@
  <div class="view-container settings-config">
+ <h2>Relations</h2>
    <div data-bind="aggregateRelations"></div>
  </div>

Index: app/views/ghost-inspector.js
=== modified file 'app/views/ghost-inspector.js'
--- app/views/ghost-inspector.js 2013-09-16 07:00:29 +0000
+++ app/views/ghost-inspector.js 2013-09-16 21:09:30 +0000
@@ -300,6 +300,11 @@
        });

        this.closeInspector();
+ // This flag is used twice in the service topology module as a marker
+ // to know that it should not move the service or the canvas around
+ // (as opposed to services received from the environment).
+ ghostService.set('localCreation', true);
+ this.options.environment.createServiceInspector(ghostService);
      }

    };

Index: app/store/env/sandbox.js
=== modified file 'app/store/env/sandbox.js'
--- app/store/env/sandbox.js 2013-09-13 16:55:51 +0000
+++ app/store/env/sandbox.js 2013-09-16 20:09:02 +0000
@@ -852,13 +852,21 @@
          'Series': function(attrs, self) {
            var db = self.get('state').db;
            var service = db.services.getById(attrs.service);
- var charm = db.charms.getById(service.get('charm'));
- ...

Read more...

Revision history for this message
Gary Poster (gary) wrote :

95% fly-bys. Sorry.

https://codereview.appspot.com/13246050/diff/1/app/store/env/sandbox.js
File app/store/env/sandbox.js (right):

https://codereview.appspot.com/13246050/diff/1/app/store/env/sandbox.js#newcode859
app/store/env/sandbox.js:859: return null; // Probably unit/service was
deleted.
This was a flyby: when deleting a service then sometimes this would
trigger. I'll remove if a test is needed; it is just for exploratory
testing AFAIK.

https://codereview.appspot.com/13246050/diff/1/app/store/env/sandbox.js#newcode868
app/store/env/sandbox.js:868: return null; // Probably unit/service was
deleted.
As above.

https://codereview.appspot.com/13246050/diff/1/app/templates/service-constraints-viewlet.handlebars
File app/templates/service-constraints-viewlet.handlebars (right):

https://codereview.appspot.com/13246050/diff/1/app/templates/service-constraints-viewlet.handlebars#newcode3
app/templates/service-constraints-viewlet.handlebars:3: <h2>Constraints
for new units</h2>
Fly-by. Every other title is sentence cased. I prefer title cased, but
this is easier for now, and I'm not sure if this is actually something
that UX cares about.

https://codereview.appspot.com/13246050/diff/1/app/templates/service-relations-viewlet.handlebars
File app/templates/service-relations-viewlet.handlebars (right):

https://codereview.appspot.com/13246050/diff/1/app/templates/service-relations-viewlet.handlebars#newcode2
app/templates/service-relations-viewlet.handlebars:2: <h2>Relations</h2>
Every other non-intro tab has a header. It needs one. Sorry, another
fly-by.

https://codereview.appspot.com/13246050/diff/1/app/views/ghost-inspector.js
File app/views/ghost-inspector.js (right):

https://codereview.appspot.com/13246050/diff/1/app/views/ghost-inspector.js#newcode306
app/views/ghost-inspector.js:306: ghostService.set('localCreation',
true);
This line is about...well, see the comment.

https://codereview.appspot.com/13246050/diff/1/app/views/ghost-inspector.js#newcode307
app/views/ghost-inspector.js:307:
this.options.environment.createServiceInspector(ghostService);
This was the only change that this branch actually needed to accomplish
the stated task. Sorry.

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

https://codereview.appspot.com/13246050/diff/1/app/views/topology/service.js#newcode1391
app/views/topology/service.js:1391:
serviceMenu.one('.destroy-service').hide();
Another fly-by. We should actually make this menu show and hide with
inspector, but I was amazingly able to hold myself back from
implementing that. (It was because I couldn't see how to do it quickly
:-P).

https://codereview.appspot.com/13246050/diff/1/app/views/viewlets/inspector-header.js
File app/views/viewlets/inspector-header.js (right):

https://codereview.appspot.com/13246050/diff/1/app/views/viewlets/inspector-header.js#newcode35
app/views/viewlets/inspector-header.js:35: if (model instanceof
models.BrowserCharm) {
Another flyby. Jeff pointed out the .scheme conditional, which seemed
unnecessarily obscure to me. This seems nice and clear to me.

https://codereview.appspot.com/13246050/

Revision history for this message
Madison Scott-Clary (makyo) wrote :

LGTM, QA okay in Chrome/Go Env (starting up IE now, will comment if
anything goes wrong)

https://codereview.appspot.com/13246050/diff/1/app/views/ghost-inspector.js
File app/views/ghost-inspector.js (right):

https://codereview.appspot.com/13246050/diff/1/app/views/ghost-inspector.js#newcode306
app/views/ghost-inspector.js:306: ghostService.set('localCreation',
true);
On 2013/09/16 21:22:16, gary.poster wrote:
> This line is about...well, see the comment.

Would like to see this defined in the Service model's ATTRs with a
comment and default to false, just for consistency's sake.

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

https://codereview.appspot.com/13246050/diff/1/app/views/topology/service.js#newcode1099
app/views/topology/service.js:1099: // box.model.set('localCreation',
false);
Remove (assuming flag gets unset later?)

https://codereview.appspot.com/13246050/

Revision history for this message
Madison Scott-Clary (makyo) wrote :

IE QA okay - services dragged onto the canvas don't retain drop
coordinates, but that's true in trunk as well. Will hunt or file bug.

https://codereview.appspot.com/13246050/

Revision history for this message
Gary Poster (gary) wrote :

*** Submitted:

Inspector shows up after ghost inspector

- Per UX, after ghost inspector finishes, real inspector starts
- Changed new service creation to not bounce the box around
- Made a couple of other small tweaks for sandbox edge cases and
capitalization

R=matthew.scott
CC=
https://codereview.appspot.com/13246050

https://codereview.appspot.com/13246050/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/env/sandbox.js'
2--- app/store/env/sandbox.js 2013-09-13 16:55:51 +0000
3+++ app/store/env/sandbox.js 2013-09-16 21:15:45 +0000
4@@ -852,13 +852,21 @@
5 'Series': function(attrs, self) {
6 var db = self.get('state').db;
7 var service = db.services.getById(attrs.service);
8- var charm = db.charms.getById(service.get('charm'));
9- return charm.get('series');
10+ if (service) {
11+ var charm = db.charms.getById(service.get('charm'));
12+ return charm.get('series');
13+ } else {
14+ return null; // Probably unit/service was deleted.
15+ }
16 },
17 'CharmURL': function(attrs, self) {
18 var db = self.get('state').db;
19 var service = db.services.getById(attrs.service);
20- return service.get('charm');
21+ if (service) {
22+ return service.get('charm');
23+ } else {
24+ return null; // Probably unit/service was deleted.
25+ }
26 },
27 PublicAddress: 'public_address',
28 PrivateAddress: 'private_address',
29
30=== modified file 'app/templates/service-constraints-viewlet.handlebars'
31--- app/templates/service-constraints-viewlet.handlebars 2013-09-16 07:36:24 +0000
32+++ app/templates/service-constraints-viewlet.handlebars 2013-09-16 21:15:45 +0000
33@@ -1,6 +1,6 @@
34 <div class="settings-constraints">
35 <div class="view-container">
36- <h2>Constraints for New Units</h2>
37+ <h2>Constraints for new units</h2>
38 <div class="view-content">
39 {{> service-constraints-viewlet}}
40 </div>
41
42=== modified file 'app/templates/service-relations-viewlet.handlebars'
43--- app/templates/service-relations-viewlet.handlebars 2013-09-07 14:53:02 +0000
44+++ app/templates/service-relations-viewlet.handlebars 2013-09-16 21:15:45 +0000
45@@ -1,3 +1,4 @@
46 <div class="view-container settings-config">
47+ <h2>Relations</h2>
48 <div data-bind="aggregateRelations"></div>
49 </div>
50
51=== modified file 'app/views/ghost-inspector.js'
52--- app/views/ghost-inspector.js 2013-09-16 07:00:29 +0000
53+++ app/views/ghost-inspector.js 2013-09-16 21:15:45 +0000
54@@ -300,6 +300,11 @@
55 });
56
57 this.closeInspector();
58+ // This flag is used twice in the service topology module as a marker
59+ // to know that it should not move the service or the canvas around
60+ // (as opposed to services received from the environment).
61+ ghostService.set('localCreation', true);
62+ this.options.environment.createServiceInspector(ghostService);
63 }
64
65 };
66
67=== modified file 'app/views/topology/service.js'
68--- app/views/topology/service.js 2013-09-10 01:45:00 +0000
69+++ app/views/topology/service.js 2013-09-16 21:15:45 +0000
70@@ -106,9 +106,16 @@
71 delete annotations['gui-y'];
72 // Only update position if we're not already in a drag state (the
73 // current drag supercedes any previous annotations).
74+ var localCreation = d.model.get('localCreation');
75+ if (localCreation) {
76+ // This flag has served its purpose, at initialization time on the
77+ // canvas. Remove it, so future changes will have the usual
78+ // behavior.
79+ d.model.set('localCreation', false);
80+ }
81 if (!d.inDrag) {
82- self.drag.call(this, d, self, {x: x, y: y},
83- self.get('useTransitions'));
84+ var useTransitions = self.get('useTransitions') && !localCreation;
85+ self.drag.call(this, d, self, {x: x, y: y}, useTransitions);
86 }
87 }});
88
89@@ -1049,6 +1056,7 @@
90 // nodes. This has the side effect that service blocks can overlap
91 // and will be fixed later.
92 var vertices;
93+ var localCreation = false;
94 var new_services = Y.Object.values(topo.service_boxes)
95 .filter(function(boundingBox) {
96 return !Y.Lang.isNumber(boundingBox.x);
97@@ -1087,6 +1095,10 @@
98 vertices = [];
99 }
100 Y.each(new_services, function(box) {
101+ if (box.model.get('localCreation')) {
102+ // box.model.set('localCreation', false);
103+ localCreation = true;
104+ }
105 var existing = box.model.get('annotations') || {};
106 if (!existing && !existing['gui-x']) {
107 topo.get('env').update_annotations(
108@@ -1111,7 +1123,7 @@
109 if (!vertices) {
110 vertices = topoUtils.serviceBoxesToVertices(topo.service_boxes);
111 }
112- this.findAndSetCentroid(vertices);
113+ this.findAndSetCentroid(vertices, localCreation);
114 }
115 // enter
116 node
117@@ -1157,14 +1169,16 @@
118 @param {array} vertices A list of vertices in the form [x, y].
119 @return {undefined} Side effects only.
120 */
121- findAndSetCentroid: function(vertices) {
122+ findAndSetCentroid: function(vertices, preventPan) {
123 var topo = this.get('component'),
124 centroid = topoUtils.centroid(vertices);
125 // The centroid is set on the topology object due to the fact that it is
126 // used as a sigil to tell whether or not to pan to the point after the
127 // first delta.
128 topo.centroid = centroid;
129- topo.fire('panToPoint', {point: topo.centroid});
130+ if (!preventPan) {
131+ topo.fire('panToPoint', {point: topo.centroid});
132+ }
133 },
134
135 /**
136@@ -1374,6 +1388,7 @@
137 // The view option should not be used with the inspector.
138 if (flags.serviceInspector) {
139 serviceMenu.one('.view-service').hide();
140+ serviceMenu.one('.destroy-service').hide();
141 }
142
143 if (box && !serviceMenu.hasClass('active')) {
144
145=== modified file 'app/views/viewlets/inspector-header.js'
146--- app/views/viewlets/inspector-header.js 2013-08-27 12:42:30 +0000
147+++ app/views/viewlets/inspector-header.js 2013-09-16 21:15:45 +0000
148@@ -32,15 +32,13 @@
149 'render': function(model, viewContainerAttrs) {
150 this.container = Y.Node.create(this.templateWrapper);
151 var pojoModel = model.getAttrs();
152- if (pojoModel.scheme) {
153+ if (model instanceof models.BrowserCharm) {
154 pojoModel.ghost = true;
155- }
156- // If this is a service, the id is the service.charm.
157- if (pojoModel.charm) {
158+ pojoModel.charmUrl = pojoModel.id;
159+ } else if (model instanceof models.Service) {
160 pojoModel.charmUrl = pojoModel.charm;
161 } else {
162- // If this is a charm model, just use the id.
163- pojoModel.charmUrl = pojoModel.id;
164+ throw 'Programmer error: unknown model type';
165 }
166 // Manually add the icon url for the charm since we don't have access to
167 // the browser handlebars helper at this location.

Subscribers

People subscribed via source and target branches