]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/compose/components/upload_button.js
1 import React
from 'react';
2 import IconButton
from '../../../components/icon_button';
3 import PropTypes
from 'prop-types';
4 import { defineMessages
, injectIntl
} from 'react-intl';
5 import { connect
} from 'react-redux';
6 import ImmutablePureComponent
from 'react-immutable-pure-component';
7 import ImmutablePropTypes
from 'react-immutable-proptypes';
9 const messages
= defineMessages({
10 upload: { id: 'upload_button.label', defaultMessage: 'Add media (JPEG, PNG, GIF, WebM, MP4, MOV)' },
13 const makeMapStateToProps
= () => {
14 const mapStateToProps
= state
=> ({
15 acceptContentTypes: state
.getIn(['media_attachments', 'accept_content_types']),
18 return mapStateToProps
;
26 export default @connect(makeMapStateToProps
)
28 class UploadButton
extends ImmutablePureComponent
{
31 disabled: PropTypes
.bool
,
32 onSelectFile: PropTypes
.func
.isRequired
,
33 style: PropTypes
.object
,
34 resetFileKey: PropTypes
.number
,
35 acceptContentTypes: ImmutablePropTypes
.listOf(PropTypes
.string
).isRequired
,
36 intl: PropTypes
.object
.isRequired
,
39 handleChange
= (e
) => {
40 if (e
.target
.files
.length
> 0) {
41 this.props
.onSelectFile(e
.target
.files
);
46 this.fileElement
.click();
55 const { intl
, resetFileKey
, disabled
, acceptContentTypes
} = this.props
;
58 <div className
='compose-form__upload-button'>
59 <IconButton icon
='camera' title
={intl
.formatMessage(messages
.upload
)} disabled
={disabled
} onClick
={this.handleClick
} className
='compose-form__upload-button-icon' size
={18} inverted style
={iconStyle
} />
61 <span style
={{ display: 'none' }}>{intl
.formatMessage(messages
.upload
)}</span
>
67 accept
={acceptContentTypes
.toArray().join(',')}
68 onChange
={this.handleChange
}
70 style
={{ display: 'none' }}
This page took 0.101875 seconds and 5 git commands to generate.