Skip to content

Commit 40f4d59

Browse files
authored
[issue_tracker] Display attachments (#8346)
Display image attachments inline in the imaging browser. Resolves #8005
1 parent 2e9aee1 commit 40f4d59

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ changes in the following format: PR #1234***
1313
#### Features
1414
- Added new interface intended to be used for querying module data from PHP (PR #8215)
1515
- Added the NOT NULL constraint on Project Name (PR #8295)
16+
- Added ability to display images in issue tracker tickets (PR #8346)
1617
- Migrated instrument permissions from config.xml to database and added the ability
1718
to manage instrument permissions in the frontend from the `instrument_manager`
1819
module. (PR #8302)

modules/issue_tracker/jsx/attachments/attachmentsList.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ class AttachmentsList extends Component {
151151
);
152152
}
153153

154+
/**
155+
* Sets event target src to null
156+
*
157+
* @param {Object} event
158+
*/
159+
displayNone(event) {
160+
event.target.src = null;
161+
}
162+
154163
/**
155164
* Renders the React component.
156165
*
@@ -187,6 +196,7 @@ class AttachmentsList extends Component {
187196
);
188197

189198
let attachmentsRows = [];
199+
let regexImg = /image/;
190200
for (const key in this.state.attachments) {
191201
if (this.state.attachments.hasOwnProperty(key)) {
192202
const item = this.state.attachments[key];
@@ -205,7 +215,26 @@ class AttachmentsList extends Component {
205215
</div>
206216
<div className='col-md-8'>
207217
<div className='col-md-1'><b>File: </b></div>
208-
<div className='col-md-11'><i>{item.file_name}</i></div>
218+
<div className='col-md-11'>
219+
<i>{item.file_name}</i>
220+
{regexImg.test(item.mime_type) ?
221+
(<img
222+
src={this.props.baseURL +
223+
'/issue_tracker/Attachment' +
224+
'?ID=' + item.ID +
225+
'&file_hash=' + item.file_hash +
226+
'&issue=' + this.props.issue +
227+
'&filename=' + item.file_name +
228+
'&mime_type=' + item.mime_type
229+
}
230+
width='100%'
231+
height='100%'
232+
onError={this.displayNone}
233+
>
234+
</img>) :
235+
null
236+
}
237+
</div>
209238
</div>
210239
</div>
211240
<div className='row'>

0 commit comments

Comments
 (0)