From 33b411a66d046e2faa204b95902c07352c4757a6 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 3 Jul 2017 12:05:01 -0400 Subject: [PATCH 1/2] Fixed console error when switching source type back to Choose a source --- .../sources/add/sources-add.controller.js | 1 + .../sources/edit/sources-edit.controller.js | 33 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 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 b153d4bdad..8a4e609784 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 @@ -144,6 +144,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', varName = source + '_variables'; } + $scope[varName] = $scope[varName] === (null || undefined) ? '---' : $scope[varName]; ParseTypeChange({ scope: $scope, field_id: varName, 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 8fe3e05e08..5fec22bc2a 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 @@ -341,13 +341,20 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', }; $scope.sourceChange = function(source) { - $scope.source = source; + if (source) { + source = source.value; + } else { + source = ""; + } - source = source.value; + $scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network'; - if (source === 'ec2' || source === 'custom' || - source === 'vmware' || source === 'openstack' || - source === 'scm') { + if (source === 'custom'){ + $scope.credentialBasePath = GetBasePath('inventory_script'); + } + + if (source === 'ec2' || source === 'custom' || source === 'vmware' || source === 'openstack' || source === 'scm') { + $scope.envParseType = 'yaml'; var varName; if (source === 'scm') { @@ -361,18 +368,26 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', scope: $scope, field_id: varName, variable: varName, - parse_variable: 'envParseType', + parse_variable: 'envParseType' }); } + + if (source === 'scm') { + $scope.overwrite_vars = true; + $scope.inventory_source_form.inventory_file.$setPristine(); + } else { + $scope.overwrite_vars = false; + } + // reset fields + $scope.group_by_choices = source === 'ec2' ? $scope.ec2_group_by : null; // azure_rm regions choices are keyed as "azure" in an OPTIONS request to the inventory_sources endpoint - $scope.source_region_choices = source.value === 'azure_rm' ? $scope.azure_regions : $scope[source.value + '_regions']; - $scope.cloudCredentialRequired = source.value !== '' && source.value !== 'custom' && source.value !== 'scm' && source.value !== 'ec2' ? true : false; + $scope.source_region_choices = source === 'azure_rm' ? $scope.azure_regions : $scope[source + '_regions']; + $scope.cloudCredentialRequired = source !== '' && source !== 'scm' && source !== 'custom' && source !== 'ec2' ? true : false; $scope.group_by = null; $scope.source_regions = null; $scope.credential = null; $scope.credential_name = null; - initRegionSelect(); }; From c2b552b3b2b31d1d7629e7d07b7cad3b62eda5f8 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Thu, 6 Jul 2017 12:01:46 -0400 Subject: [PATCH 2/2] Removed erroneous credential basepath line --- .../inventories/related/sources/add/sources-add.controller.js | 4 ---- .../related/sources/edit/sources-edit.controller.js | 4 ---- 2 files changed, 8 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 8a4e609784..e49f661884 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 @@ -130,10 +130,6 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', $scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network'; - if (source === 'custom'){ - $scope.credentialBasePath = GetBasePath('inventory_script'); - } - if (source === 'ec2' || source === 'custom' || source === 'vmware' || source === 'openstack' || source === 'scm') { $scope.envParseType = 'yaml'; 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 5fec22bc2a..e9f953e4a0 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 @@ -349,10 +349,6 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', $scope.credentialBasePath = GetBasePath('credentials') + '?credential_type__kind__in=cloud,network'; - if (source === 'custom'){ - $scope.credentialBasePath = GetBasePath('inventory_script'); - } - if (source === 'ec2' || source === 'custom' || source === 'vmware' || source === 'openstack' || source === 'scm') { $scope.envParseType = 'yaml';