AMBARI-17936 Log search tab seems to be visible for all user roles (zhewang)
diff --git a/ambari-web/app/views/main/host/menu.js b/ambari-web/app/views/main/host/menu.js
index 07d9def..b3c52f4 100644
--- a/ambari-web/app/views/main/host/menu.js
+++ b/ambari-web/app/views/main/host/menu.js
@@ -58,7 +58,7 @@
routing: 'logs',
hidden: function () {
if (App.get('supports.logSearch')) {
- return !(App.Service.find().someProperty('serviceName', 'LOGSEARCH') && !App.get('isClusterUser'));
+ return !(App.Service.find().someProperty('serviceName', 'LOGSEARCH') && App.isAuthorized('SERVICE.VIEW_OPERATIONAL_LOGS'));
}
return true;
}.property('App.supports.logSearch'),
diff --git a/ambari-web/test/views/main/host/menu_test.js b/ambari-web/test/views/main/host/menu_test.js
index f7d35a4..0938a9a 100644
--- a/ambari-web/test/views/main/host/menu_test.js
+++ b/ambari-web/test/views/main/host/menu_test.js
@@ -30,12 +30,13 @@
beforeEach(function () {
this.mock = sinon.stub(App, 'get');
this.serviceMock = sinon.stub(App.Service, 'find');
- this.clusterUserMock = this.mock.withArgs('isClusterUser');
+ this.authMock = sinon.stub(App, 'isAuthorized');
});
afterEach(function () {
App.get.restore();
App.Service.find.restore();
+ App.isAuthorized.restore();
});
Em.A([
@@ -61,28 +62,28 @@
{
logSearch: false,
services: [{serviceName: 'LOGSEARCH'}],
- isClusterUser: false,
+ auth: true,
m: '`logs` tab is invisible',
e: true
},
{
logSearch: true,
services: [],
- isClusterUser: false,
+ auth: true,
m: '`logs` tab is invisible because service not installed',
e: true
},
{
logSearch: true,
services: [{serviceName: 'LOGSEARCH'}],
- isClusterUser: false,
+ auth: true,
m: '`logs` tab is visible',
e: false
},
{
logSearch: true,
services: [{serviceName: 'LOGSEARCH'}],
- isClusterUser: true,
+ auth: false,
m: '`logs` tab is hidden because user has no access',
e: true
}
@@ -90,7 +91,7 @@
it(test.m, function() {
this.mock.withArgs('supports.logSearch').returns(test.logSearch);
this.serviceMock.returns(test.services);
- this.clusterUserMock.returns(test.isClusterUser);
+ this.authMock.returns(test.auth);
view.propertyDidChange('content');
expect(view.get('content').findProperty('name', 'logs').get('hidden')).to.equal(test.e);
});