diff --git a/.gitignore b/.gitignore index 13a6c1a10..138ba4d98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ coverage/ demo/dist/ +.idea/ # Generated build files es/ diff --git a/README.md b/README.md index 4dcc49ca8..202b3fe56 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,8 @@ Launcher props: | newMessagesCount | number | no | The number of new messages. If greater than 0, this number will be displayed in a badge on the launcher. Defaults to `0`. | | onFilesSelected | function([fileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList)) | no | Called after file has been selected from dialogue in chat window. | | onMessageWasSent | function([message](#message-objects)) | yes | Called when a message is sent, with a message object as an argument. | -| showEmoji | boolean | no | Whether or not to show the emoji button in the input bar. Defaults to `true`. +| showEmoji | boolean | no | Whether or not to show the emoji button in the input bar. Defaults to `true`. | +| showFilePicker | boolean | no | Whether or not to show the file picker button in the input bar. Defaults to `true`. ### Message Objects diff --git a/src/components/ChatWindow.js b/src/components/ChatWindow.js index 445bf1247..c76233c80 100644 --- a/src/components/ChatWindow.js +++ b/src/components/ChatWindow.js @@ -39,6 +39,7 @@ class ChatWindow extends Component { onSubmit={this.onUserInputSubmit.bind(this)} onFilesSelected={this.onFilesSelected.bind(this)} showEmoji={this.props.showEmoji} + showFilePicker={this.props.showFilePicker} /> ); @@ -51,7 +52,8 @@ ChatWindow.propTypes = { onClose: PropTypes.func.isRequired, onFilesSelected: PropTypes.func, onUserInputSubmit: PropTypes.func.isRequired, - showEmoji: PropTypes.bool + showEmoji: PropTypes.bool, + showFilePicker: PropTypes.bool }; export default ChatWindow; diff --git a/src/components/Launcher.js b/src/components/Launcher.js index 7b4306cd4..884f957ca 100644 --- a/src/components/Launcher.js +++ b/src/components/Launcher.js @@ -60,6 +60,7 @@ class Launcher extends Component { isOpen={isOpen} onClose={this.handleClick.bind(this)} showEmoji={this.props.showEmoji} + showFilePicker={this.props.showFilePicker} /> ); @@ -84,11 +85,13 @@ Launcher.propTypes = { messageList: PropTypes.arrayOf(PropTypes.object), mute: PropTypes.bool, showEmoji: PropTypes.bool, + showFilePicker: PropTypes.bool }; Launcher.defaultProps = { newMessagesCount: 0, - showEmoji: true + showEmoji: true, + showFilePicker: true }; export default Launcher; diff --git a/src/components/UserInput.js b/src/components/UserInput.js index 63ada1e0c..5843b649a 100644 --- a/src/components/UserInput.js +++ b/src/components/UserInput.js @@ -20,7 +20,7 @@ class UserInput extends Component { } componentDidMount() { - this.emojiPickerButton = document.querySelector('#sc-emoji-picker-button'); + this.emojiPickerButton = document.querySelector('#sc-emoji-picker-button'); } handleKeyDown(event) { @@ -111,19 +111,22 @@ class UserInput extends Component { ); + } else if (this.props.showFilePicker) { + return ( +
+ + { this._fileUploadButton = e; }} + onChange={this._onFilesSelected.bind(this)} + /> +
+ ); + } else { + return null; } - return ( -
- - { this._fileUploadButton = e; }} - onChange={this._onFilesSelected.bind(this)} - /> -
- ); } render() { @@ -162,7 +165,8 @@ class UserInput extends Component { UserInput.propTypes = { onSubmit: PropTypes.func.isRequired, onFilesSelected: PropTypes.func.isRequired, - showEmoji: PropTypes.bool + showEmoji: PropTypes.bool, + showFilePicker: PropTypes.bool }; export default UserInput;