]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/components/attachment_list.js
1 import React
from 'react';
2 import ImmutablePropTypes
from 'react-immutable-proptypes';
3 import PropTypes
from 'prop-types';
4 import ImmutablePureComponent
from 'react-immutable-pure-component';
5 import { FormattedMessage
} from 'react-intl';
6 import classNames
from 'classnames';
7 import Icon
from 'mastodon/components/icon';
9 const filename
= url
=> url
.split('/').pop().split('#')[0].split('?')[0];
11 export default class AttachmentList
extends ImmutablePureComponent
{
14 media: ImmutablePropTypes
.list
.isRequired
,
15 compact: PropTypes
.bool
,
19 const { media
, compact
} = this.props
;
22 <div className
={classNames('attachment-list', { compact
})}>
24 <div className
='attachment-list__icon'>
29 <ul className
='attachment-list__list'>
30 {media
.map(attachment
=> {
31 const displayUrl
= attachment
.get('remote_url') || attachment
.get('url');
34 <li key
={attachment
.get('id')}>
35 <a href
={displayUrl
} target
='_blank' rel
='noopener noreferrer'>
36 {compact
&& <Icon id
='link' />}
38 {displayUrl
? filename(displayUrl
) : <FormattedMessage id
='attachments_list.unprocessed' defaultMessage
='(unprocessed)' />}
This page took 0.087797 seconds and 4 git commands to generate.