← Back to team overview

yellow team mailing list archive

[Merge] lp:~makyo/juju-gui/no-remove-sub-rels into lp:juju-gui

 

Matthew Scott has proposed merging lp:~makyo/juju-gui/no-remove-sub-rels into lp:juju-gui.

Requested reviews:
  Juju GUI Hackers (juju-gui)

For more details, see:
https://code.launchpad.net/~makyo/juju-gui/no-remove-sub-rels/+merge/134495

Remove ability to remove subordinate relations.

Attempting to remove a subordinate relation through the standard means will warn that it's not possible and not let the user remove the relation.

https://codereview.appspot.com/6846060/

-- 
https://code.launchpad.net/~makyo/juju-gui/no-remove-sub-rels/+merge/134495
Your team Juju GUI Hackers is requested to review the proposed merge of lp:~makyo/juju-gui/no-remove-sub-rels into lp:juju-gui.
=== modified file 'app/templates/overview.handlebars'
--- app/templates/overview.handlebars	2012-10-27 20:06:21 +0000
+++ app/templates/overview.handlebars	2012-11-15 15:57:46 +0000
@@ -50,4 +50,6 @@
             Destroy
         </div>
     </div>
+    <div id="rmrelation-modal-panel"></div>
+    <div id="rmsubrelation-modal-panel"></div>
 </div>

=== modified file 'app/views/environment.js'
--- app/views/environment.js	2012-11-13 21:51:29 +0000
+++ app/views/environment.js	2012-11-15 15:57:46 +0000
@@ -434,7 +434,29 @@
         },
 
         relationClick: function(d, self) {
-          self.removeRelationConfirm(d, this, self);
+          if (d.scope === 'container') {
+            var subRelDialog = views.createModalPanel(
+                'You may not remove a subordinate relation.',
+                '#rmsubrelation-modal-panel');
+            subRelDialog.addButton(
+                { value: 'Cancel',
+                  section: Y.WidgetStdMod.FOOTER,
+                  /**
+                   * @method action Hides the dialog on click.
+                   * @param {object} e The click event.
+                   * @return {undefined} nothing.
+                   */
+                  action: function(e) {
+                    e.preventDefault();
+                    subRelDialog.hide();
+                  },
+                  classNames: ['btn']
+                });
+            subRelDialog.get('boundingBox').all('.yui3-button')
+                .removeClass('yui5-button');
+          } else {
+            self.removeRelationConfirm(d, this, self);
+          }
         },
 
         /**

=== modified file 'test/test_environment_view.js'
--- test/test_environment_view.js	2012-11-13 21:51:29 +0000
+++ test/test_environment_view.js	2012-11-15 15:57:46 +0000
@@ -369,12 +369,17 @@
            db: db,
            env: env}).render();
 
-         var relation = container.one('.rel-label'),
+         var relation = container.one('#relation-0000000001 .rel-label'),
          dialog_btn,
          panel;
 
          relation.simulate('click');
-         panel = Y.one('.yui3-panel');
+         panel = Y.one('#rmrelation-modal-panel');
+
+         // There should be a 'remove relation' button and a 'cancel' button
+         // on the dialog.
+         panel.all('button').size().should.equal(2);
+
          dialog_btn = panel.one('.btn-danger');
          dialog_btn.simulate('click');
          container.all('.to-remove')
@@ -383,6 +388,28 @@
          view.get('rmrelation_dialog').hide();
        });
 
+    it('must not allow removing a subordinate relation between services',
+        function() {
+         var view = new views.environment({
+           container: container,
+           db: db,
+           env: env}).render();
+
+         // Get a subordinate relation.
+         var relation = container.one('#relation-0000000007 .rel-label'),
+         dialog_btn,
+         panel;
+
+         relation.simulate('click');
+         panel = Y.one('#rmsubrelation-modal-panel');
+
+         // There should only be a cancel button on the warning dialog.
+         panel.all('button').size().should.equal(1);
+
+         // Clicking cancel will hide the dialog.
+         panel.one('button').simulate('click');
+        });
+
     it('should stop creating a relation if the background is clicked',
         function() {
           var db = new models.Database(),


Follow ups