ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-13347. Alert notification create/edit/duplicate menu items should be disabled for non-admin users. (Sangeeta Ravindran via yusaku)
Date Mon, 09 Nov 2015 22:21:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c715189ab -> d7a965535


AMBARI-13347. Alert notification create/edit/duplicate menu items should be disabled for non-admin
users. (Sangeeta Ravindran via yusaku)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d7a96553
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d7a96553
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d7a96553

Branch: refs/heads/trunk
Commit: d7a9655350126d2958382a5095b9499bf450bf07
Parents: c715189
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Mon Nov 9 14:21:06 2015 -0800
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Mon Nov 9 14:21:06 2015 -0800

----------------------------------------------------------------------
 .../alerts/manage_alert_notifications_popup.hbs |  3 +-
 .../alerts/manage_alert_notifications_view.js   | 13 ++++--
 .../manage_alert_notifications_view_test.js     | 45 +++++++++++++++++++-
 3 files changed, 55 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d7a96553/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
index b0fa709..3581f12 100644
--- a/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
+++ b/ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs
@@ -32,13 +32,14 @@
           <div class="btn-toolbar pull-right">
             <button rel="button-info" class="btn add-notification-button"
               {{translateAttr data-original-title="alerts.actions.manage_alert_notifications_popup.addButton"}}
+              {{bindAttr disabled="view.isAddButtonDisabled"}}
               {{action addAlertNotification target="controller"}}><i class="icon-plus"></i></button>
             <button rel="button-info" class="btn remove-notification-button"
               {{translateAttr data-original-title="alerts.actions.manage_alert_notifications_popup.removeButton"}}
               {{bindAttr disabled="view.isRemoveButtonDisabled"}}
               {{action deleteAlertNotification target="controller"}}><i class="icon-minus"></i></button>
             <div class="btn-group notification-actions-button">
-              <button class="btn dropdown-toggle" data-toggle="dropdown">
+              <button class="btn dropdown-toggle" data-toggle="dropdown" {{bindAttr disabled="view.isAddButtonDisabled"}}>
                 <i class="icon-cog"></i>&nbsp;<span class="caret"></span>
               </button>
               <ul class="dropdown-menu">

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7a96553/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
index ff55ae9..4672662 100644
--- a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
+++ b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js
@@ -31,6 +31,8 @@ App.ManageAlertNotificationsView = Em.View.extend({
     return this.get('controller.selectedAlertNotification.groups').toArray().mapProperty('displayName').join(',
');
   }.property('controller.selectedAlertNotification', 'controller.selectedAlertNotification.groups.@each',
'controller.isLoaded'),
 
+  isAddButtonDisabled: true,
+
   isEditButtonDisabled: true,
 
   isRemoveButtonDisabled: true,
@@ -67,9 +69,10 @@ App.ManageAlertNotificationsView = Em.View.extend({
    */
   buttonObserver: function () {
     var selectedAlertNotification = this.get('controller.selectedAlertNotification');
-    this.set('isEditButtonDisabled', !selectedAlertNotification);
-    this.set('isRemoveButtonDisabled', !selectedAlertNotification);
-    this.set('isDuplicateButtonDisabled', !selectedAlertNotification);
+    this.set('isAddButtonDisabled', (!selectedAlertNotification || App.isOperator));
+    this.set('isEditButtonDisabled', (!selectedAlertNotification || App.isOperator));
+    this.set('isRemoveButtonDisabled', (!selectedAlertNotification || App.isOperator));
+    this.set('isDuplicateButtonDisabled', (!selectedAlertNotification || App.isOperator));
   }.observes('controller.selectedAlertNotification'),
 
   /**
@@ -98,6 +101,10 @@ App.ManageAlertNotificationsView = Em.View.extend({
         this.set('selectedAlertNotification', this.get('controller.selectedAlertNotification')
|| notifications[0]);
         this.buttonObserver();
       }  else {
+        if(!App.isOperator)
+	 {
+	    this.set('isAddButtonDisabled',false);
+	 }
         this.set('selectedAlertNotification', null);
       }
       Em.run.later(this, function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7a96553/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
index a2822ce..6e8b993 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
@@ -34,28 +34,68 @@ describe('App.ManageAlertNotificationsView', function () {
 
     Em.A([
       {
+	 isOperator: false,
         selectedAlertNotification: {id: 1},
-        m: 'some alert notification is selected',
+        m: 'some alert notification is selected and user is an admin',
         p: {
+          isAddButtonDisabled: true,
           isEditButtonDisabled: true,
           isRemoveButtonDisabled: true,
           isDuplicateButtonDisabled: true
         },
         e:  {
+          isAddButtonDisabled: false,
           isEditButtonDisabled: false,
           isRemoveButtonDisabled: false,
           isDuplicateButtonDisabled: false
         }
       },
       {
+        isOperator: true,
+        selectedAlertNotification: {id: 1},
+        m: 'some alert notification is selected and user is a non-admin operator',
+        p: {
+          isAddButtonDisabled: true,
+          isEditButtonDisabled: true,
+          isRemoveButtonDisabled: true,
+          isDuplicateButtonDisabled: true
+        },
+        e:  {
+          isAddButtonDisabled: true,
+          isEditButtonDisabled: true,
+          isRemoveButtonDisabled: true,
+          isDuplicateButtonDisabled: true
+        }
+      },
+      {
+        isOperator: false,
         selectedAlertNotification: null,
-        m: 'some alert notification is not selected',
+        m: 'some alert notification is not selected and user is an admin',
+        p: {
+          isAddButtonDisabled: true,
+          isEditButtonDisabled: false,
+          isRemoveButtonDisabled: false,
+          isDuplicateButtonDisabled: false
+        },
+        e:  {
+          isAddButtonDisabled: true,
+          isEditButtonDisabled: true,
+          isRemoveButtonDisabled: true,
+          isDuplicateButtonDisabled: true
+        }
+      },
+      {
+        isOperator: true,
+        selectedAlertNotification: null,        
+        m: 'some alert notification is not selected and user is a non-admin operator',
         p: {
+	   isAddButtonDisabled: true,
           isEditButtonDisabled: false,
           isRemoveButtonDisabled: false,
           isDuplicateButtonDisabled: false
         },
         e:  {
+          isAddButtonDisabled: true,
           isEditButtonDisabled: true,
           isRemoveButtonDisabled: true,
           isDuplicateButtonDisabled: true
@@ -67,6 +107,7 @@ describe('App.ManageAlertNotificationsView', function () {
             view.set(k, test.p[k]);
           });
           view.set('controller.selectedAlertNotification', test.selectedAlertNotification);
+          App.isOperator=test.isOperator;
           view.buttonObserver();
           Em.keys(test.e).forEach(function (k) {
             expect(view.get(k)).to.equal(test.e[k]);


Mime
View raw message