Skip to content

Commit

Permalink
[issue_tracker] Display attachments (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaliqarosli authored Mar 22, 2023
1 parent b2b5633 commit 6a47aed
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion modules/issue_tracker/jsx/attachments/attachmentsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ class AttachmentsList extends Component {
);
}

/**
* Sets event target src to null
*
* @param {Object} event
*/
displayNone(event) {
event.target.src = null;
}

/**
* Renders the React component.
*
Expand Down Expand Up @@ -185,6 +194,7 @@ class AttachmentsList extends Component {
);

let attachmentsRows = [];
let regexImg = /image/;
for (const key in this.state.attachments) {
if (this.state.attachments.hasOwnProperty(key)) {
const item = this.state.attachments[key];
Expand All @@ -203,7 +213,26 @@ class AttachmentsList extends Component {
</div>
<div className='col-md-8'>
<div className='col-md-1'><b>File: </b></div>
<div className='col-md-11'><i>{item.file_name}</i></div>
<div className='col-md-11'>
<i>{item.file_name}</i>
{regexImg.test(item.mime_type) ?
(<img
src={this.props.baseURL +
'/issue_tracker/Attachment' +
'?ID=' + item.ID +
'&file_hash=' + item.file_hash +
'&issue=' + this.props.issue +
'&filename=' + item.file_name +
'&mime_type=' + item.mime_type
}
width='100%'
height='100%'
onError={this.displayNone}
>
</img>) :
null
}
</div>
</div>
</div>
<div className='row'>
Expand Down

0 comments on commit 6a47aed

Please # to comment.