allow messages to be send on ctrl+enter
Этот коммит содержится в:
@@ -27,7 +27,7 @@ export default class CreateComment extends React.Component {
|
|||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this);
|
this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this);
|
||||||
this.handleUserInput = this.handleUserInput.bind(this);
|
this.handleUserInput = this.handleUserInput.bind(this);
|
||||||
this.handleArrowUp = this.handleArrowUp.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
this.handleUploadStart = this.handleUploadStart.bind(this);
|
this.handleUploadStart = this.handleUploadStart.bind(this);
|
||||||
this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this);
|
this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this);
|
||||||
this.handleUploadError = this.handleUploadError.bind(this);
|
this.handleUploadError = this.handleUploadError.bind(this);
|
||||||
@@ -36,6 +36,7 @@ export default class CreateComment extends React.Component {
|
|||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.getFileCount = this.getFileCount.bind(this);
|
this.getFileCount = this.getFileCount.bind(this);
|
||||||
this.handleResize = this.handleResize.bind(this);
|
this.handleResize = this.handleResize.bind(this);
|
||||||
|
this.onUserChange = this.onUserChange.bind(this);
|
||||||
|
|
||||||
PostStore.clearCommentDraftUploads();
|
PostStore.clearCommentDraftUploads();
|
||||||
|
|
||||||
@@ -45,8 +46,11 @@ export default class CreateComment extends React.Component {
|
|||||||
uploadsInProgress: draft.uploadsInProgress,
|
uploadsInProgress: draft.uploadsInProgress,
|
||||||
previews: draft.previews,
|
previews: draft.previews,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
windowWidth: Utils.windowWidth()
|
windowWidth: Utils.windowWidth(),
|
||||||
|
ctrlSend: UserStore.getCurrentUser().props.ctrlSend
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserStore.addChangeListener(this.onUserChange);
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.addEventListener('resize', this.handleResize);
|
window.addEventListener('resize', this.handleResize);
|
||||||
@@ -54,6 +58,10 @@ export default class CreateComment extends React.Component {
|
|||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
window.removeEventListener('resize', this.handleResize);
|
window.removeEventListener('resize', this.handleResize);
|
||||||
}
|
}
|
||||||
|
onUserChange() {
|
||||||
|
const ctrlSend = UserStore.getCurrentUser().props.ctrlSend || 'false';
|
||||||
|
this.setState({ctrlSend});
|
||||||
|
}
|
||||||
handleResize() {
|
handleResize() {
|
||||||
this.setState({windowWidth: Utils.windowWidth()});
|
this.setState({windowWidth: Utils.windowWidth()});
|
||||||
}
|
}
|
||||||
@@ -140,10 +148,12 @@ export default class CreateComment extends React.Component {
|
|||||||
this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null});
|
this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null});
|
||||||
}
|
}
|
||||||
commentMsgKeyPress(e) {
|
commentMsgKeyPress(e) {
|
||||||
if (e.which === 13 && !e.shiftKey && !e.altKey) {
|
if (this.state.ctrlSend === 'true' && e.ctrlKey || this.state.ctrlSend === 'false') {
|
||||||
e.preventDefault();
|
if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
|
||||||
ReactDOM.findDOMNode(this.refs.textbox).blur();
|
e.preventDefault();
|
||||||
this.handleSubmit(e);
|
ReactDOM.findDOMNode(this.refs.textbox).blur();
|
||||||
|
this.handleSubmit(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const t = Date.now();
|
const t = Date.now();
|
||||||
@@ -161,7 +171,12 @@ export default class CreateComment extends React.Component {
|
|||||||
$('.post-right__scroll').perfectScrollbar('update');
|
$('.post-right__scroll').perfectScrollbar('update');
|
||||||
this.setState({messageText: messageText});
|
this.setState({messageText: messageText});
|
||||||
}
|
}
|
||||||
handleArrowUp(e) {
|
handleKeyDown(e) {
|
||||||
|
if (this.state.ctrlSend === 'true' && e.keyCode === KeyCodes.ENTER && e.ctrlKey === true) {
|
||||||
|
this.commentMsgKeyPress(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -313,7 +328,7 @@ export default class CreateComment extends React.Component {
|
|||||||
<Textbox
|
<Textbox
|
||||||
onUserInput={this.handleUserInput}
|
onUserInput={this.handleUserInput}
|
||||||
onKeyPress={this.commentMsgKeyPress}
|
onKeyPress={this.commentMsgKeyPress}
|
||||||
onKeyDown={this.handleArrowUp}
|
onKeyDown={this.handleKeyDown}
|
||||||
messageText={this.state.messageText}
|
messageText={this.state.messageText}
|
||||||
createMessage='Add a comment...'
|
createMessage='Add a comment...'
|
||||||
initialText=''
|
initialText=''
|
||||||
|
|||||||
@@ -36,9 +36,10 @@ export default class CreatePost extends React.Component {
|
|||||||
this.removePreview = this.removePreview.bind(this);
|
this.removePreview = this.removePreview.bind(this);
|
||||||
this.onChange = this.onChange.bind(this);
|
this.onChange = this.onChange.bind(this);
|
||||||
this.getFileCount = this.getFileCount.bind(this);
|
this.getFileCount = this.getFileCount.bind(this);
|
||||||
this.handleArrowUp = this.handleArrowUp.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
this.handleResize = this.handleResize.bind(this);
|
this.handleResize = this.handleResize.bind(this);
|
||||||
this.sendMessage = this.sendMessage.bind(this);
|
this.sendMessage = this.sendMessage.bind(this);
|
||||||
|
this.onUserChange = this.onUserChange.bind(this);
|
||||||
|
|
||||||
PostStore.clearDraftUploads();
|
PostStore.clearDraftUploads();
|
||||||
|
|
||||||
@@ -52,8 +53,15 @@ export default class CreatePost extends React.Component {
|
|||||||
submitting: false,
|
submitting: false,
|
||||||
initialText: draft.messageText,
|
initialText: draft.messageText,
|
||||||
windowWidth: Utils.windowWidth(),
|
windowWidth: Utils.windowWidth(),
|
||||||
windowHeight: Utils.windowHeight()
|
windowHeight: Utils.windowHeight(),
|
||||||
|
ctrlSend: UserStore.getCurrentUser().props.ctrlSend
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserStore.addChangeListener(this.onUserChange);
|
||||||
|
}
|
||||||
|
onUserChange() {
|
||||||
|
const ctrlSend = UserStore.getCurrentUser().props.ctrlSend || 'false';
|
||||||
|
this.setState({ctrlSend});
|
||||||
}
|
}
|
||||||
handleResize() {
|
handleResize() {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -201,10 +209,12 @@ export default class CreatePost extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
postMsgKeyPress(e) {
|
postMsgKeyPress(e) {
|
||||||
if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
|
if (this.state.ctrlSend === 'true' && e.ctrlKey || this.state.ctrlSend === 'false') {
|
||||||
e.preventDefault();
|
if (e.which === KeyCodes.ENTER && !e.shiftKey && !e.altKey) {
|
||||||
ReactDOM.findDOMNode(this.refs.textbox).blur();
|
e.preventDefault();
|
||||||
this.handleSubmit(e);
|
ReactDOM.findDOMNode(this.refs.textbox).blur();
|
||||||
|
this.handleSubmit(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const t = Date.now();
|
const t = Date.now();
|
||||||
@@ -328,7 +338,12 @@ export default class CreatePost extends React.Component {
|
|||||||
const draft = PostStore.getDraft(channelId);
|
const draft = PostStore.getDraft(channelId);
|
||||||
return draft.previews.length + draft.uploadsInProgress.length;
|
return draft.previews.length + draft.uploadsInProgress.length;
|
||||||
}
|
}
|
||||||
handleArrowUp(e) {
|
handleKeyDown(e) {
|
||||||
|
if (this.state.ctrlSend === 'true' && e.keyCode === KeyCodes.ENTER && e.ctrlKey === true) {
|
||||||
|
this.postMsgKeyPress(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
if (e.keyCode === KeyCodes.UP && this.state.messageText === '') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -393,7 +408,7 @@ export default class CreatePost extends React.Component {
|
|||||||
<Textbox
|
<Textbox
|
||||||
onUserInput={this.handleUserInput}
|
onUserInput={this.handleUserInput}
|
||||||
onKeyPress={this.postMsgKeyPress}
|
onKeyPress={this.postMsgKeyPress}
|
||||||
onKeyDown={this.handleArrowUp}
|
onKeyDown={this.handleKeyDown}
|
||||||
onHeightChange={this.resizePostHolder}
|
onHeightChange={this.resizePostHolder}
|
||||||
messageText={this.state.messageText}
|
messageText={this.state.messageText}
|
||||||
createMessage='Write a message...'
|
createMessage='Write a message...'
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
this.submitEmail = this.submitEmail.bind(this);
|
this.submitEmail = this.submitEmail.bind(this);
|
||||||
this.submitUser = this.submitUser.bind(this);
|
this.submitUser = this.submitUser.bind(this);
|
||||||
this.submitPicture = this.submitPicture.bind(this);
|
this.submitPicture = this.submitPicture.bind(this);
|
||||||
|
this.submitCtrlSend = this.submitCtrlSend.bind(this);
|
||||||
|
|
||||||
this.updateUsername = this.updateUsername.bind(this);
|
this.updateUsername = this.updateUsername.bind(this);
|
||||||
this.updateFirstName = this.updateFirstName.bind(this);
|
this.updateFirstName = this.updateFirstName.bind(this);
|
||||||
@@ -30,6 +31,7 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
this.updateEmail = this.updateEmail.bind(this);
|
this.updateEmail = this.updateEmail.bind(this);
|
||||||
this.updateConfirmEmail = this.updateConfirmEmail.bind(this);
|
this.updateConfirmEmail = this.updateConfirmEmail.bind(this);
|
||||||
this.updatePicture = this.updatePicture.bind(this);
|
this.updatePicture = this.updatePicture.bind(this);
|
||||||
|
this.updateCtrlSend = this.updateCtrlSend.bind(this);
|
||||||
this.updateSection = this.updateSection.bind(this);
|
this.updateSection = this.updateSection.bind(this);
|
||||||
|
|
||||||
this.handleClose = this.handleClose.bind(this);
|
this.handleClose = this.handleClose.bind(this);
|
||||||
@@ -176,6 +178,13 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
submitCtrlSend(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var user = UserStore.getCurrentUser();
|
||||||
|
user.props = this.state.props;
|
||||||
|
this.submitUser(user, true);
|
||||||
|
}
|
||||||
updateUsername(e) {
|
updateUsername(e) {
|
||||||
this.setState({username: e.target.value});
|
this.setState({username: e.target.value});
|
||||||
}
|
}
|
||||||
@@ -194,6 +203,11 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
updateConfirmEmail(e) {
|
updateConfirmEmail(e) {
|
||||||
this.setState({confirmEmail: e.target.value});
|
this.setState({confirmEmail: e.target.value});
|
||||||
}
|
}
|
||||||
|
updateCtrlSend(value) {
|
||||||
|
let props = this.state.props;
|
||||||
|
props.ctrlSend = value;
|
||||||
|
this.setState({props});
|
||||||
|
}
|
||||||
updatePicture(e) {
|
updatePicture(e) {
|
||||||
if (e.target.files && e.target.files[0]) {
|
if (e.target.files && e.target.files[0]) {
|
||||||
this.setState({picture: e.target.files[0]});
|
this.setState({picture: e.target.files[0]});
|
||||||
@@ -228,7 +242,8 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
var user = props.user;
|
var user = props.user;
|
||||||
|
|
||||||
return {username: user.username, firstName: user.first_name, lastName: user.last_name, nickname: user.nickname,
|
return {username: user.username, firstName: user.first_name, lastName: user.last_name, nickname: user.nickname,
|
||||||
email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailChangeInProgress: false};
|
email: user.email, confirmEmail: '', picture: null, loadingPicture: false, emailChangeInProgress: false,
|
||||||
|
props: user.props};
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
var user = this.props.user;
|
var user = this.props.user;
|
||||||
@@ -570,6 +585,76 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var miscellaneousSection;
|
||||||
|
var describeCtrlSend = this.state.props.ctrlSend === 'true' ? 'On' : 'Off';
|
||||||
|
if (this.props.activeSection === 'ctrlSend') {
|
||||||
|
var ctrlSendActive = [false, false];
|
||||||
|
if (this.state.props.ctrlSend === 'true') {
|
||||||
|
ctrlSendActive[0] = true;
|
||||||
|
} else {
|
||||||
|
ctrlSendActive[1] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let ctrlSendInputs = [];
|
||||||
|
ctrlSendInputs.push(
|
||||||
|
<div
|
||||||
|
key='ctrlSendSetting'
|
||||||
|
className='form-group'
|
||||||
|
>
|
||||||
|
<div className=''>
|
||||||
|
<div className='radio'>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type='radio'
|
||||||
|
onChange={() => this.updateCtrlSend('true')}
|
||||||
|
checked={ctrlSendActive[0]}
|
||||||
|
/>
|
||||||
|
{'On'}
|
||||||
|
</label>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
<div className='radio'>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type='radio'
|
||||||
|
onChange={() => this.updateCtrlSend('false')}
|
||||||
|
checked={ctrlSendActive[1]}
|
||||||
|
/>
|
||||||
|
{'Off'}
|
||||||
|
</label>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
<div><br/>{'If enabled \'Enter\' inserts a new line and ctrl + enter submits the message.'}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
miscellaneousSection = (
|
||||||
|
<SettingItemMax
|
||||||
|
title='Send messages on Ctrl + Enter'
|
||||||
|
inputs={ctrlSendInputs}
|
||||||
|
submit={this.submitCtrlSend}
|
||||||
|
server_error={serverError}
|
||||||
|
client_error={emailError}
|
||||||
|
updateSection={function clearCtrlSend(e) {
|
||||||
|
this.updateSection('ctrlSend');
|
||||||
|
e.preventDefault();
|
||||||
|
}.bind(this)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
miscellaneousSection = (
|
||||||
|
<SettingItemMin
|
||||||
|
title='Send messages on Ctrl + Enter'
|
||||||
|
describe={describeCtrlSend}
|
||||||
|
updateSection={function updateCtrlSend() {
|
||||||
|
this.updateSection('ctrlSend');
|
||||||
|
}.bind(this)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className='modal-header'>
|
<div className='modal-header'>
|
||||||
@@ -601,6 +686,8 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
{emailSection}
|
{emailSection}
|
||||||
<div className='divider-light'/>
|
<div className='divider-light'/>
|
||||||
{pictureSection}
|
{pictureSection}
|
||||||
|
<div className='divider-light'/>
|
||||||
|
{miscellaneousSection}
|
||||||
<div className='divider-dark'/>
|
<div className='divider-dark'/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user