From fe896dbda5e8ce63e39e331b7e49a8e0cd5b8feb Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Tue, 10 Jan 2017 12:57:40 -0500 Subject: [PATCH] permission tab disable for private credentials --- awx/ui/client/src/controllers/Credentials.js | 19 ++++++++++--------- awx/ui/client/src/forms/Credentials.js | 4 +++- awx/ui/client/src/shared/directives.js | 8 +++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index a64056ccd4..2bddc26f0d 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -283,7 +283,7 @@ CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $stateParams, CredentialForm, Rest, Alert, ProcessErrors, ClearScope, Prompt, GetBasePath, GetChoices, KindChange, Empty, OwnerChange, FormSave, Wait, - $state, CreateSelect2, Authorization) { + $state, CreateSelect2, Authorization, i18n) { ClearScope(); @@ -336,13 +336,14 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, }); } - // if the credential is assigned to an organization, allow permission delegation - // do NOT use $scope.organization in a view directive to determine if a credential is associated with an org - // @todo why not? ^ and what is this type check for a number doing - should this be a type check for undefined? - $scope.disablePermissionAssignment = typeof($scope.organization) === 'number' ? false : true; - if ($scope.disablePermissionAssignment) { - $scope.permissionsTooltip = 'Credentials are only shared within an organization. Assign credentials to an organization to delegate credential permissions. The organization cannot be edited after credentials are assigned.'; - } + $scope.$watch('organization', function(val) { + if (val === undefined) { + $scope.permissionsTooltip = i18n._('Credentials are only shared within an organization. Assign credentials to an organization to delegate credential permissions. The organization cannot be edited after credentials are assigned.'); + } else { + $scope.permissionsTooltip = ''; + } + }); + setAskCheckboxes(); KindChange({ scope: $scope, @@ -613,5 +614,5 @@ CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$stateParams', 'CredentialForm', 'Rest', 'Alert', 'ProcessErrors', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices', 'KindChange', 'Empty', 'OwnerChange', - 'FormSave', 'Wait', '$state', 'CreateSelect2', 'Authorization' + '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 9d816c9ce4..727172c94c 100644 --- a/awx/ui/client/src/forms/Credentials.js +++ b/awx/ui/client/src/forms/Credentials.js @@ -420,7 +420,9 @@ export default related: { permissions: { - disabled: 'disablePermissionAssignment', + disabled: '(organization === undefined ? true : false)', + // Do not transition the state if organization is undefined + ngClick: `(organization === undefined ? true : false)||$state.go('credentials.edit.permissions')`, awToolTip: '{{permissionsTooltip}}', dataTipWatch: 'permissionsTooltip', dataPlacement: 'top', diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 1da55f80f8..a66ca71e9f 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -621,11 +621,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'JobsHelper']) if (attrs.tipWatch) { // Add dataTipWatch: 'variable_name' scope.$watch(attrs.tipWatch, function(newVal, oldVal) { - if (newVal !== oldVal) { - // Where did fixTitle come from?: - // http://stackoverflow.com/questions/9501921/change-twitter-bootstrap-tooltip-content-on-click - $(element).tooltip('hide').attr('data-original-title', newVal).tooltip('fixTitle'); - } + // Where did fixTitle come from?: + // http://stackoverflow.com/questions/9501921/change-twitter-bootstrap-tooltip-content-on-click + $(element).tooltip('hide').attr('data-original-title', newVal).tooltip('fixTitle'); }); } }