Ported PostDeletedModal to React-Bootstrap
Этот коммит содержится в:
@@ -7,6 +7,7 @@ import * as AsyncClient from '../utils/async_client.jsx';
|
|||||||
import SocketStore from '../stores/socket_store.jsx';
|
import SocketStore from '../stores/socket_store.jsx';
|
||||||
import ChannelStore from '../stores/channel_store.jsx';
|
import ChannelStore from '../stores/channel_store.jsx';
|
||||||
import UserStore from '../stores/user_store.jsx';
|
import UserStore from '../stores/user_store.jsx';
|
||||||
|
import PostDeletedModal from './post_deleted_modal.jsx';
|
||||||
import PostStore from '../stores/post_store.jsx';
|
import PostStore from '../stores/post_store.jsx';
|
||||||
import PreferenceStore from '../stores/preference_store.jsx';
|
import PreferenceStore from '../stores/preference_store.jsx';
|
||||||
import Textbox from './textbox.jsx';
|
import Textbox from './textbox.jsx';
|
||||||
@@ -60,6 +61,8 @@ class CreateComment extends React.Component {
|
|||||||
this.handleResize = this.handleResize.bind(this);
|
this.handleResize = this.handleResize.bind(this);
|
||||||
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
this.onPreferenceChange = this.onPreferenceChange.bind(this);
|
||||||
this.focusTextbox = this.focusTextbox.bind(this);
|
this.focusTextbox = this.focusTextbox.bind(this);
|
||||||
|
this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
|
||||||
|
this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this);
|
||||||
|
|
||||||
PostStore.clearCommentDraftUploads();
|
PostStore.clearCommentDraftUploads();
|
||||||
|
|
||||||
@@ -70,7 +73,8 @@ class CreateComment extends React.Component {
|
|||||||
previews: draft.previews,
|
previews: draft.previews,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
windowWidth: Utils.windowWidth(),
|
windowWidth: Utils.windowWidth(),
|
||||||
ctrlSend: PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter')
|
ctrlSend: PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
|
||||||
|
showPostDeletedModal: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -141,8 +145,10 @@ class CreateComment extends React.Component {
|
|||||||
PostStore.storePendingPost(post);
|
PostStore.storePendingPost(post);
|
||||||
PostStore.storeCommentDraft(this.props.rootId, null);
|
PostStore.storeCommentDraft(this.props.rootId, null);
|
||||||
|
|
||||||
Client.createPost(post, ChannelStore.getCurrent(),
|
Client.createPost(
|
||||||
function handlePostSuccess(data) {
|
post,
|
||||||
|
ChannelStore.getCurrent(),
|
||||||
|
(data) => {
|
||||||
AsyncClient.getPosts(this.props.channelId);
|
AsyncClient.getPosts(this.props.channelId);
|
||||||
|
|
||||||
const channel = ChannelStore.get(this.props.channelId);
|
const channel = ChannelStore.get(this.props.channelId);
|
||||||
@@ -155,27 +161,30 @@ class CreateComment extends React.Component {
|
|||||||
type: ActionTypes.RECEIVED_POST,
|
type: ActionTypes.RECEIVED_POST,
|
||||||
post: data
|
post: data
|
||||||
});
|
});
|
||||||
}.bind(this),
|
},
|
||||||
function handlePostError(err) {
|
(err) => {
|
||||||
let state = {};
|
|
||||||
|
|
||||||
if (err.id === 'api.post.create_post.root_id.app_error') {
|
if (err.id === 'api.post.create_post.root_id.app_error') {
|
||||||
PostStore.removePendingPost(post.channel_id, post.pending_post_id);
|
this.showPostDeletedModal();
|
||||||
|
|
||||||
if ($('#post_deleted').length > 0) {
|
PostStore.removePendingPost(post.channel_id, post.pending_post_id);
|
||||||
$('#post_deleted').modal('show');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
post.state = Constants.POST_FAILED;
|
post.state = Constants.POST_FAILED;
|
||||||
PostStore.updatePendingPost(post);
|
PostStore.updatePendingPost(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.submitting = false;
|
this.setState({
|
||||||
this.setState(state);
|
submitting: false
|
||||||
}.bind(this)
|
});
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
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 (this.state.ctrlSend && e.ctrlKey || !this.state.ctrlSend) {
|
if (this.state.ctrlSend && e.ctrlKey || !this.state.ctrlSend) {
|
||||||
@@ -312,6 +321,16 @@ class CreateComment extends React.Component {
|
|||||||
this.refs.textbox.focus();
|
this.refs.textbox.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
showPostDeletedModal() {
|
||||||
|
this.setState({
|
||||||
|
showPostDeletedModal: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hidePostDeletedModal() {
|
||||||
|
this.setState({
|
||||||
|
showPostDeletedModal: false
|
||||||
|
});
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
let serverError = null;
|
let serverError = null;
|
||||||
if (this.state.serverError) {
|
if (this.state.serverError) {
|
||||||
@@ -411,6 +430,10 @@ class CreateComment extends React.Component {
|
|||||||
{serverError}
|
{serverError}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<PostDeletedModal
|
||||||
|
show={this.state.showPostDeletedModal}
|
||||||
|
onHide={this.hidePostDeletedModal}
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import MsgTyping from './msg_typing.jsx';
|
|||||||
import Textbox from './textbox.jsx';
|
import Textbox from './textbox.jsx';
|
||||||
import FileUpload from './file_upload.jsx';
|
import FileUpload from './file_upload.jsx';
|
||||||
import FilePreview from './file_preview.jsx';
|
import FilePreview from './file_preview.jsx';
|
||||||
|
import PostDeletedModal from './post_deleted_modal.jsx';
|
||||||
import TutorialTip from './tutorial/tutorial_tip.jsx';
|
import TutorialTip from './tutorial/tutorial_tip.jsx';
|
||||||
|
|
||||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||||
@@ -64,6 +65,8 @@ class CreatePost extends React.Component {
|
|||||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
this.sendMessage = this.sendMessage.bind(this);
|
this.sendMessage = this.sendMessage.bind(this);
|
||||||
this.focusTextbox = this.focusTextbox.bind(this);
|
this.focusTextbox = this.focusTextbox.bind(this);
|
||||||
|
this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
|
||||||
|
this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this);
|
||||||
|
|
||||||
PostStore.clearDraftUploads();
|
PostStore.clearDraftUploads();
|
||||||
|
|
||||||
@@ -77,7 +80,8 @@ class CreatePost extends React.Component {
|
|||||||
submitting: false,
|
submitting: false,
|
||||||
initialText: draft.messageText,
|
initialText: draft.messageText,
|
||||||
ctrlSend: false,
|
ctrlSend: false,
|
||||||
showTutorialTip: false
|
showTutorialTip: false,
|
||||||
|
showPostDeletedModal: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
getCurrentDraft() {
|
getCurrentDraft() {
|
||||||
@@ -157,7 +161,6 @@ class CreatePost extends React.Component {
|
|||||||
post.pending_post_id = `${userId}:${time}`;
|
post.pending_post_id = `${userId}:${time}`;
|
||||||
post.user_id = userId;
|
post.user_id = userId;
|
||||||
post.create_at = time;
|
post.create_at = time;
|
||||||
post.root_id = this.state.rootId;
|
|
||||||
post.parent_id = this.state.parentId;
|
post.parent_id = this.state.parentId;
|
||||||
|
|
||||||
const channel = ChannelStore.get(this.state.channelId);
|
const channel = ChannelStore.get(this.state.channelId);
|
||||||
@@ -177,20 +180,19 @@ class CreatePost extends React.Component {
|
|||||||
EventHelpers.emitPostRecievedEvent(data);
|
EventHelpers.emitPostRecievedEvent(data);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
const state = {};
|
|
||||||
|
|
||||||
if (err.id === 'api.post.create_post.root_id.app_error') {
|
if (err.id === 'api.post.create_post.root_id.app_error') {
|
||||||
if ($('#post_deleted').length > 0) {
|
// this should never actually happen since you can't reply from this textbox
|
||||||
$('#post_deleted').modal('show');
|
this.showPostDeletedModal();
|
||||||
}
|
|
||||||
PostStore.removePendingPost(post.pending_post_id);
|
PostStore.removePendingPost(post.pending_post_id);
|
||||||
} else {
|
} else {
|
||||||
post.state = Constants.POST_FAILED;
|
post.state = Constants.POST_FAILED;
|
||||||
PostStore.updatePendingPost(post);
|
PostStore.updatePendingPost(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.submitting = false;
|
this.setState({
|
||||||
this.setState(state);
|
submitting: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -374,6 +376,16 @@ class CreatePost extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
showPostDeletedModal() {
|
||||||
|
this.setState({
|
||||||
|
showPostDeletedModal: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hidePostDeletedModal() {
|
||||||
|
this.setState({
|
||||||
|
showPostDeletedModal: false
|
||||||
|
});
|
||||||
|
}
|
||||||
createTutorialTip() {
|
createTutorialTip() {
|
||||||
const screens = [];
|
const screens = [];
|
||||||
|
|
||||||
@@ -479,6 +491,10 @@ class CreatePost extends React.Component {
|
|||||||
{serverError}
|
{serverError}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<PostDeletedModal
|
||||||
|
show={this.state.showPostDeletedModal}
|
||||||
|
onHide={this.hidePostDeletedModal}
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import UserStore from '../stores/user_store.jsx';
|
|
||||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||||
import Constants from '../utils/constants.jsx';
|
import Constants from '../utils/constants.jsx';
|
||||||
|
|
||||||
@@ -9,20 +8,22 @@ import {FormattedMessage} from 'mm-intl';
|
|||||||
|
|
||||||
var ActionTypes = Constants.ActionTypes;
|
var ActionTypes = Constants.ActionTypes;
|
||||||
|
|
||||||
|
const Modal = ReactBootstrap.Modal;
|
||||||
|
|
||||||
export default class PostDeletedModal extends React.Component {
|
export default class PostDeletedModal extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.handleClose = this.handleClose.bind(this);
|
this.handleHide = this.handleHide.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {};
|
shouldComponentUpdate(nextProps) {
|
||||||
|
return nextProps.show !== this.props.show;
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
|
||||||
$(ReactDOM.findDOMNode(this.refs.modal)).on('hidden.bs.modal', () => {
|
handleHide(e) {
|
||||||
this.handleClose();
|
e.preventDefault();
|
||||||
});
|
|
||||||
}
|
|
||||||
handleClose() {
|
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.RECEIVED_SEARCH,
|
type: ActionTypes.RECEIVED_SEARCH,
|
||||||
results: null
|
results: null
|
||||||
@@ -39,67 +40,50 @@ export default class PostDeletedModal extends React.Component {
|
|||||||
type: ActionTypes.RECEIVED_POST_SELECTED,
|
type: ActionTypes.RECEIVED_POST_SELECTED,
|
||||||
results: null
|
results: null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.props.onHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var currentUser = UserStore.getCurrentUser();
|
return (
|
||||||
|
<Modal
|
||||||
if (currentUser != null) {
|
show={this.props.show}
|
||||||
return (
|
onHide={this.handleHide}
|
||||||
<div
|
>
|
||||||
className='modal fade'
|
<Modal.Header closeButton={true}>
|
||||||
ref='modal'
|
<Modal.Title>
|
||||||
id='post_deleted'
|
<FormattedMessage
|
||||||
tabIndex='-1'
|
id='post_delete.notPosted'
|
||||||
role='dialog'
|
defaultMessage='Comment could not be posted'
|
||||||
aria-hidden='true'
|
/>
|
||||||
>
|
</Modal.Title>
|
||||||
<div className='modal-dialog'>
|
</Modal.Header>
|
||||||
<div className='modal-content'>
|
<Modal.Body>
|
||||||
<div className='modal-header'>
|
<p>
|
||||||
<button
|
<FormattedMessage
|
||||||
type='button'
|
id='post_delete.someone'
|
||||||
className='close'
|
defaultMessage='Someone deleted the message on which you tried to post a comment.'
|
||||||
data-dismiss='modal'
|
/>
|
||||||
aria-label='Close'
|
</p>
|
||||||
>
|
</Modal.Body>
|
||||||
<span aria-hidden='true'>{'×'}</span>
|
<Modal.Footer>
|
||||||
</button>
|
<button
|
||||||
<h4
|
type='button'
|
||||||
className='modal-title'
|
className='btn btn-primary'
|
||||||
id='myModalLabel'
|
onClick={this.handleHide}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='post_delete.notPosted'
|
id='post_delete.okay'
|
||||||
defaultMessage='Comment could not be posted'
|
defaultMessage='Okay'
|
||||||
/>
|
/>
|
||||||
</h4>
|
</button>
|
||||||
</div>
|
</Modal.Footer>
|
||||||
<div className='modal-body'>
|
</Modal>
|
||||||
<p>
|
);
|
||||||
<FormattedMessage
|
|
||||||
id='post_delete.someone'
|
|
||||||
defaultMessage='Someone deleted the message on which you tried to post a comment.'
|
|
||||||
/>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className='modal-footer'>
|
|
||||||
<button
|
|
||||||
type='button'
|
|
||||||
className='btn btn-primary'
|
|
||||||
data-dismiss='modal'
|
|
||||||
>
|
|
||||||
<FormattedMessage
|
|
||||||
id='post_delete.okay'
|
|
||||||
defaultMessage='Okay'
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div/>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PostDeletedModal.propTypes = {
|
||||||
|
show: React.PropTypes.bool.isRequired,
|
||||||
|
onHide: React.PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import RenameChannelModal from '../components/rename_channel_modal.jsx';
|
|||||||
import EditPostModal from '../components/edit_post_modal.jsx';
|
import EditPostModal from '../components/edit_post_modal.jsx';
|
||||||
import DeletePostModal from '../components/delete_post_modal.jsx';
|
import DeletePostModal from '../components/delete_post_modal.jsx';
|
||||||
import MoreChannelsModal from '../components/more_channels.jsx';
|
import MoreChannelsModal from '../components/more_channels.jsx';
|
||||||
import PostDeletedModal from '../components/post_deleted_modal.jsx';
|
|
||||||
import TeamSettingsModal from '../components/team_settings_modal.jsx';
|
import TeamSettingsModal from '../components/team_settings_modal.jsx';
|
||||||
import RemovedFromChannelModal from '../components/removed_from_channel_modal.jsx';
|
import RemovedFromChannelModal from '../components/removed_from_channel_modal.jsx';
|
||||||
import RegisterAppModal from '../components/register_app_modal.jsx';
|
import RegisterAppModal from '../components/register_app_modal.jsx';
|
||||||
@@ -79,7 +78,6 @@ class Root extends React.Component {
|
|||||||
<MoreChannelsModal />
|
<MoreChannelsModal />
|
||||||
<EditPostModal />
|
<EditPostModal />
|
||||||
<DeletePostModal />
|
<DeletePostModal />
|
||||||
<PostDeletedModal />
|
|
||||||
<RemovedFromChannelModal />
|
<RemovedFromChannelModal />
|
||||||
<RegisterAppModal />
|
<RegisterAppModal />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user