2017-05-03 00:04:16 +00:00
|
|
|
import React from 'react';
|
2017-04-19 13:37:18 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
|
|
|
|
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
|
|
|
|
2017-04-21 18:05:35 +00:00
|
|
|
class AttachmentList extends React.PureComponent {
|
2017-04-19 13:37:18 +00:00
|
|
|
|
2017-05-12 12:44:10 +00:00
|
|
|
static propTypes = {
|
|
|
|
media: ImmutablePropTypes.list.isRequired
|
|
|
|
};
|
|
|
|
|
2017-04-19 13:37:18 +00:00
|
|
|
render () {
|
|
|
|
const { media } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='attachment-list'>
|
|
|
|
<div className='attachment-list__icon'>
|
|
|
|
<i className='fa fa-link' />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ul className='attachment-list__list'>
|
|
|
|
{media.map(attachment =>
|
|
|
|
<li key={attachment.get('id')}>
|
|
|
|
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'>{filename(attachment.get('remote_url'))}</a>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-21 18:05:35 +00:00
|
|
|
|
2017-05-12 12:44:10 +00:00
|
|
|
}
|
2017-04-19 13:37:18 +00:00
|
|
|
|
|
|
|
export default AttachmentList;
|