/
index.js
81 lines (72 loc) · 2.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, {PropTypes} from 'react';
import classNames from 'classnames';
import Button from '../button';
import {ICON_TYPE_DOWNLOAD} from '../icon';
import Spinner from '../spinner';
import {bytesToSize} from '../../utils/files';
import styles from './styles.css';
function ActivityItemShareThumbnail(props) {
const {
file,
isFetching,
isPending,
objectUrl,
onDownloadClick
} = props;
const {
displayName,
fileSize,
objectType
} = file;
let image;
if (!isFetching && objectUrl) {
image = <img alt="Uploaded File" src={objectUrl} />;
}
else if (isFetching) {
image = <div className={classNames(`spinner-container`, styles.spinnerContainer)}><Spinner /></div>;
}
function handleDownloadClick() {
onDownloadClick(file);
}
let shareItemActions;
if (!isPending) {
// eslint-disable-next-line no-extra-parens
shareItemActions = (
<div className={classNames(`share-item-actions`, styles.shareActions)}>
<div className={classNames(`share-action-item`, styles.shareActionItem)}>
<Button
buttonClassName={styles.downloadButton}
iconType={ICON_TYPE_DOWNLOAD}
onClick={handleDownloadClick}
title="Download this file"
/>
</div>
</div>
);
}
return (
<div className={classNames(`activity-share-item`, styles.shareItem)}>
<div className={classNames(`share-thumbnail`, styles.thumbnail)}>
{image}
</div>
<div className={classNames(`share-meta`, styles.meta)}>
<div className={classNames(`share-file-info`, styles.fileInfo)}>
<div className={classNames(`share-name`, styles.name)}>{displayName}</div>
<div className={classNames(`share-file-props`, styles.fileProps)}>
<span className={classNames(`share-file-size`, styles.fileSize)}>{bytesToSize(fileSize)}</span>
<span className={classNames(`share-file-type`, styles.fileType)}>{objectType}</span>
</div>
</div>
{shareItemActions}
</div>
</div>
);
}
ActivityItemShareThumbnail.propTypes = {
file: PropTypes.object,
isFetching: PropTypes.bool,
isPending: PropTypes.bool,
objectUrl: PropTypes.string,
onDownloadClick: PropTypes.func
};
export default ActivityItemShareThumbnail;