Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature to disable add files button #132

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
coverage/
demo/dist/
.idea/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe put this after the .DS_Store entry, and give that section a title like # OS or editor files?


# Generated build files
es/
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/components/ChatWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
</div>
);
Expand All @@ -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;
5 changes: 4 additions & 1 deletion src/components/Launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Launcher extends Component {
isOpen={isOpen}
onClose={this.handleClick.bind(this)}
showEmoji={this.props.showEmoji}
showFilePicker={this.props.showFilePicker}
/>
</div>
);
Expand All @@ -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;
32 changes: 18 additions & 14 deletions src/components/UserInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -111,19 +111,22 @@ class UserInput extends Component {
<SendIcon onClick={this._submitText.bind(this)} />
</div>
);
} else if (this.props.showFilePicker) {
return (
<div className="sc-user-input--button">
<FileIcon onClick={this._showFilePicker.bind(this)} />
<input
type="file"
name="files[]"
multiple
ref={(e) => { this._fileUploadButton = e; }}
onChange={this._onFilesSelected.bind(this)}
/>
</div>
);
} else {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm so this makes the emoji picker icon jump to the left whenever the user starts typing; I think it would be better to always render either the file picker or the send icon. The handler _submitText already just ignores empty messages so I think it would be fine.

}
return (
<div className="sc-user-input--button">
<FileIcon onClick={this._showFilePicker.bind(this)} />
<input
type="file"
name="files[]"
multiple
ref={(e) => { this._fileUploadButton = e; }}
onChange={this._onFilesSelected.bind(this)}
/>
</div>
);
}

render() {
Expand Down Expand Up @@ -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;