You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
7 years ago
|
import PropTypes from 'prop-types';
|
||
8 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
3 years ago
|
import { FormattedMessage } from 'react-intl';
|
||
|
import classNames from 'classnames';
|
||
6 years ago
|
import Icon from 'mastodon/components/icon';
|
||
8 years ago
|
|
||
|
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
||
|
|
||
8 years ago
|
export default class AttachmentList extends ImmutablePureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static propTypes = {
|
||
8 years ago
|
media: ImmutablePropTypes.list.isRequired,
|
||
7 years ago
|
compact: PropTypes.bool,
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
render () {
|
||
7 years ago
|
const { media, compact } = this.props;
|
||
|
|
||
8 years ago
|
return (
|
||
3 years ago
|
<div className={classNames('attachment-list', { compact })}>
|
||
|
{!compact && (
|
||
|
<div className='attachment-list__icon'>
|
||
|
<Icon id='link' />
|
||
|
</div>
|
||
|
)}
|
||
8 years ago
|
|
||
|
<ul className='attachment-list__list'>
|
||
7 years ago
|
{media.map(attachment => {
|
||
|
const displayUrl = attachment.get('remote_url') || attachment.get('url');
|
||
|
|
||
|
return (
|
||
|
<li key={attachment.get('id')}>
|
||
3 years ago
|
<a href={displayUrl} target='_blank' rel='noopener noreferrer'>
|
||
|
{compact && <Icon id='link' />}
|
||
|
{compact && ' ' }
|
||
|
{displayUrl ? filename(displayUrl) : <FormattedMessage id='attachments_list.unprocessed' defaultMessage='(unprocessed)' />}
|
||
|
</a>
|
||
7 years ago
|
</li>
|
||
|
);
|
||
|
})}
|
||
8 years ago
|
</ul>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
}
|