Selaa lähdekoodia

AMBARI-20194 - Enable/Disable UI objects related to managing alert targets based on user's privileges <fix1>(rzang)

Richard Zang 8 vuotta sitten
vanhempi
commit
b53fc82a71

+ 1 - 1
ambari-web/app/app.js

@@ -38,7 +38,7 @@ module.exports = Em.Application.create({
   isOperator: false,
   isOperator: false,
   isClusterUser: false,
   isClusterUser: false,
   isPermissionDataLoaded: false,
   isPermissionDataLoaded: false,
-  auth: null,
+  auth: undefined,
   isOnlyViewUser: function() {
   isOnlyViewUser: function() {
     return App.auth && (App.auth.length == 0 || (App.isAuthorized('VIEW.USE') && App.auth.length == 1));
     return App.auth && (App.auth.length == 0 || (App.isAuthorized('VIEW.USE') && App.auth.length == 1));
   }.property('auth'),
   }.property('auth'),

+ 1 - 1
ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js

@@ -57,7 +57,7 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({
       showDivider: false
       showDivider: false
     });
     });
     return content;
     return content;
-  }.property('App.supports.createAlerts'),
+  }.property('App.supports.createAlerts', 'App.auth'),
 
 
   /**
   /**
    * Common handler for menu item click
    * Common handler for menu item click

+ 2 - 3
ambari-web/app/templates/main/alerts/manage_alert_notifications_popup.hbs

@@ -32,16 +32,15 @@
           <div class="btn-toolbar pull-right">
           <div class="btn-toolbar pull-right">
             <button rel="button-info" class="btn add-notification-button"
             <button rel="button-info" class="btn add-notification-button"
               {{translateAttr data-original-title="alerts.actions.manage_alert_notifications_popup.addButton"}}
               {{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>
               {{action addAlertNotification target="controller"}}><i class="icon-plus"></i></button>
             <button rel="button-info" class="btn remove-notification-button"
             <button rel="button-info" class="btn remove-notification-button"
               {{translateAttr data-original-title="alerts.actions.manage_alert_notifications_popup.removeButton"}}
               {{translateAttr data-original-title="alerts.actions.manage_alert_notifications_popup.removeButton"}}
               {{bindAttr disabled="view.isRemoveButtonDisabled"}}
               {{bindAttr disabled="view.isRemoveButtonDisabled"}}
               {{action deleteAlertNotification target="controller"}}><i class="icon-minus"></i></button>
               {{action deleteAlertNotification target="controller"}}><i class="icon-minus"></i></button>
             <div class="btn-group notification-actions-button">
             <div class="btn-group notification-actions-button">
-              <button class="btn dropdown-toggle" data-toggle="dropdown" {{bindAttr disabled="view.isAddButtonDisabled"}}>
+              <button class="btn dropdown-toggle" data-toggle="dropdown">
                 <i class="icon-cog"></i>&nbsp;<span class="caret"></span>
                 <i class="icon-cog"></i>&nbsp;<span class="caret"></span>
-              </button>
+             </button>
               <ul class="dropdown-menu">
               <ul class="dropdown-menu">
                 <li {{bindAttr class="view.isEditButtonDisabled:disabled"}}>
                 <li {{bindAttr class="view.isEditButtonDisabled:disabled"}}>
                   <a href="" rel="button-info-dropdown"
                   <a href="" rel="button-info-dropdown"

+ 6 - 4
ambari-web/app/views/main/alerts/manage_alert_notifications_view.js

@@ -36,22 +36,24 @@ App.ManageAlertNotificationsView = Em.View.extend({
   /**
   /**
    * @type {boolean}
    * @type {boolean}
    */
    */
-  isAddButtonDisabled: Em.computed.alias('App.isOperator'),
+  isEditButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', '!controller.selectedAlertNotification.enabled'),
 
 
   /**
   /**
    * @type {boolean}
    * @type {boolean}
    */
    */
-  isEditButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'),
+
+  isRemoveButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected'),
 
 
   /**
   /**
    * @type {boolean}
    * @type {boolean}
    */
    */
-  isRemoveButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'),
+  isDuplicateButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', '!controller.selectedAlertNotification.enabled'),
 
 
   /**
   /**
    * @type {boolean}
    * @type {boolean}
    */
    */
-  isDuplicateButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected', 'App.isOperator'),
+
+  isEnableOrDisableButtonDisabled: Em.computed.or('!someAlertNotificationIsSelected'),
 
 
   /**
   /**
    * Show EMAIL information if selected alert notification has type EMAIL
    * Show EMAIL information if selected alert notification has type EMAIL

+ 0 - 14
ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js

@@ -224,20 +224,6 @@ describe('App.ManageAlertNotificationsView', function () {
         view.onLoad();
         view.onLoad();
         expect(view.get('selectedAlertNotification')).to.be.null;
         expect(view.get('selectedAlertNotification')).to.be.null;
       });
       });
-
-      it("isAddButtonDisabled should be true", function () {
-        view.set('isAddButtonDisabled', true);
-        App.set('isOperator', true);
-        view.onLoad();
-        expect(view.get('isAddButtonDisabled')).to.be.true;
-      });
-
-      it("isAddButtonDisabled should be false", function () {
-        view.set('isAddButtonDisabled', true);
-        App.set('isOperator', false);
-        view.onLoad();
-        expect(view.get('isAddButtonDisabled')).to.be.false;
-      });
     });
     });
 
 
     describe("controller.isLoaded is true, alertNotifications is array", function () {
     describe("controller.isLoaded is true, alertNotifications is array", function () {