mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
creating CanRemdiate flag for permissions
to remediate an inventory
This commit is contained in:
parent
07f472381e
commit
71fefc42a5
@ -123,8 +123,38 @@ angular.module('inventory', [
|
||||
'status: ' + status
|
||||
});
|
||||
});
|
||||
}],
|
||||
CanRemediate: ['resourceData', '$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
|
||||
function(resourceData, $stateParams, Rest, GetBasePath, ProcessErrors){
|
||||
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
||||
let credential_id = resourceData.data.summary_fields.insights_credential.id,
|
||||
path = `${GetBasePath('projects')}?credential__id=${credential_id}`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get()
|
||||
.then(({data}) => {
|
||||
if (data.results.length > 0 &&
|
||||
_.has(data, 'results[0].summary_fields.user_capabilities.edit')) {
|
||||
return data.results[0].summary_fields.user_capabilities.edit;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get instance groups. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}]
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
function InventoriesEdit($scope, $location,
|
||||
$stateParams, InventoryForm, Rest, ProcessErrors,
|
||||
GetBasePath, ParseTypeChange, Wait, ToJSON,
|
||||
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData, CreateSelect2, InstanceGroupsService, InstanceGroupsData) {
|
||||
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData,
|
||||
CreateSelect2, InstanceGroupsService, InstanceGroupsData, CanRemediate) {
|
||||
|
||||
// Inject dynamic view
|
||||
let defaultUrl = GetBasePath('inventory'),
|
||||
@ -37,6 +38,7 @@ function InventoriesEdit($scope, $location,
|
||||
$scope.inventory_variables = inventoryData.variables === null || inventoryData.variables === '' ? '---' : ParseVariableString(inventoryData.variables);
|
||||
$scope.parseType = 'yaml';
|
||||
$scope.instance_groups = InstanceGroupsData;
|
||||
$scope.canRemediate = CanRemediate;
|
||||
|
||||
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||
if(toState.name === 'inventories.edit') {
|
||||
|
||||
@ -201,7 +201,7 @@ function(i18n, InventoryCompletedJobsList) {
|
||||
relatedButtons: {
|
||||
remediate_inventory: {
|
||||
ngClick: 'remediateInventory(id, insights_credential)',
|
||||
ngShow: 'is_insights && mode !== "add" && canEditOrg',
|
||||
ngShow: 'is_insights && mode !== "add" && canRemediate',
|
||||
label: i18n._('Remediate Inventory'),
|
||||
class: 'Form-primaryButton'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user