mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
Prevent users from attempting to delete pending approvals
This commit is contained in:
@@ -61,10 +61,6 @@ const ItemToDelete = shape({
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
});
|
});
|
||||||
|
|
||||||
function cannotDelete(item) {
|
|
||||||
return !item.summary_fields.user_capabilities.delete;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ToolbarDeleteButton({
|
function ToolbarDeleteButton({
|
||||||
itemsToDelete,
|
itemsToDelete,
|
||||||
pluralizedItemName,
|
pluralizedItemName,
|
||||||
@@ -72,6 +68,7 @@ function ToolbarDeleteButton({
|
|||||||
onDelete,
|
onDelete,
|
||||||
warningMessage,
|
warningMessage,
|
||||||
i18n,
|
i18n,
|
||||||
|
cannotDelete,
|
||||||
}) {
|
}) {
|
||||||
const { isKebabified, onKebabModalChange } = useContext(KebabifiedContext);
|
const { isKebabified, onKebabModalChange } = useContext(KebabifiedContext);
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
@@ -100,7 +97,7 @@ function ToolbarDeleteButton({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{errorMessage.length > 0
|
{errorMessage.length > 0
|
||||||
? errorMessage
|
? `${errorMessage}: ${itemsUnableToDelete}`
|
||||||
: i18n._(
|
: i18n._(
|
||||||
t`You do not have permission to delete ${pluralizedItemName}: ${itemsUnableToDelete}`
|
t`You do not have permission to delete ${pluralizedItemName}: ${itemsUnableToDelete}`
|
||||||
)}
|
)}
|
||||||
@@ -193,12 +190,14 @@ ToolbarDeleteButton.propTypes = {
|
|||||||
pluralizedItemName: string,
|
pluralizedItemName: string,
|
||||||
errorMessage: string,
|
errorMessage: string,
|
||||||
warningMessage: node,
|
warningMessage: node,
|
||||||
|
cannotDelete: func,
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarDeleteButton.defaultProps = {
|
ToolbarDeleteButton.defaultProps = {
|
||||||
pluralizedItemName: 'Items',
|
pluralizedItemName: 'Items',
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
warningMessage: null,
|
warningMessage: null,
|
||||||
|
cannotDelete: item => !item.summary_fields.user_capabilities.delete,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withI18n()(ToolbarDeleteButton);
|
export default withI18n()(ToolbarDeleteButton);
|
||||||
|
|||||||
@@ -212,6 +212,13 @@ function WorkflowApprovalsList({ i18n }) {
|
|||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
itemsToDelete={selected}
|
itemsToDelete={selected}
|
||||||
pluralizedItemName={i18n._(t`Workflow Approvals`)}
|
pluralizedItemName={i18n._(t`Workflow Approvals`)}
|
||||||
|
cannotDelete={item =>
|
||||||
|
item.status === 'pending' ||
|
||||||
|
!item.summary_fields.user_capabilities.delete
|
||||||
|
}
|
||||||
|
errorMessage={i18n._(
|
||||||
|
t`These approvals cannot be deleted due to insufficient permissions or a pending job status`
|
||||||
|
)}
|
||||||
/>,
|
/>,
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user