Ver código fonte

AMBARI-4837. Do not show Admin Access section on non-2.1 Stack. (Denys Buzhor via akovalenko)

Aleksandr Kovalenko 11 anos atrás
pai
commit
edd310c8bb

+ 22 - 1
ambari-web/app/controllers/main/admin.js

@@ -20,5 +20,26 @@ var App = require('app');
 
 App.MainAdminController = Em.Controller.extend({
   name: 'mainAdminController',
-  category: 'user'
+  category: 'user',
+  /**
+   * Check if access page available.
+   * Turn on if YARN service is installed with Application Timeline Server component and TEZ installed too.
+   *
+   * @type {Boolean}
+   */
+  isAccessAvailable: function() {
+    var dependencies = {
+      services: ['YARN', 'TEZ'],
+      components: ['APP_TIMELINE_SERVER']
+    };
+    var serviceNames = App.Service.find().mapProperty('serviceName')
+      .filter(function(serviceName) {
+        return dependencies.services.contains(serviceName);
+      });
+    var componentNames = App.get('stackDependedComponents').mapProperty('componentName')
+      .filter(function(componentName) {
+        return dependencies.components.contains(componentName);
+      });
+    return (dependencies.services.length == serviceNames.length && componentNames.length == 0);
+  }.property()
 });

+ 5 - 0
ambari-web/app/routes/main.js

@@ -546,6 +546,11 @@ module.exports = Em.Route.extend({
       }
     }),
     adminAccess: Em.Route.extend({
+      enter: function(router) {
+        Em.run.next(function() {
+          if (!router.get('mainAdminController.isAccessAvailable')) router.transitionTo('adminUser.allUsers');
+        });
+      },
       route: '/access',
       connectOutlets: function (router) {
         router.set('mainAdminController.category', "access");

+ 7 - 5
ambari-web/app/views/main/admin.js

@@ -51,11 +51,13 @@ App.MainAdminView = Em.View.extend({
       url: 'adminMisc',
       label: Em.I18n.t('common.misc')
     });
-    items.push({
-      name: 'access',
-      url: 'adminAccess',
-      label: Em.I18n.t('common.access')
-    });
+    if (this.get('controller.isAccessAvailable')) {
+      items.push({
+        name: 'access',
+        url: 'adminAccess',
+        label: Em.I18n.t('common.access')
+      });
+    }
     return items;
   }.property(''),