From 95da197bac36714ec0fc0a091485a0a58e9a582e Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 12 Jun 2017 15:29:49 -0400 Subject: [PATCH] Remove ask_extra_credentials_on_launch in the UI. Everything will run through ask_credential_on_launch --- .../launchjob.factory.js | 9 ++-- .../job-submission.controller.js | 50 +++++++++---------- .../job-submission.directive.js | 2 +- .../job-submission.partial.html | 10 ++-- .../client/src/templates/job-template.form.js | 4 -- .../job-template-add.controller.js | 8 +-- .../job-template-edit.controller.js | 6 --- 7 files changed, 36 insertions(+), 53 deletions(-) diff --git a/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js b/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js index fc26bf7cb2..5bc55d1173 100644 --- a/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js +++ b/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js @@ -111,11 +111,10 @@ export default } // include the credential used if the user was prompted to choose a cred - if(scope.ask_credential_on_launch && !Empty(scope.selected_credentials.machine)){ - job_launch_data.credential_id = scope.selected_credentials.machine.id; - } - - if(scope.ask_extra_credentials_on_launch){ + if(scope.ask_credential_on_launch){ + if(!Empty(scope.selected_credentials.machine)) { + job_launch_data.credential_id = scope.selected_credentials.machine.id; + } job_launch_data.extra_credentials = []; scope.selected_credentials.extra.forEach((extraCredential) => { job_launch_data.extra_credentials.push(extraCredential.id); diff --git a/awx/ui/client/src/job-submission/job-submission.controller.js b/awx/ui/client/src/job-submission/job-submission.controller.js index 3c9d7791c8..e4bfc4c245 100644 --- a/awx/ui/client/src/job-submission/job-submission.controller.js +++ b/awx/ui/client/src/job-submission/job-submission.controller.js @@ -240,30 +240,11 @@ export default $scope.selected_credentials.machine = angular.copy($scope.defaults.credential); } - if($scope.ask_extra_credentials_on_launch) { - // Go out and get the credential types - Rest.setUrl(GetBasePath('credential_types')); - Rest.get() - .success(function (credentialTypeData) { - let credential_types = {}; - $scope.credentialKindOptions = []; - credentialTypeData.results.forEach((credentialType => { - credential_types[credentialType.id] = credentialType; - if(($scope.ask_credential_on_launch || (!$scope.ask_credential_on_launch && credentialType.id !== 1)) && credentialType.kind.match(/^(cloud|network|ssh)$/)) { - $scope.credentialKindOptions.push({ - name: credentialType.name, - value: credentialType.id - }); - } - })); - $scope.credential_types = credential_types; - if($scope.has_default_extra_credentials) { - $scope.selected_credentials.extra = angular.copy($scope.defaults.extra_credentials); - } - }); + if($scope.has_default_extra_credentials) { + $scope.selected_credentials.extra = angular.copy($scope.defaults.extra_credentials); } - if( ($scope.submitJobType === 'workflow_job_template' && !$scope.survey_enabled) || ($scope.submitJobRelaunch && !$scope.password_needed) || (!$scope.submitJobRelaunch && $scope.can_start_without_user_input && !$scope.ask_inventory_on_launch && !$scope.ask_credential_on_launch && !$scope.ask_extra_credentials_on_launch && !$scope.has_other_prompts && !$scope.survey_enabled)) { + if( ($scope.submitJobType === 'workflow_job_template' && !$scope.survey_enabled) || ($scope.submitJobRelaunch && !$scope.password_needed) || (!$scope.submitJobRelaunch && $scope.can_start_without_user_input && !$scope.ask_inventory_on_launch && !$scope.ask_credential_on_launch && !$scope.has_other_prompts && !$scope.survey_enabled)) { // The job can be launched if // a) It's a relaunch and no passwords are needed // or @@ -274,11 +255,30 @@ export default else { var initiateModal = function() { + + // Go out and get the credential types + Rest.setUrl(GetBasePath('credential_types')); + Rest.get() + .success(function (credentialTypeData) { + let credential_types = {}; + $scope.credentialTypeOptions = []; + credentialTypeData.results.forEach((credentialType => { + credential_types[credentialType.id] = credentialType; + if(credentialType.kind.match(/^(machine|cloud|network|ssh)$/)) { + $scope.credentialTypeOptions.push({ + name: credentialType.name, + value: credentialType.id + }); + } + })); + $scope.credential_types = credential_types; + }); + // Figure out which step the user needs to start on if($scope.ask_inventory_on_launch) { $scope.setStep("inventory", true); } - else if($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed) { + else if($scope.ask_credential_on_launch || $scope.password_needed) { $scope.setStep("credential", true); } else if($scope.has_other_prompts) { @@ -399,7 +399,7 @@ export default $scope.getActionButtonText = function() { if($scope.step === "inventory") { - return ($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed || $scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH"; + return ($scope.ask_credential_on_launch || $scope.password_needed || $scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH"; } else if($scope.step === "credential") { return ($scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH"; @@ -457,7 +457,7 @@ export default $scope.takeAction = function() { if($scope.step === "inventory") { // Check to see if there's another step after this one - if($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed) { + if($scope.ask_credential_on_launch || $scope.password_needed) { $scope.setStep("credential"); } else if($scope.has_other_prompts) { diff --git a/awx/ui/client/src/job-submission/job-submission.directive.js b/awx/ui/client/src/job-submission/job-submission.directive.js index e4108124cf..88a8cfe42f 100644 --- a/awx/ui/client/src/job-submission/job-submission.directive.js +++ b/awx/ui/client/src/job-submission/job-submission.directive.js @@ -28,7 +28,7 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT if(scope.ask_inventory_on_launch) { scope.includeInventoryList = true; } - if(scope.ask_credential_on_launch || scope.ask_extra_credentials_on_launch) { + if(scope.ask_credential_on_launch) { scope.credentialKind = (scope.ask_credential_on_launch) ? "1" : "5"; scope.includeCredentialList = true; diff --git a/awx/ui/client/src/job-submission/job-submission.partial.html b/awx/ui/client/src/job-submission/job-submission.partial.html index 3cdcb2077a..96f3071664 100644 --- a/awx/ui/client/src/job-submission/job-submission.partial.html +++ b/awx/ui/client/src/job-submission/job-submission.partial.html @@ -15,7 +15,7 @@
Inventory
-
Credential
+
Credential
Other Prompts
Survey
@@ -36,7 +36,7 @@
-
+
@@ -52,17 +52,17 @@ {{extraCredential.name}}{{$last ? '' : ', '}} None selected - + REVERT
-
+
CREDENTIAL TYPE:
diff --git a/awx/ui/client/src/templates/job-template.form.js b/awx/ui/client/src/templates/job-template.form.js index a25d42eae4..9aa50f0505 100644 --- a/awx/ui/client/src/templates/job-template.form.js +++ b/awx/ui/client/src/templates/job-template.form.js @@ -93,10 +93,6 @@ function(NotificationsList, CompletedJobsList, i18n) { }, project: { label: i18n._('Project'), - labelAction: { - label: i18n._('RESET'), - ngClick: 'resetProjectToDefault()', - }, type: 'lookup', list: 'ProjectList', basePath: 'projects', diff --git a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js index 06985f83f5..35861eea98 100644 --- a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js +++ b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js @@ -178,12 +178,6 @@ sync_playbook_select2(); }; - $scope.resetProjectToDefault = function() { - $scope.project_name = 'Default'; - $scope.project = null; - selectPlaybook('force_load'); - }; - // Detect and alert user to potential SCM status issues checkSCMStatus = function (oldValue, newValue) { if (oldValue !== newValue && !Empty($scope.project)) { @@ -237,7 +231,7 @@ }); if ($scope.removeSurveySaved) { - $scope.rmoveSurveySaved(); + $scope.removeSurveySaved(); } $scope.removeSurveySaved = $scope.$on('SurveySaved', function() { Wait('stop'); diff --git a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js index 5f0103658a..a6faab1f0b 100644 --- a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js +++ b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js @@ -179,12 +179,6 @@ export default }); }; - $scope.resetProjectToDefault = function() { - $scope.project_name = 'Default'; - $scope.project = null; - getPlaybooks(); - }; - // Detect and alert user to potential SCM status issues checkSCMStatus = function () { if (!Empty($scope.project)) {