~gary/juju-gui/fixsavetext

« back to all changes in this revision

Viewing changes to app/store/env/sandbox.js

  • Committer: Matthew Scott
  • Date: 2013-09-03 10:07:13 UTC
  • mfrom: (992.2.7 go-relations)
  • Revision ID: matthew.scott@canonical.com-20130903100713-2snoco2crgtucpqv
Fix go relations in sandbox

Go relations now working in sandbox.  This finally actually really totally checks in changing the environment type, as well.

R=rharding, jeff.pihach
CC=
https://codereview.appspot.com/13335048

Show diffs side-by-side

added added

removed removed

Lines of Context:
651
651
    */
652
652
    performOp_add_relation: function(data) {
653
653
      var relation = this.get('state').addRelation(
654
 
          data.endpoint_a, data.endpoint_b);
 
654
          data.endpoint_a, data.endpoint_b, true);
655
655
 
656
656
      if (relation === false) {
657
657
        // If everything checks out but could not create a new relation model
870
870
      },
871
871
      relation: {
872
872
        Key: 'relation_id',
873
 
        'Endpoints': function() {}
 
873
        'Endpoints': function(relation, goAPI) {
 
874
          var result = [];
 
875
          if (relation.endpoints.length === 1) {
 
876
            return;
 
877
          }
 
878
          relation.endpoints.forEach(function(endpoint, index) {
 
879
            result.push({
 
880
              Relation: {
 
881
                Name: endpoint[1].name,
 
882
                Role: (index) ? 'server' : 'client',
 
883
                Interface: relation.type,
 
884
                Scope: relation.scope
 
885
              },
 
886
              ServiceName: endpoint[0]
 
887
            });
 
888
          });
 
889
          return result;
 
890
        }
874
891
      },
875
892
      annotation: {
876
893
        'Tag': function() {
1243
1260
    */
1244
1261
    handleClientAddRelation: function(data, client, state) {
1245
1262
      var stateData = state.addRelation(
1246
 
          data.Params.Endpoints[0], data.Params.Endpoints[1]);
 
1263
          data.Params.Endpoints[0], data.Params.Endpoints[1], false);
1247
1264
      var resp = {RequestId: data.RequestId};
1248
1265
      if (stateData === false) {
1249
1266
        // Everything checks out but could not create a new relation model.
1261
1278
          stateEpB = stateData.endpoints[1],
1262
1279
          epA = {
1263
1280
            Name: stateEpA[1].name,
1264
 
            Role: stateEpA[1].role,
 
1281
            Role: 'requirer',
1265
1282
            Scope: stateData.scope,
1266
1283
            Interface: stateData['interface']
1267
1284
          },
1268
1285
          epB = {
1269
1286
            Name: stateEpB[1].name,
1270
 
            Role: stateEpB[1].role,
 
1287
            Role: 'provider',
1271
1288
            Scope: stateData.scope,
1272
1289
            Interface: stateData['interface']
1273
1290
          };