2017-05-03 01:04:16 +01:00
|
|
|
import React from 'react';
|
2017-04-19 14:37:18 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2018-03-08 03:54:26 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-31 01:14:26 +01:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-04-19 14:37:18 +01:00
|
|
|
|
|
|
|
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
|
|
|
|
2017-06-23 18:36:54 +01:00
|
|
|
export default class AttachmentList extends ImmutablePureComponent {
|
2017-04-19 14:37:18 +01:00
|
|
|
|
2017-05-12 13:44:10 +01:00
|
|
|
static propTypes = {
|
2017-05-20 16:31:47 +01:00
|
|
|
media: ImmutablePropTypes.list.isRequired,
|
2018-03-08 03:54:26 +00:00
|
|
|
compact: PropTypes.bool,
|
2017-05-12 13:44:10 +01:00
|
|
|
};
|
|
|
|
|
2017-04-19 14:37:18 +01:00
|
|
|
render () {
|
2018-03-08 03:54:26 +00:00
|
|
|
const { media, compact } = this.props;
|
|
|
|
|
|
|
|
if (compact) {
|
|
|
|
return (
|
|
|
|
<div className='attachment-list compact'>
|
|
|
|
<ul className='attachment-list__list'>
|
|
|
|
{media.map(attachment => (
|
|
|
|
<li key={attachment.get('id')}>
|
|
|
|
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'><i className='fa fa-link' /> {filename(attachment.get('remote_url'))}</a>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-19 14:37:18 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='attachment-list'>
|
|
|
|
<div className='attachment-list__icon'>
|
|
|
|
<i className='fa fa-link' />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ul className='attachment-list__list'>
|
2018-01-17 15:57:15 +00:00
|
|
|
{media.map(attachment => (
|
2017-04-19 14:37:18 +01:00
|
|
|
<li key={attachment.get('id')}>
|
|
|
|
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'>{filename(attachment.get('remote_url'))}</a>
|
|
|
|
</li>
|
2018-01-17 15:57:15 +00:00
|
|
|
))}
|
2017-04-19 14:37:18 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-21 19:05:35 +01:00
|
|
|
|
2017-05-12 13:44:10 +01:00
|
|
|
}
|