mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 22:16:00 -03:30
Turned the activity stream button into a toggle and added a conditional tooltip for show/hide
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
export default
|
export default
|
||||||
['templateUrl', '$state', 'FeaturesService', 'ProcessErrors','$rootScope',
|
['templateUrl', '$state', 'FeaturesService', 'ProcessErrors','$rootScope', 'Store', 'Empty',
|
||||||
function(templateUrl, $state, FeaturesService, ProcessErrors, $rootScope) {
|
function(templateUrl, $state, FeaturesService, ProcessErrors, $rootScope, Store, Empty) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
||||||
@@ -13,22 +13,50 @@ export default
|
|||||||
|
|
||||||
scope.toggleActivityStream = function() {
|
scope.toggleActivityStream = function() {
|
||||||
|
|
||||||
var stateGoParams = {};
|
// If the user is not already on the activity stream then they want to navigate to it
|
||||||
|
if(!scope.activityStreamActive) {
|
||||||
|
var stateGoParams = {};
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
if(streamConfig.activityStreamTarget) {
|
if(streamConfig.activityStreamTarget) {
|
||||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||||
|
}
|
||||||
|
if(streamConfig.activityStreamId) {
|
||||||
|
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$state.go('activityStream', stateGoParams);
|
||||||
}
|
}
|
||||||
if(streamConfig.activityStreamId) {
|
// The user is navigating away from the activity stream - take them back from whence they came
|
||||||
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
else {
|
||||||
|
// Pull the previous state out of local storage
|
||||||
|
var previousState = Store('previous_state');
|
||||||
|
|
||||||
|
if(previousState && !Empty(previousState.name)) {
|
||||||
|
$state.go(previousState.name, previousState.fromParams);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If for some reason something went wrong (like local storage was wiped, etc) take the
|
||||||
|
// user back to the dashboard
|
||||||
|
$state.go('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.$on("$stateChangeStart", function updateActivityStreamButton(event, toState, toParams, fromState, fromParams) {
|
||||||
|
|
||||||
|
if(fromState && !Empty(fromState.name)) {
|
||||||
|
// Go ahead and attach the from params to the state object so that it can all be stored together
|
||||||
|
fromState.fromParams = fromParams ? fromParams : {};
|
||||||
|
|
||||||
|
// Store the state that we're coming from in local storage to be accessed when navigating away from the
|
||||||
|
// activity stream
|
||||||
|
Store('previous_state', fromState);
|
||||||
}
|
}
|
||||||
|
|
||||||
$state.go('activityStream', stateGoParams);
|
|
||||||
};
|
|
||||||
|
|
||||||
scope.$on("$stateChangeStart", function updateActivityStreamButton(event, toState) {
|
|
||||||
|
|
||||||
streamConfig = (toState && toState.data) ? toState.data : {};
|
streamConfig = (toState && toState.data) ? toState.data : {};
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
@@ -42,6 +70,7 @@ export default
|
|||||||
if(features){
|
if(features){
|
||||||
scope.loadingLicense = false;
|
scope.loadingLicense = false;
|
||||||
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
||||||
|
scope.activityStreamTooltip = (toState.name === 'activityStream') ? 'Hide Activity Stream' : 'View Activity Stream';
|
||||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name ==='activityStream') ? true : false;
|
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name ==='activityStream') ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,8 +86,9 @@ export default
|
|||||||
// var features = FeaturesService.get();
|
// var features = FeaturesService.get();
|
||||||
if(features){
|
if(features){
|
||||||
scope.loadingLicense = false;
|
scope.loadingLicense = false;
|
||||||
scope.activityStreamActive = ($state.name === 'activityStream') ? true : false;
|
scope.activityStreamActive = ($state.current.name === 'activityStream') ? true : false;
|
||||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.name ==='activityStream') ? true : false;
|
scope.activityStreamTooltip = ($state.current.name === 'activityStream') ? 'Hide Activity Stream' : 'View Activity Stream';
|
||||||
|
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.current.name ==='activityStream') ? true : false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<div ng-hide="licenseMissing" ncy-breadcrumb></div>
|
<div ng-hide="licenseMissing" ncy-breadcrumb></div>
|
||||||
<div class="BreadCrumb-menuLink"
|
<div class="BreadCrumb-menuLink"
|
||||||
id="bread_crumb_activity_stream"
|
id="bread_crumb_activity_stream"
|
||||||
aw-tool-tip="View Activity Stream"
|
aw-tool-tip="{{activityStreamTooltip}}"
|
||||||
|
data-tip-watch="activityStreamTooltip"
|
||||||
data-placement="left"
|
data-placement="left"
|
||||||
data-trigger="hover"
|
data-trigger="hover"
|
||||||
data-container="body"
|
data-container="body"
|
||||||
|
|||||||
Reference in New Issue
Block a user