From 99ea28c3fd095eefa8d3b124a84c92015dcdb780 Mon Sep 17 00:00:00 2001 From: kialam Date: Fri, 1 Jun 2018 16:39:04 -0400 Subject: [PATCH 1/3] Check `defaults` against `query set` to make sure `credential_type` does not get overwritten - We want to preserve the existing `credential_type` param that already exists in `queryset` and not have `defaults ` overwrite it. We first loop through the `defaults` object keys and check it against the the keys of `queryset` and if the keys match, then set the value to `queryset[key]`. --- .../src/shared/smart-search/smart-search.controller.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index ad14dd5344..69b5ee9b02 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -235,11 +235,15 @@ function SmartSearchController ( }; $scope.clearAllTerms = () => { - const cleared = _(defaults).omit(_.isNull).value(); + const cleared = {}; - delete cleared.page; + _.forOwn(defaults, function(value, key) { + if (key !== "page") { + cleared[key] = _.has(queryset, key) ? queryset[key] : value; + } + }); - queryset = cleared; + queryset = _(cleared).omit(_.isNull).value(); if (!$scope.querySet) { $state.go('.', { [searchKey]: queryset }); From b344eb9af0092e0d4ad13c0365c1940d4ae8b4b0 Mon Sep 17 00:00:00 2001 From: kialam Date: Mon, 4 Jun 2018 12:05:18 -0400 Subject: [PATCH 2/3] Fix failing test by only preserving `credential_type` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reset `defaults` object’s own `credential_type` value to that of `queryset`’s. --- .../shared/smart-search/smart-search.controller.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index 69b5ee9b02..2ac0550a2b 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -235,15 +235,15 @@ function SmartSearchController ( }; $scope.clearAllTerms = () => { - const cleared = {}; - - _.forOwn(defaults, function(value, key) { - if (key !== "page") { - cleared[key] = _.has(queryset, key) ? queryset[key] : value; + _.forOwn(defaults, (value, key) => { + // preserve the `credential_type` queryset param if it exists + if (key === 'credential_type') { + defaults[key] = queryset[key]; } }); - - queryset = _(cleared).omit(_.isNull).value(); + const cleared = _(defaults).omit(_.isNull).value(); + delete cleared.page; + queryset = cleared; if (!$scope.querySet) { $state.go('.', { [searchKey]: queryset }); From 6fee8c699d724b6bb5be37fd5e0173b979580c77 Mon Sep 17 00:00:00 2001 From: kialam Date: Thu, 7 Jun 2018 10:35:51 -0400 Subject: [PATCH 3/3] Fix SCM credential list for Projects add and edit views --- awx/ui/client/src/shared/stateDefinitions.factory.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index a7a437ef11..8972b9c19a 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -880,7 +880,11 @@ function($injector, $stateExtender, $log, i18n) { $stateParams[`${list.iterator}_search`].role_level = "admin_role"; $stateParams[`${list.iterator}_search`].credential_type = InsightsCredTypePK.toString() ; } - + if(list.iterator === 'credential') { + if($state.current.name.includes('projects.edit') || $state.current.name.includes('projects.add')) { + state.params[`${list.iterator}_search`].value = _.merge(state.params[`${list.iterator}_search`].value, $stateParams[`${list.iterator}_search`]); + } + } return qs.search(path, $stateParams[`${list.iterator}_search`]); }