PLT-4943: Warn when editing a message > 4000 chars (#4789)
* added basic functionality * css fixes * css fixes part II: electric boogaloo * removed css interference with theme changes, for this and post length error
Этот коммит содержится в:
коммит произвёл
enahum
родитель
f0b74e78dd
Коммит
26e43c671c
@@ -494,7 +494,7 @@ export default class CreatePost extends React.Component {
|
|||||||
|
|
||||||
let postError = null;
|
let postError = null;
|
||||||
if (this.state.postError) {
|
if (this.state.postError) {
|
||||||
const postErrorClass = 'control-label post-error' + (this.state.errorClass ? (' ' + this.state.errorClass) : '');
|
const postErrorClass = 'post-error' + (this.state.errorClass ? (' ' + this.state.errorClass) : '');
|
||||||
postError = <label className={postErrorClass}>{this.state.postError}</label>;
|
postError = <label className={postErrorClass}>{this.state.postError}</label>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ export default class EditPostModal extends React.Component {
|
|||||||
channel_id: '',
|
channel_id: '',
|
||||||
comments: 0,
|
comments: 0,
|
||||||
refocusId: '',
|
refocusId: '',
|
||||||
ctrlSend: PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter')
|
ctrlSend: PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
|
||||||
|
postError: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,14 @@ export default class EditPostModal extends React.Component {
|
|||||||
channel_id: this.state.channel_id
|
channel_id: this.state.channel_id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.state.postError) {
|
||||||
|
this.setState({errorClass: 'animation--highlight'});
|
||||||
|
setTimeout(() => {
|
||||||
|
this.setState({errorClass: null});
|
||||||
|
}, Constants.ANIMATION_TIMEOUT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (updatedPost.message === this.state.originalText) {
|
if (updatedPost.message === this.state.originalText) {
|
||||||
// no changes so just close the modal
|
// no changes so just close the modal
|
||||||
$('#edit_post').modal('hide');
|
$('#edit_post').modal('hide');
|
||||||
@@ -90,9 +99,25 @@ export default class EditPostModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChange(e) {
|
handleChange(e) {
|
||||||
|
const message = e.target.value;
|
||||||
this.setState({
|
this.setState({
|
||||||
editText: e.target.value
|
editText: message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (message.length > Constants.CHARACTER_LIMIT) {
|
||||||
|
const errorMessage = (
|
||||||
|
<FormattedMessage
|
||||||
|
id='create_post.error_message'
|
||||||
|
defaultMessage='Your message is too long. Character count: {length}/{limit}'
|
||||||
|
values={{
|
||||||
|
length: message.length,
|
||||||
|
limit: Constants.CHARACTER_LIMIT
|
||||||
|
}}
|
||||||
|
/>);
|
||||||
|
this.setState({postError: errorMessage});
|
||||||
|
} else {
|
||||||
|
this.setState({postError: ''});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEditKeyPress(e) {
|
handleEditKeyPress(e) {
|
||||||
@@ -195,9 +220,11 @@ export default class EditPostModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var error = (<div className='form-group'><br/></div>);
|
const errorBoxClass = 'edit-post-footer' + (this.state.postError ? ' has-error' : '');
|
||||||
if (this.state.error) {
|
let postError = null;
|
||||||
error = (<div className='form-group has-error'><br/><label className='control-label'>{this.state.error}</label></div>);
|
if (this.state.postError) {
|
||||||
|
const postErrorClass = 'post-error' + (this.state.errorClass ? (' ' + this.state.errorClass) : '');
|
||||||
|
postError = (<label className={postErrorClass}>{this.state.postError}</label>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -242,7 +269,9 @@ export default class EditPostModal extends React.Component {
|
|||||||
id='edit_textbox'
|
id='edit_textbox'
|
||||||
ref='editbox'
|
ref='editbox'
|
||||||
/>
|
/>
|
||||||
{error}
|
<div className={errorBoxClass}>
|
||||||
|
{postError}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='modal-footer'>
|
<div className='modal-footer'>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -31,6 +31,21 @@
|
|||||||
.suggestion-list__content {
|
.suggestion-list__content {
|
||||||
max-height: 150px;
|
max-height: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-post-footer {
|
||||||
|
font-size: 13px;
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
|
.post-error {
|
||||||
|
position: relative;
|
||||||
|
font-weight: normal;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-size: .85em;
|
||||||
|
@include opacity(.55);
|
||||||
|
top: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.row--invite {
|
.row--invite {
|
||||||
|
|||||||
@@ -448,22 +448,16 @@
|
|||||||
padding: 3px 0 0;
|
padding: 3px 0 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.control-label {
|
.post-error {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
position: relative;
|
|
||||||
top: -5px;
|
|
||||||
|
|
||||||
&.post-error {
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: .85em;
|
font-size: .85em;
|
||||||
@include opacity(.55);
|
@include opacity(.55);
|
||||||
color: rgb(51, 51, 51);
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.msg-typing {
|
.msg-typing {
|
||||||
@include opacity(.7);
|
@include opacity(.7);
|
||||||
|
|||||||
@@ -32,14 +32,10 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-label {
|
.post-error {
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
||||||
&.post-error {
|
|
||||||
left: 32px;
|
left: 32px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -865,6 +865,8 @@ export const Constants = {
|
|||||||
MENTION_SPECIAL: 'mention.special',
|
MENTION_SPECIAL: 'mention.special',
|
||||||
DEFAULT_NOTIFICATION_DURATION: 5000,
|
DEFAULT_NOTIFICATION_DURATION: 5000,
|
||||||
STATUS_INTERVAL: 60000,
|
STATUS_INTERVAL: 60000,
|
||||||
|
AUTOCOMPLETE_TIMEOUT: 100,
|
||||||
|
ANIMATION_TIMEOUT: 1000,
|
||||||
SEARCH_TIMEOUT_MILLISECONDS: 100
|
SEARCH_TIMEOUT_MILLISECONDS: 100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user