From 78851213a345be894f16c526fc8414580e6759c9 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Wed, 19 Jul 2017 11:09:46 -0400 Subject: [PATCH 1/2] Fix scm inv source credential lookup --- .../sources/add/sources-add.controller.js | 27 +++++++++++++------ .../sources/edit/sources-edit.controller.js | 27 +++++++++++++------ .../lookup/sources-lookup-credential.route.js | 3 ++- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js index 7d85d08a9a..c6d6b1de64 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js @@ -71,14 +71,25 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', } $scope.lookupCredential = function(){ - let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; - $state.go('.credential', { - credential_search: { - kind: kind, - page_size: '5', - page: '1' - } - }); + if($scope.source.value !== "scm") { + let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; + $state.go('.credential', { + credential_search: { + kind: kind, + page_size: '5', + page: '1' + } + }); + } + else { + $state.go('.credential', { + credential_search: { + credential_type__kind: "cloud", + page_size: '5', + page: '1' + } + }); + } }; $scope.lookupProject = function(){ diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js index 778368e88b..e570f4c2a5 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js @@ -300,14 +300,25 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', }; $scope.lookupCredential = function(){ - let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; - $state.go('.credential', { - credential_search: { - kind: kind, - page_size: '5', - page: '1' - } - }); + if($scope.source.value !== "scm") { + let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; + $state.go('.credential', { + credential_search: { + kind: kind, + page_size: '5', + page: '1' + } + }); + } + else { + $state.go('.credential', { + credential_search: { + credential_type__kind: "cloud", + page_size: '5', + page: '1' + } + }); + } }; $scope.formCancel = function() { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/lookup/sources-lookup-credential.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/lookup/sources-lookup-credential.route.js index fa12eb8cc1..b80e65c1c9 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/lookup/sources-lookup-credential.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/lookup/sources-lookup-credential.route.js @@ -5,7 +5,8 @@ export default { page_size:"5", order_by:"name", role_level:"use_role", - kind: null + kind: null, + credential_type__kind: null }, dynamic:true, squash:"" From 7d39f86d84a539bdbea1fb3a7056f76b617ca491 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Thu, 20 Jul 2017 10:01:54 -0400 Subject: [PATCH 2/2] Expose credential when adding/editing custom source --- .../inventories/related/sources/add/sources-add.controller.js | 2 +- .../inventories/related/sources/edit/sources-edit.controller.js | 2 +- .../inventories/related/sources/sources.form.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js index c6d6b1de64..742a9bbf91 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js @@ -71,7 +71,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', } $scope.lookupCredential = function(){ - if($scope.source.value !== "scm") { + if($scope.source.value !== "scm" && $scope.source.value !== "custom") { let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; $state.go('.credential', { credential_search: { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js index e570f4c2a5..3ca385d1ea 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.controller.js @@ -300,7 +300,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', }; $scope.lookupCredential = function(){ - if($scope.source.value !== "scm") { + if($scope.source.value !== "scm" && $scope.source.value !== "custom") { let kind = ($scope.source.value === "ec2") ? "aws" : $scope.source.value; $state.go('.credential', { credential_search: { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js index 2159fb4ddb..8cd403a921 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.form.js @@ -71,7 +71,7 @@ return { type: 'lookup', list: 'CredentialList', basePath: 'credentials', - ngShow: "source && source.value !== '' && source.value !== 'custom'", + ngShow: "source && source.value !== ''", sourceModel: 'credential', sourceField: 'name', ngClick: 'lookupCredential()',