mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-13 03:21:49 -05:00
checking project and inventory "use" permission to remediate
This commit is contained in:
@@ -123,35 +123,51 @@ angular.module('inventory', [
|
|||||||
'status: ' + status
|
'status: ' + status
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
CanRemediate: ['resourceData', '$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
|
checkProjectPermission: ['resourceData', '$stateParams', 'Rest', 'GetBasePath',
|
||||||
function(resourceData, $stateParams, Rest, GetBasePath, ProcessErrors){
|
function(resourceData, $stateParams, Rest, GetBasePath){
|
||||||
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
||||||
let credential_id = resourceData.data.summary_fields.insights_credential.id,
|
let credential_id = resourceData.data.summary_fields.insights_credential.id,
|
||||||
path = `${GetBasePath('projects')}?credential__id=${credential_id}&role_level=use_role`;
|
path = `${GetBasePath('projects')}?credential__id=${credential_id}&role_level=use_role`;
|
||||||
Rest.setUrl(path);
|
Rest.setUrl(path);
|
||||||
return Rest.get()
|
return Rest.get().then(({data}) => {
|
||||||
.then(({data}) => {
|
if (data.results.length > 0){
|
||||||
if (data.results.length > 0){
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
return false;
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(({data, status}) => {
|
|
||||||
ProcessErrors(null, data, status, null, {
|
|
||||||
hdr: 'Error!',
|
|
||||||
msg: 'Failed to get instance groups. GET returned ' +
|
|
||||||
'status: ' + status
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}],
|
||||||
}]
|
checkInventoryPermission: ['resourceData', '$stateParams', 'Rest', 'GetBasePath',
|
||||||
|
function(resourceData, $stateParams, Rest, GetBasePath){
|
||||||
|
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
||||||
|
let path = `${GetBasePath('inventory')}${$stateParams.inventory_id}/?role_level=use_role`;
|
||||||
|
Rest.setUrl(path);
|
||||||
|
return Rest.get().then(() => {
|
||||||
|
return true;
|
||||||
|
}).catch(() => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
CanRemediate: ['checkProjectPermission', 'checkInventoryPermission',
|
||||||
|
function(checkProjectPermission, checkInventoryPermission){
|
||||||
|
// the user can remediate an insights
|
||||||
|
// inv if the user has "use" permission on
|
||||||
|
// an insights project and the inventory
|
||||||
|
// being edited:
|
||||||
|
return checkProjectPermission === true && checkInventoryPermission === true;
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,5 +117,6 @@ export default ['$scope', '$location',
|
|||||||
'$stateParams', 'InventoryForm', 'Rest',
|
'$stateParams', 'InventoryForm', 'Rest',
|
||||||
'ProcessErrors', 'GetBasePath', 'ParseTypeChange', 'Wait',
|
'ProcessErrors', 'GetBasePath', 'ParseTypeChange', 'Wait',
|
||||||
'ToJSON', 'ParseVariableString',
|
'ToJSON', 'ParseVariableString',
|
||||||
'$state', 'OrgAdminLookup', '$rootScope', 'resourceData', 'CreateSelect2', 'InstanceGroupsService', 'InstanceGroupsData', InventoriesEdit,
|
'$state', 'OrgAdminLookup', '$rootScope', 'resourceData', 'CreateSelect2',
|
||||||
|
'InstanceGroupsService', 'InstanceGroupsData', 'CanRemediate', InventoriesEdit,
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user