mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Tweaked permissions logic to fix bug which prevented editing a JT without a default inv
This commit is contained in:
parent
2ad26008cc
commit
37003a52cf
@ -18,7 +18,7 @@ export default
|
||||
'Empty', 'Prompt', 'ToJSON', 'GetChoices', 'CallbackHelpInit',
|
||||
'InitiatePlaybookRun' , 'initSurvey', '$state', 'CreateSelect2',
|
||||
'ToggleNotification','$q', 'InstanceGroupsService', 'InstanceGroupsData', 'MultiCredentialService', 'availableLabels',
|
||||
'canGetProject', 'canGetInventory', 'jobTemplateData', 'ParseVariableString',
|
||||
'projectGetPermissionDenied', 'inventoryGetPermissionDenied', 'jobTemplateData', 'ParseVariableString',
|
||||
function(
|
||||
$filter, $scope, $rootScope,
|
||||
$location, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||
@ -26,7 +26,7 @@ export default
|
||||
ParseTypeChange, Wait, selectedLabels, i18n,
|
||||
Empty, Prompt, ToJSON, GetChoices, CallbackHelpInit, InitiatePlaybookRun, SurveyControllerInit, $state,
|
||||
CreateSelect2, ToggleNotification, $q, InstanceGroupsService, InstanceGroupsData, MultiCredentialService, availableLabels,
|
||||
canGetProject, canGetInventory, jobTemplateData, ParseVariableString
|
||||
projectGetPermissionDenied, inventoryGetPermissionDenied, jobTemplateData, ParseVariableString
|
||||
) {
|
||||
|
||||
$scope.$watch('job_template_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||
@ -360,7 +360,7 @@ export default
|
||||
MultiCredentialService.loadCredentials(jobTemplateData)
|
||||
.then(([selectedCredentials, credTypes, credTypeOptions,
|
||||
credTags, credentialGetPermissionDenied]) => {
|
||||
$scope.canGetAllRelatedResources = canGetProject && canGetInventory && !credentialGetPermissionDenied ? true : false;
|
||||
$scope.canGetAllRelatedResources = !projectGetPermissionDenied && !inventoryGetPermissionDenied && !credentialGetPermissionDenied ? true : false;
|
||||
$scope.selectedCredentials = selectedCredentials;
|
||||
$scope.credential_types = credTypes;
|
||||
$scope.credentialTypeOptions = credTypeOptions;
|
||||
|
@ -150,47 +150,57 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
|
||||
});
|
||||
});
|
||||
}],
|
||||
canGetProject: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
||||
projectGetPermissionDenied: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
||||
function(Rest, ProcessErrors, jobTemplateData) {
|
||||
Rest.setUrl(jobTemplateData.related.project);
|
||||
return Rest.get()
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
if (status === 403) {
|
||||
/* User doesn't have read access to the project, no problem. */
|
||||
} else {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get project. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
if(jobTemplateData.related.project) {
|
||||
Rest.setUrl(jobTemplateData.related.project);
|
||||
return Rest.get()
|
||||
.then(() => {
|
||||
return false;
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
if (status !== 403) {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get project. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
canGetInventory: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
||||
inventoryGetPermissionDenied: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
||||
function(Rest, ProcessErrors, jobTemplateData) {
|
||||
Rest.setUrl(jobTemplateData.related.inventory);
|
||||
return Rest.get()
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
if (status === 403) {
|
||||
/* User doesn't have read access to the project, no problem. */
|
||||
} else {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get project. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
if(jobTemplateData.related.inventory) {
|
||||
Rest.setUrl(jobTemplateData.related.inventory);
|
||||
return Rest.get()
|
||||
.then(() => {
|
||||
return false;
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
if (status !== 403) {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get project. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
InstanceGroupsData: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
|
||||
function($stateParams, Rest, GetBasePath, ProcessErrors){
|
||||
|
Loading…
Reference in New Issue
Block a user