mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +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',
|
'Empty', 'Prompt', 'ToJSON', 'GetChoices', 'CallbackHelpInit',
|
||||||
'InitiatePlaybookRun' , 'initSurvey', '$state', 'CreateSelect2',
|
'InitiatePlaybookRun' , 'initSurvey', '$state', 'CreateSelect2',
|
||||||
'ToggleNotification','$q', 'InstanceGroupsService', 'InstanceGroupsData', 'MultiCredentialService', 'availableLabels',
|
'ToggleNotification','$q', 'InstanceGroupsService', 'InstanceGroupsData', 'MultiCredentialService', 'availableLabels',
|
||||||
'canGetProject', 'canGetInventory', 'jobTemplateData', 'ParseVariableString',
|
'projectGetPermissionDenied', 'inventoryGetPermissionDenied', 'jobTemplateData', 'ParseVariableString',
|
||||||
function(
|
function(
|
||||||
$filter, $scope, $rootScope,
|
$filter, $scope, $rootScope,
|
||||||
$location, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
$location, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||||
@ -26,7 +26,7 @@ export default
|
|||||||
ParseTypeChange, Wait, selectedLabels, i18n,
|
ParseTypeChange, Wait, selectedLabels, i18n,
|
||||||
Empty, Prompt, ToJSON, GetChoices, CallbackHelpInit, InitiatePlaybookRun, SurveyControllerInit, $state,
|
Empty, Prompt, ToJSON, GetChoices, CallbackHelpInit, InitiatePlaybookRun, SurveyControllerInit, $state,
|
||||||
CreateSelect2, ToggleNotification, $q, InstanceGroupsService, InstanceGroupsData, MultiCredentialService, availableLabels,
|
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) {
|
$scope.$watch('job_template_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||||
@ -360,7 +360,7 @@ export default
|
|||||||
MultiCredentialService.loadCredentials(jobTemplateData)
|
MultiCredentialService.loadCredentials(jobTemplateData)
|
||||||
.then(([selectedCredentials, credTypes, credTypeOptions,
|
.then(([selectedCredentials, credTypes, credTypeOptions,
|
||||||
credTags, credentialGetPermissionDenied]) => {
|
credTags, credentialGetPermissionDenied]) => {
|
||||||
$scope.canGetAllRelatedResources = canGetProject && canGetInventory && !credentialGetPermissionDenied ? true : false;
|
$scope.canGetAllRelatedResources = !projectGetPermissionDenied && !inventoryGetPermissionDenied && !credentialGetPermissionDenied ? true : false;
|
||||||
$scope.selectedCredentials = selectedCredentials;
|
$scope.selectedCredentials = selectedCredentials;
|
||||||
$scope.credential_types = credTypes;
|
$scope.credential_types = credTypes;
|
||||||
$scope.credentialTypeOptions = credTypeOptions;
|
$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) {
|
function(Rest, ProcessErrors, jobTemplateData) {
|
||||||
Rest.setUrl(jobTemplateData.related.project);
|
if(jobTemplateData.related.project) {
|
||||||
return Rest.get()
|
Rest.setUrl(jobTemplateData.related.project);
|
||||||
.then(() => {
|
return Rest.get()
|
||||||
return true;
|
.then(() => {
|
||||||
})
|
return false;
|
||||||
.catch(({data, status}) => {
|
})
|
||||||
if (status === 403) {
|
.catch(({data, status}) => {
|
||||||
/* User doesn't have read access to the project, no problem. */
|
if (status !== 403) {
|
||||||
} else {
|
ProcessErrors(null, data, status, null, {
|
||||||
ProcessErrors(null, data, status, null, {
|
hdr: 'Error!',
|
||||||
hdr: 'Error!',
|
msg: 'Failed to get project. GET returned ' +
|
||||||
msg: 'Failed to get project. GET returned ' +
|
'status: ' + status
|
||||||
'status: ' + status
|
});
|
||||||
});
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return false;
|
return true;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
canGetInventory: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
inventoryGetPermissionDenied: ['Rest', 'ProcessErrors', 'jobTemplateData',
|
||||||
function(Rest, ProcessErrors, jobTemplateData) {
|
function(Rest, ProcessErrors, jobTemplateData) {
|
||||||
Rest.setUrl(jobTemplateData.related.inventory);
|
if(jobTemplateData.related.inventory) {
|
||||||
return Rest.get()
|
Rest.setUrl(jobTemplateData.related.inventory);
|
||||||
.then(() => {
|
return Rest.get()
|
||||||
return true;
|
.then(() => {
|
||||||
})
|
return false;
|
||||||
.catch(({data, status}) => {
|
})
|
||||||
if (status === 403) {
|
.catch(({data, status}) => {
|
||||||
/* User doesn't have read access to the project, no problem. */
|
if (status !== 403) {
|
||||||
} else {
|
ProcessErrors(null, data, status, null, {
|
||||||
ProcessErrors(null, data, status, null, {
|
hdr: 'Error!',
|
||||||
hdr: 'Error!',
|
msg: 'Failed to get project. GET returned ' +
|
||||||
msg: 'Failed to get project. GET returned ' +
|
'status: ' + status
|
||||||
'status: ' + status
|
});
|
||||||
});
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return false;
|
return true;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
InstanceGroupsData: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
|
InstanceGroupsData: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
|
||||||
function($stateParams, Rest, GetBasePath, ProcessErrors){
|
function($stateParams, Rest, GetBasePath, ProcessErrors){
|
||||||
|
Loading…
Reference in New Issue
Block a user