@@ -2,6 +2,8 @@ import React from 'react';
22import ImmutablePropTypes from 'react-immutable-proptypes' ;
33import PropTypes from 'prop-types' ;
44import ImmutablePureComponent from 'react-immutable-pure-component' ;
5+ import { FormattedMessage } from 'react-intl' ;
6+ import classNames from 'classnames' ;
57import Icon from 'mastodon/components/icon' ;
68
79const filename = url => url . split ( '/' ) . pop ( ) . split ( '#' ) [ 0 ] . split ( '?' ) [ 0 ] ;
@@ -16,37 +18,25 @@ export default class AttachmentList extends ImmutablePureComponent {
1618 render ( ) {
1719 const { media, compact } = this . props ;
1820
19- if ( compact ) {
20- return (
21- < div className = 'attachment-list compact' >
22- < ul className = 'attachment-list__list' >
23- { media . map ( attachment => {
24- const displayUrl = attachment . get ( 'remote_url' ) || attachment . get ( 'url' ) ;
25-
26- return (
27- < li key = { attachment . get ( 'id' ) } >
28- < a href = { displayUrl } target = '_blank' rel = 'noopener noreferrer' > < Icon id = 'link' /> { filename ( displayUrl ) } </ a >
29- </ li >
30- ) ;
31- } ) }
32- </ ul >
33- </ div >
34- ) ;
35- }
36-
3721 return (
38- < div className = 'attachment-list' >
39- < div className = 'attachment-list__icon' >
40- < Icon id = 'link' />
41- </ div >
22+ < div className = { classNames ( 'attachment-list' , { compact } ) } >
23+ { ! compact && (
24+ < div className = 'attachment-list__icon' >
25+ < Icon id = 'link' />
26+ </ div >
27+ ) }
4228
4329 < ul className = 'attachment-list__list' >
4430 { media . map ( attachment => {
4531 const displayUrl = attachment . get ( 'remote_url' ) || attachment . get ( 'url' ) ;
4632
4733 return (
4834 < li key = { attachment . get ( 'id' ) } >
49- < a href = { displayUrl } target = '_blank' rel = 'noopener noreferrer' > { filename ( displayUrl ) } </ a >
35+ < a href = { displayUrl } target = '_blank' rel = 'noopener noreferrer' >
36+ { compact && < Icon id = 'link' /> }
37+ { compact && ' ' }
38+ { displayUrl ? filename ( displayUrl ) : < FormattedMessage id = 'attachments_list.unprocessed' defaultMessage = '(unprocessed)' /> }
39+ </ a >
5040 </ li >
5141 ) ;
5242 } ) }
0 commit comments