Merge lp:~hatch/juju-gui/peer-status-1255336 into lp:juju-gui/experimental

Proposed by Jeff Pihach
Status: Merged
Merged at revision: 1214
Proposed branch: lp:~hatch/juju-gui/peer-status-1255336
Merge into: lp:juju-gui/experimental
Diff against target: 46 lines (+22/-4)
2 files modified
app/templates/service-relations-list.handlebars (+3/-1)
app/views/utils.js (+19/-3)
To merge this branch: bzr merge lp:~hatch/juju-gui/peer-status-1255336
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+196964@code.launchpad.net

Description of the change

Displays the relation name for peer relations

https://codereview.appspot.com/34120044/

To post a comment you must log in.
Revision history for this message
Jeff Pihach (hatch) wrote :

Reviewers: mp+196964_code.launchpad.net,

Message:
Please take a look.

Description:
Displays the relation name for peer relations

https://code.launchpad.net/~hatch/juju-gui/peer-status-1255336/+merge/196964

(do not edit description out of merge proposal)

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

Affected files (+24, -4 lines):
   A [revision details]
   M app/templates/service-relations-list.handlebars
   M app/views/utils.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-relations-list.handlebars
=== modified file 'app/templates/service-relations-list.handlebars'
--- app/templates/service-relations-list.handlebars 2013-11-26 18:34:25
+0000
+++ app/templates/service-relations-list.handlebars 2013-11-27 17:14:10
+0000
@@ -4,7 +4,9 @@
  </div>
  {{/unless}}
  {{#relations}}
- <div class="relation-label {{relationStatus
far.service ../errors}}"><h3>{{far.service}}</h3></div>
+ <div class="relation-label {{relationStatus . ../errors}}">
+ <h3>{{relationServiceName .}}</h3>
+ </div>
    <h4>Interface: {{interface}}</h4>
    <h4>Name: {{near.name}}</h4>
    <h4>Role: {{near.role}}</h4>

Index: app/views/utils.js
=== modified file 'app/views/utils.js'
--- app/views/utils.js 2013-11-26 18:34:25 +0000
+++ app/views/utils.js 2013-11-27 17:14:10 +0000
@@ -1686,9 +1686,25 @@
      /*jshint debug:false */
    });

- Y.Handlebars.registerHelper('relationStatus', function(value, errors) {
- if (errors[value]) {
- return 'error';
+ // Returns 'error' if the relation in question is in error. Supports both
+ // normal and peer relations.
+ Y.Handlebars.registerHelper('relationStatus', function(relation, errors)
{
+ var serviceName = '';
+ if (!relation.far) { // It's a peer relation
+ serviceName = relation.near.service;
+ } else {
+ serviceName = relation.far.service;
+ }
+ if (errors[serviceName]) { return 'error'; }
+ });
+
+ // Returns the proper service name to support peer and normal relations
for
+ // the relations tab in the juju-gui.
+ Y.Handlebars.registerHelper('relationServiceName', function(relation) {
+ if (!relation.far) { // It's a peer relation
+ return relation.near.service;
+ } else {
+ return relation.far.service;
      }
    });

Revision history for this message
Benji York (benji) wrote :

This looks fine. They do need tests.

LGTM

https://codereview.appspot.com/34120044/diff/1/app/views/utils.js
File app/views/utils.js (right):

https://codereview.appspot.com/34120044/diff/1/app/views/utils.js#newcode1693
app/views/utils.js:1693: if (!relation.far) { // It's a peer relation
It would be a little clearer if the negation was removed from the
condition and the then/else clauses were swapped.

https://codereview.appspot.com/34120044/diff/1/app/views/utils.js#newcode1707
app/views/utils.js:1707: return relation.far.service;
I'm not too hung up on it, but the above code is duplicated from above.
Maybe there is a nice way to factor both copies into a third place.

https://codereview.appspot.com/34120044/

Revision history for this message
Jeff Pihach (hatch) wrote :

Thanks for the review - Changes made and tests will be submitted.

https://codereview.appspot.com/34120044/diff/1/app/views/utils.js
File app/views/utils.js (right):

https://codereview.appspot.com/34120044/diff/1/app/views/utils.js#newcode1693
app/views/utils.js:1693: if (!relation.far) { // It's a peer relation
On 2013/11/27 19:05:40, benji wrote:
> It would be a little clearer if the negation was removed from the
condition and
> the then/else clauses were swapped.

Done.

https://codereview.appspot.com/34120044/

Revision history for this message
Jeff Pihach (hatch) wrote :

*** Submitted:

Displays the relation name for peer relations

R=benji
CC=
https://codereview.appspot.com/34120044

https://codereview.appspot.com/34120044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/templates/service-relations-list.handlebars'
2--- app/templates/service-relations-list.handlebars 2013-11-26 18:34:25 +0000
3+++ app/templates/service-relations-list.handlebars 2013-11-27 19:01:05 +0000
4@@ -4,7 +4,9 @@
5 </div>
6 {{/unless}}
7 {{#relations}}
8- <div class="relation-label {{relationStatus far.service ../errors}}"><h3>{{far.service}}</h3></div>
9+ <div class="relation-label {{relationStatus . ../errors}}">
10+ <h3>{{relationServiceName .}}</h3>
11+ </div>
12 <h4>Interface: {{interface}}</h4>
13 <h4>Name: {{near.name}}</h4>
14 <h4>Role: {{near.role}}</h4>
15
16=== modified file 'app/views/utils.js'
17--- app/views/utils.js 2013-11-26 18:34:25 +0000
18+++ app/views/utils.js 2013-11-27 19:01:05 +0000
19@@ -1686,9 +1686,25 @@
20 /*jshint debug:false */
21 });
22
23- Y.Handlebars.registerHelper('relationStatus', function(value, errors) {
24- if (errors[value]) {
25- return 'error';
26+ // Returns 'error' if the relation in question is in error. Supports both
27+ // normal and peer relations.
28+ Y.Handlebars.registerHelper('relationStatus', function(relation, errors) {
29+ var serviceName = '';
30+ if (!relation.far) { // It's a peer relation
31+ serviceName = relation.near.service;
32+ } else {
33+ serviceName = relation.far.service;
34+ }
35+ if (errors[serviceName]) { return 'error'; }
36+ });
37+
38+ // Returns the proper service name to support peer and normal relations for
39+ // the relations tab in the juju-gui.
40+ Y.Handlebars.registerHelper('relationServiceName', function(relation) {
41+ if (!relation.far) { // It's a peer relation
42+ return relation.near.service;
43+ } else {
44+ return relation.far.service;
45 }
46 });
47

Subscribers

People subscribed via source and target branches