mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 10:41:05 -03:30
creating CanRemdiate flag for permissions
to remediate an inventory
This commit is contained in:
@@ -123,8 +123,38 @@ angular.module('inventory', [
|
|||||||
'status: ' + status
|
'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,
|
function InventoriesEdit($scope, $location,
|
||||||
$stateParams, InventoryForm, Rest, ProcessErrors,
|
$stateParams, InventoryForm, Rest, ProcessErrors,
|
||||||
GetBasePath, ParseTypeChange, Wait, ToJSON,
|
GetBasePath, ParseTypeChange, Wait, ToJSON,
|
||||||
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData, CreateSelect2, InstanceGroupsService, InstanceGroupsData) {
|
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData,
|
||||||
|
CreateSelect2, InstanceGroupsService, InstanceGroupsData, CanRemediate) {
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
let defaultUrl = GetBasePath('inventory'),
|
let defaultUrl = GetBasePath('inventory'),
|
||||||
@@ -37,6 +38,7 @@ function InventoriesEdit($scope, $location,
|
|||||||
$scope.inventory_variables = inventoryData.variables === null || inventoryData.variables === '' ? '---' : ParseVariableString(inventoryData.variables);
|
$scope.inventory_variables = inventoryData.variables === null || inventoryData.variables === '' ? '---' : ParseVariableString(inventoryData.variables);
|
||||||
$scope.parseType = 'yaml';
|
$scope.parseType = 'yaml';
|
||||||
$scope.instance_groups = InstanceGroupsData;
|
$scope.instance_groups = InstanceGroupsData;
|
||||||
|
$scope.canRemediate = CanRemediate;
|
||||||
|
|
||||||
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||||
if(toState.name === 'inventories.edit') {
|
if(toState.name === 'inventories.edit') {
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ function(i18n, InventoryCompletedJobsList) {
|
|||||||
relatedButtons: {
|
relatedButtons: {
|
||||||
remediate_inventory: {
|
remediate_inventory: {
|
||||||
ngClick: 'remediateInventory(id, insights_credential)',
|
ngClick: 'remediateInventory(id, insights_credential)',
|
||||||
ngShow: 'is_insights && mode !== "add" && canEditOrg',
|
ngShow: 'is_insights && mode !== "add" && canRemediate',
|
||||||
label: i18n._('Remediate Inventory'),
|
label: i18n._('Remediate Inventory'),
|
||||||
class: 'Form-primaryButton'
|
class: 'Form-primaryButton'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user