Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[issue_tracker] Display attachments #32

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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