* MM-21368 Notify user when editing message that's too long * Disable 'Save' button to prevent edits from being posted * Display error message specific to the message size and allows max, instead of the current, default "Invalid Message" error. * Split message length error into text (left justified) and counts (right justified) UX guidance from PR review * UX Review: Wrap for longer error text + spacing adjustment * UX Review: Align split messages to top + add spacing in-between * UX Review: Align error message box padding with content
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {bindActionCreators} from 'redux';
|
|
import {connect} from 'react-redux';
|
|
|
|
import {editPost} from '@mm-redux/actions/posts';
|
|
import {getConfig} from '@mm-redux/selectors/entities/general';
|
|
import {getTheme} from '@mm-redux/selectors/entities/preferences';
|
|
|
|
import {MAX_MESSAGE_LENGTH_FALLBACK} from '@constants/post_draft';
|
|
import {getDimensions, isLandscape} from '@selectors/device';
|
|
|
|
import EditPost from './edit_post';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const config = getConfig(state);
|
|
|
|
return {
|
|
...getDimensions(state),
|
|
isLandscape: isLandscape(state),
|
|
maxMessageLength: (config && parseInt(config.MaxPostSize || 0, 10)) || MAX_MESSAGE_LENGTH_FALLBACK,
|
|
post: ownProps.post,
|
|
theme: getTheme(state),
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
actions: bindActionCreators({
|
|
editPost,
|
|
}, dispatch),
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(EditPost);
|