about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/attachment_list.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-03-27 15:40:10 +0200
committerThibaut Girka <thib@sitedethib.com>2018-03-27 16:09:27 +0200
commit3bc5452449d492fd7fc9bba28a24acb877fc8dad (patch)
tree53eb27badb1c4ec506065d256ab169cf250521a7 /app/javascript/flavours/glitch/components/attachment_list.js
parent837b3804bfed9db1cf92923c4f6202aa7117d408 (diff)
[Glitch] Display AttachmentList in timelines in compact style when media missing
Port 86a9de6753fc425b247699c7822bc8a5d49af043 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/components/attachment_list.js')
-rw-r--r--app/javascript/flavours/glitch/components/attachment_list.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/components/attachment_list.js b/app/javascript/flavours/glitch/components/attachment_list.js
index 3a28c70f3..ef937fb4c 100644
--- a/app/javascript/flavours/glitch/components/attachment_list.js
+++ b/app/javascript/flavours/glitch/components/attachment_list.js
@@ -1,5 +1,6 @@
 import React from 'react';
 import ImmutablePropTypes from 'react-immutable-proptypes';
+import PropTypes from 'prop-types';
 import ImmutablePureComponent from 'react-immutable-pure-component';
 
 const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
@@ -8,10 +9,25 @@ export default class AttachmentList extends ImmutablePureComponent {
 
   static propTypes = {
     media: ImmutablePropTypes.list.isRequired,
+    compact: PropTypes.bool,
   };
 
   render () {
-    const { media } = this.props;
+    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>
+      );
+    }
 
     return (
       <div className='attachment-list'>