mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 10:11:05 -03:30
Disable permissions tab in Credential > Edit form if Credential is private (#3288)
* disable permissions tab in credential > edit view if credential is private, resolves #3265 * add tooltip indicating why permissions tab is disabled if cred is private
This commit is contained in:
@@ -148,7 +148,7 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
url;
|
url;
|
||||||
|
|
||||||
$scope.keyEntered = false;
|
$scope.keyEntered = false;
|
||||||
|
$scope.permissionsTooltip = 'Please save before assigning permissions';
|
||||||
generator.inject(form, { mode: 'add', related: false, scope: $scope });
|
generator.inject(form, { mode: 'add', related: false, scope: $scope });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
@@ -391,6 +391,12 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log,
|
|||||||
$scope.removeCredentialLoaded();
|
$scope.removeCredentialLoaded();
|
||||||
}
|
}
|
||||||
$scope.removeCredentialLoaded = $scope.$on('credentialLoaded', function () {
|
$scope.removeCredentialLoaded = $scope.$on('credentialLoaded', function () {
|
||||||
|
// 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
|
||||||
|
$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.';
|
||||||
|
}
|
||||||
var set;
|
var set;
|
||||||
for (set in relatedSets) {
|
for (set in relatedSets) {
|
||||||
$scope.search(relatedSets[set].iterator);
|
$scope.search(relatedSets[set].iterator);
|
||||||
|
|||||||
@@ -404,7 +404,9 @@ export default
|
|||||||
|
|
||||||
related: {
|
related: {
|
||||||
permissions: {
|
permissions: {
|
||||||
awToolTip: 'Please save before assigning permissions',
|
disabled: 'disablePermissionAssignment',
|
||||||
|
awToolTip: '{{permissionsTooltip}}',
|
||||||
|
dataTipWatch: 'permissionsTooltip',
|
||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
basePath: 'credentials/:id/access_list/',
|
basePath: 'credentials/:id/access_list/',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
@@ -452,7 +454,7 @@ export default
|
|||||||
return {
|
return {
|
||||||
permissions: {
|
permissions: {
|
||||||
iterator: 'permission',
|
iterator: 'permission',
|
||||||
url: urls.access_list
|
url: urls.access_list,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1526,8 +1526,13 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
collection = this.form.related[itm];
|
collection = this.form.related[itm];
|
||||||
html += `<div id="${itm}_tab"`+
|
html += `<div id="${itm}_tab"`+
|
||||||
`class="Form-tab"`+
|
`class="Form-tab"`+
|
||||||
`ng-click="${this.form.related[itm].disabled} || toggleFormTabs($event)"` +
|
`ng-click="${this.form.related[itm].disabled} || toggleFormTabs($event)"`;
|
||||||
`ng-class="{'is-selected': ${itm}Selected ` ;
|
if (collection.awToolTip){
|
||||||
|
html += `aw-tool-tip="${collection.awToolTip}"` +
|
||||||
|
`aw-tip-placement="${collection.dataPlacement}"` +
|
||||||
|
`data-tip-watch="${collection.dataTipWatch}"`;
|
||||||
|
}
|
||||||
|
html += `ng-class="{'is-selected': ${itm}Selected ` ;
|
||||||
if(this.form.related[itm].disabled){
|
if(this.form.related[itm].disabled){
|
||||||
html += `, 'Form-tab--disabled' : ${this.form.related[itm].disabled }`;
|
html += `, 'Form-tab--disabled' : ${this.form.related[itm].disabled }`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user