Skip to content

Commit

Permalink
[Issue tracker] - fix can't Delete attachment (#8337)
Browse files Browse the repository at this point in the history
Allow users to delete their own attachment. If a user does not have Issue Tracker: Close/Edit/Re-assign/Comment on All Issues, they cannot currently delete their own attachment.

Resolves #8006
  • Loading branch information
kongtiaowang committed Mar 28, 2023
1 parent 488bec8 commit eb88669
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/issue_tracker/jsx/IssueForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class IssueForm extends Component {
baseURL={this.props.baseURL}
attachments={this.state.issueData['attachments']}
userHasPermission={this.props.userHasPermission}
whoami={this.state.issueData.whoami}
/>
);

Expand Down Expand Up @@ -570,7 +571,6 @@ IssueForm.propTypes = {
baseURL: PropTypes.string.isRequired,
action: PropTypes.string.isRequired,
issue: PropTypes.string.isRequired,
whoami: PropTypes.string.isRequired,
};

export default IssueForm;
Expand Down
3 changes: 2 additions & 1 deletion modules/issue_tracker/jsx/attachments/attachmentsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AttachmentsList extends Component {
*/
displayAttachmentOptions(deleteData, item) {
if (this.props.userHasPermission
|| this.state.attachments.whoami === item.user) {
|| this.props.whoami === item.user) {
return (
<div className='row'>
<div className='col-md-12'>
Expand Down Expand Up @@ -244,6 +244,7 @@ AttachmentsList.propTypes = {
issue: PropTypes.string.isRequired,
baseURL: PropTypes.string.isRequired,
attachments: PropTypes.array,
whoami: PropTypes.string.isRequired,
};
AttachmentsList.defaultProps = {
attachments: [],
Expand Down
3 changes: 2 additions & 1 deletion modules/issue_tracker/php/edit.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ class Edit extends \NDB_Page implements ETagCalculator
*/
function _hasAccess(\User $user) : bool
{
return $user->hasPermission('data_entry');
return $user->hasPermission('issue_tracker_reporter')
|| $user->hasPermission('issue_tracker_developer');
}

/**
Expand Down

0 comments on commit eb88669

Please # to comment.