From b4e44d0c566339139c8d1dda84c165bf2010f43a Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 17 Jan 2017 16:03:47 -0500 Subject: [PATCH] fix priv escalation field labels from not showing up --- awx/ui/client/src/controllers/Credentials.js | 28 +++-- awx/ui/client/src/forms/Credentials.js | 3 +- awx/ui/client/src/helpers/Credentials.js | 106 +++++++++++++++++++ 3 files changed, 127 insertions(+), 10 deletions(-) diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 2bddc26f0d..8fc0d4e55f 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -113,7 +113,7 @@ CredentialsList.$inject = ['$scope', '$rootScope', '$location', '$log', export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $stateParams, CredentialForm, GenerateForm, Rest, Alert, ProcessErrors, - ClearScope, GetBasePath, GetChoices, Empty, KindChange, + ClearScope, GetBasePath, GetChoices, Empty, KindChange, BecomeMethodChange, OwnerChange, FormSave, $state, CreateSelect2) { ClearScope(); @@ -221,6 +221,10 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, KindChange({ scope: $scope, form: form, reset: true }); }; + $scope.becomeMethodChange = function() { + BecomeMethodChange({ scope: $scope }); + }; + // Save $scope.formSave = function() { if ($scope[form.name + '_form'].$valid) { @@ -276,13 +280,13 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$stateParams', 'CredentialForm', 'GenerateForm', 'Rest', 'Alert', - 'ProcessErrors', 'ClearScope', 'GetBasePath', 'GetChoices', 'Empty', 'KindChange', + 'ProcessErrors', 'ClearScope', 'GetBasePath', 'GetChoices', 'Empty', 'KindChange', 'BecomeMethodChange', 'OwnerChange', 'FormSave', '$state', 'CreateSelect2' ]; export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $stateParams, CredentialForm, Rest, Alert, ProcessErrors, ClearScope, Prompt, - GetBasePath, GetChoices, KindChange, Empty, OwnerChange, FormSave, Wait, + GetBasePath, GetChoices, KindChange, BecomeMethodChange, Empty, OwnerChange, FormSave, Wait, $state, CreateSelect2, Authorization, i18n) { ClearScope(); @@ -345,11 +349,6 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, }); setAskCheckboxes(); - KindChange({ - scope: $scope, - form: form, - reset: false - }); OwnerChange({ scope: $scope }); $scope.$watch("ssh_key_data", function(val) { if (val === "" || val === null || val === undefined) { @@ -454,6 +453,13 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, break; } } + + KindChange({ + scope: $scope, + form: form, + reset: false + }); + master.kind = $scope.kind; CreateSelect2({ @@ -519,6 +525,10 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, KindChange({ scope: $scope, form: form, reset: true }); }; + $scope.becomeMethodChange = function() { + BecomeMethodChange({ scope: $scope }); + }; + $scope.formCancel = function() { $state.transitionTo('credentials'); }; @@ -613,6 +623,6 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$stateParams', 'CredentialForm', 'Rest', 'Alert', 'ProcessErrors', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices', - 'KindChange', 'Empty', 'OwnerChange', + 'KindChange', 'BecomeMethodChange', 'Empty', 'OwnerChange', 'FormSave', 'Wait', '$state', 'CreateSelect2', 'Authorization', 'i18n', ]; diff --git a/awx/ui/client/src/forms/Credentials.js b/awx/ui/client/src/forms/Credentials.js index 1ec2628cfd..247981e18b 100644 --- a/awx/ui/client/src/forms/Credentials.js +++ b/awx/ui/client/src/forms/Credentials.js @@ -288,7 +288,8 @@ export default dataPlacement: 'right', dataContainer: "body", subForm: 'credentialSubForm', - ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)' + ngDisabled: '!(credential_obj.summary_fields.user_capabilities.edit || canAdd)', + ngChange: 'becomeMethodChange()', }, "become_username": { labelBind: 'becomeUsernameLabel', diff --git a/awx/ui/client/src/helpers/Credentials.js b/awx/ui/client/src/helpers/Credentials.js index 23216577ba..007756d17c 100644 --- a/awx/ui/client/src/helpers/Credentials.js +++ b/awx/ui/client/src/helpers/Credentials.js @@ -74,6 +74,7 @@ angular.module('CredentialsHelper', ['Utilities']) scope.projectPopOver = "

" + i18n._("The project value") + "

"; scope.hostPopOver = "

" + i18n._("The host value") + "

"; scope.ssh_key_data_api_error = ''; + if (!Empty(scope.kind)) { // Apply kind specific settings switch (scope.kind.value) { @@ -204,6 +205,111 @@ angular.module('CredentialsHelper', ['Utilities']) } ]) +.factory('BecomeMethodChange', ['Empty', 'i18n', + function (Empty, i18n) { + return function (params) { + console.log('become method has changed'); + var scope = params.scope; + + if (!Empty(scope.kind)) { + // Apply kind specific settings + switch (scope.kind.value) { + case 'aws': + scope.aws_required = true; + break; + case 'rax': + scope.rackspace_required = true; + scope.username_required = true; + break; + case 'ssh': + scope.usernameLabel = i18n._('Username'); //formally 'SSH Username' + scope.becomeUsernameLabel = i18n._('Privilege Escalation Username'); + scope.becomePasswordLabel = i18n._('Privilege Escalation Password'); + break; + case 'scm': + scope.sshKeyDataLabel = i18n._('SCM Private Key'); + scope.passwordLabel = i18n._('Password'); + break; + case 'gce': + scope.usernameLabel = i18n._('Service Account Email Address'); + scope.sshKeyDataLabel = i18n._('RSA Private Key'); + scope.email_required = true; + scope.key_required = true; + scope.project_required = true; + scope.key_description = i18n._('Paste the contents of the PEM file associated with the service account email.'); + scope.projectLabel = i18n._("Project"); + scope.project_required = false; + scope.projectPopOver = "

" + i18n._("The Project ID is the " + + "GCE assigned identification. It is constructed as " + + "two words followed by a three digit number. Such " + + "as: ") + "

adjective-noun-000

"; + break; + case 'azure': + scope.sshKeyDataLabel = i18n._('Management Certificate'); + scope.subscription_required = true; + scope.key_required = true; + scope.key_description = i18n._("Paste the contents of the PEM file that corresponds to the certificate you uploaded in the Microsoft Azure console."); + break; + case 'azure_rm': + scope.usernameLabel = i18n._("Username"); + scope.subscription_required = true; + scope.passwordLabel = i18n._('Password'); + scope.azure_rm_required = true; + break; + case 'vmware': + scope.username_required = true; + scope.host_required = true; + scope.password_required = true; + scope.hostLabel = "vCenter Host"; + scope.passwordLabel = i18n._('Password'); + scope.hostPopOver = i18n._("Enter the hostname or IP address which corresponds to your VMware vCenter."); + break; + case 'openstack': + scope.hostLabel = i18n._("Host (Authentication URL)"); + scope.projectLabel = i18n._("Project (Tenant Name)"); + scope.domainLabel = i18n._("Domain Name"); + scope.password_required = true; + scope.project_required = true; + scope.host_required = true; + scope.username_required = true; + scope.projectPopOver = "

" + i18n._("This is the tenant name. " + + " This value is usually the same " + + " as the username.") + "

"; + scope.hostPopOver = "

" + i18n._("The host to authenticate with.") + + "
" + i18n.sprintf(i18n._("For example, %s"), "https://openstack.business.com/v2.0/"); + break; + case 'satellite6': + scope.username_required = true; + scope.password_required = true; + scope.passwordLabel = i18n._('Password'); + scope.host_required = true; + scope.hostLabel = i18n._("Satellite 6 URL"); + scope.hostPopOver = i18n.sprintf(i18n._("Enter the URL which corresponds to your %s" + + "Red Hat Satellite 6 server. %s" + + "For example, %s"), "
", "
", "https://satellite.example.org"); + break; + case 'cloudforms': + scope.username_required = true; + scope.password_required = true; + scope.passwordLabel = i18n._('Password'); + scope.host_required = true; + scope.hostLabel = i18n._("CloudForms URL"); + scope.hostPopOver = i18n.sprintf(i18n._("Enter the URL for the virtual machine which %s" + + "corresponds to your CloudForm instance. %s" + + "For example, %s"), "
", "
", "https://cloudforms.example.org"); + break; + case 'net': + scope.username_required = true; + scope.password_required = false; + scope.passwordLabel = i18n._('Password'); + scope.sshKeyDataLabel = i18n._('SSH Key'); + break; + } + } + }; + } +]) + .factory('OwnerChange', [ function () {