From a58433ed9bad119a248cbf5a8efbcf01e947756c Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 16 Jan 2017 08:31:35 -0500 Subject: [PATCH 1/2] activity stream, display name of resource as title related to #4185 * When activity stream is gone to from a resource edit view, it should: * only show activity for the particular object * display the name of the resource as a title This commit patch half-ass does those two things. So what's missing? That questions is best answered by looking at how the feature behaves in tower 3.0.3. You'll notice that you are "locked" on the resource you are viewing the activity stream for. With this commit: * You aren't locked * The removal of the resource-id filter (smart-search) is borked. So what do we need to do?: * Lock the view to the resource being viewed How do we need to do it?: * router params.activity_search.values is a "static" thing. It is used to tell smart-search to not generate search tags. This is what we want to do. However, this is a contructor-only parameter. Further, the value "value" gets passed around to all sorts of other UI contructors that are hard to get access to when they are needed to try and dynamically set smart-search ignore search-tags. --- .../client/src/bread-crumb/bread-crumb.directive.js | 3 +++ .../client/src/shared/stateDefinitions.factory.js | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js index 7e58100ea0..3c64a0b701 100644 --- a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js +++ b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js @@ -47,6 +47,9 @@ export default order_by: '-timestamp', page_size: '20', }; + if (streamConfig.activityStreamTarget && streamConfig.activityStreamId) { + stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params[streamConfig.activityStreamId]; + } } else { stateGoParams.activity_search = { diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index 96e7493598..0d13e4ed7f 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -177,7 +177,7 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat break; case 'edit': url = params.urls && params.urls.edit ? params.urls.edit : (params.url ? params.url : `/:${form.name}_id`); - formNode = $stateExtender.buildDefinition({ + let formNodeState = { name: params.name || `${params.parent}.edit`, url: url, ncyBreadcrumb: { @@ -215,8 +215,15 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat return Rest.get(); } ] - } - }); + }, + }; + if (params.data && params.data.activityStreamTarget) { + formNodeState.data = {}; + formNodeState.data.activityStreamId = params.data.activityStreamTarget + '_id'; + + } + formNode = $stateExtender.buildDefinition(formNodeState); + if (params.resolve && params.resolve.edit) { formNode.resolve = _.merge(formNode.resolve, params.resolve.edit); } From 2088b1fcfe811d90b0553a282e54a76fc0feca13 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 16 Jan 2017 11:07:38 -0500 Subject: [PATCH 2/2] omit search-tags dynamically --- .../activity-stream/activitystream.controller.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/awx/ui/client/src/activity-stream/activitystream.controller.js b/awx/ui/client/src/activity-stream/activitystream.controller.js index 05609d3bc5..ada72d572c 100644 --- a/awx/ui/client/src/activity-stream/activitystream.controller.js +++ b/awx/ui/client/src/activity-stream/activitystream.controller.js @@ -12,6 +12,7 @@ function activityStreamController($scope, $state, subTitle, Stream, GetTargetTitle, list, Dataset) { init(); + initOmitSmartTags(); function init() { // search init @@ -33,6 +34,20 @@ function activityStreamController($scope, $state, subTitle, Stream, GetTargetTit }); } + // Specification of smart-tags omission from the UI is done in the route/state init. + // A limitation is that this specficiation is static and the key for which to be omitted from + // the smart-tags must be known at that time. + // In the case of activity stream, we won't to dynamically ommit the resource for which we are + // displaying the activity stream for. i.e. 'project', 'credential', etc. + function initOmitSmartTags() { + let defaults, route = _.find($state.$current.path, (step) => { + return step.params.hasOwnProperty('activity_search'); + }); + if (route && $state.params.target !== undefined) { + defaults = route.params.activity_search.config.value; + defaults[$state.params.target] = null; + } + } } export default ['$scope', '$state', 'subTitle', 'Stream', 'GetTargetTitle', 'StreamList', 'Dataset', activityStreamController];