mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 16:47:45 -02:30
Merge pull request #960 from mabashian/stream-awfeature
Hide Activity Stream button when the feature is turned off
This commit is contained in:
@@ -15,6 +15,27 @@ export default {
|
|||||||
label: "ACTIVITY STREAM"
|
label: "ACTIVITY STREAM"
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
features: ['FeaturesService', 'ProcessErrors', '$state', function(FeaturesService, ProcessErrors, $state) {
|
||||||
|
FeaturesService.get()
|
||||||
|
.then(function(features) {
|
||||||
|
if(FeaturesService.featureEnabled('activity_streams')) {
|
||||||
|
// Good to go - pass the features along to the controller.
|
||||||
|
return features;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// The activity stream feature isn't enabled. Take the user
|
||||||
|
// back to the dashboard
|
||||||
|
$state.go('dashboard');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get feature info. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}],
|
||||||
subTitle:
|
subTitle:
|
||||||
[ '$stateParams',
|
[ '$stateParams',
|
||||||
'Rest',
|
'Rest',
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
/* jshint unused: vars */
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
[ 'templateUrl', '$state', function(templateUrl, $state) {
|
[ 'templateUrl', '$state', 'FeaturesService', 'ProcessErrors', function(templateUrl, $state, FeaturesService, ProcessErrors) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
||||||
@@ -32,11 +30,36 @@ export default
|
|||||||
streamConfig = (toState && toState.data) ? toState.data : {};
|
streamConfig = (toState && toState.data) ? toState.data : {};
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
|
|
||||||
|
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
||||||
|
// after the resolve on the state declaration so features should be available at this
|
||||||
|
// point. We use the get() function call here just in case the features aren't available.
|
||||||
|
// The get() function will only fire off the server call if the features aren't already
|
||||||
|
// attached to the $rootScope.
|
||||||
|
|
||||||
|
FeaturesService.get()
|
||||||
|
.then(function(features) {
|
||||||
|
if(FeaturesService.featureEnabled('activity_streams')) {
|
||||||
scope.showActivityStreamButton = true;
|
scope.showActivityStreamButton = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope.showActivityStreamButton = false;
|
scope.showActivityStreamButton = false;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(function (response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get feature info. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
scope.showActivityStreamButton = false;
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q) {
|
|||||||
// as a resovled promise.
|
// as a resovled promise.
|
||||||
return $q.when($rootScope.features);
|
return $q.when($rootScope.features);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
featureEnabled: function(feature) {
|
||||||
|
if($rootScope.features && $rootScope.features[feature] && $rootScope.features[feature] == true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user