summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-06-29 14:06:17 +0200
committerJoram Wilander <jwawilander@gmail.com>2017-06-29 08:06:17 -0400
commit976030ea250bb5b9ae5cf70bddf9b9c54ab07959 (patch)
tree254624406eeba1b44c2a7333de62a07daf991fdd /webapp/components
parent520cedea16c3a4c71c2d11ede89c6a50a81ff8db (diff)
downloadchat-976030ea250bb5b9ae5cf70bddf9b9c54ab07959.tar.gz
chat-976030ea250bb5b9ae5cf70bddf9b9c54ab07959.tar.bz2
chat-976030ea250bb5b9ae5cf70bddf9b9c54ab07959.zip
[PLT-6707] /header [text] slash command: Edit the channel header (#6566)
* add /header slash command * update websocket * updater per review
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/create_post.jsx15
-rw-r--r--webapp/components/navbar.jsx9
2 files changed, 21 insertions, 3 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index d0f2a0afd..8ec671e45 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -76,14 +76,15 @@ export default class CreatePost extends React.Component {
PostStore.clearDraftUploads();
- const channelId = ChannelStore.getCurrentId();
- const draft = PostStore.getDraft(channelId);
-
+ const channel = ChannelStore.getCurrent();
+ const channelId = channel.id;
+ const draft = PostStore.getPostDraft(channelId);
const stats = ChannelStore.getCurrentStats();
const members = stats.member_count - 1;
this.state = {
channelId,
+ channel,
message: draft.message,
uploadsInProgress: draft.uploadsInProgress,
fileInfos: draft.fileInfos,
@@ -213,12 +214,20 @@ export default class CreatePost extends React.Component {
handleSubmit(e) {
const stats = ChannelStore.getCurrentStats();
const members = stats.member_count - 1;
+ const updateChannel = ChannelStore.getCurrent();
if ((this.state.message.includes('@all') || this.state.message.includes('@channel')) && members >= Constants.NOTIFY_ALL_MEMBERS) {
this.setState({totalMembers: members});
this.showNotifyAllModal();
return;
}
+
+ if (this.state.message.endsWith('/header ')) {
+ GlobalActions.showChannelHeaderUpdateModal(updateChannel);
+ this.setState({message: ''});
+ return;
+ }
+
this.doSubmit(e);
}
diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx
index 0f8de01a3..b27e22709 100644
--- a/webapp/components/navbar.jsx
+++ b/webapp/components/navbar.jsx
@@ -55,6 +55,7 @@ export default class Navbar extends React.Component {
this.showSearch = this.showSearch.bind(this);
this.showEditChannelHeaderModal = this.showEditChannelHeaderModal.bind(this);
+ this.hideEditChannelHeaderModal = this.hideEditChannelHeaderModal.bind(this);
this.showRenameChannelModal = this.showRenameChannelModal.bind(this);
this.hideRenameChannelModal = this.hideRenameChannelModal.bind(this);
this.isStateValid = this.isStateValid.bind(this);
@@ -110,6 +111,7 @@ export default class Navbar extends React.Component {
UserStore.addChangeListener(this.onChange);
PreferenceStore.addChangeListener(this.onChange);
ModalStore.addModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal);
+ ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.showEditChannelHeaderModal);
$('.inner-wrap').click(this.hideSidebars);
document.addEventListener('keydown', this.handleQuickSwitchKeyPress);
}
@@ -121,6 +123,7 @@ export default class Navbar extends React.Component {
UserStore.removeChangeListener(this.onChange);
PreferenceStore.removeChangeListener(this.onChange);
ModalStore.removeModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal);
+ ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.hideEditChannelHeaderModal);
document.removeEventListener('keydown', this.handleQuickSwitchKeyPress);
}
@@ -193,6 +196,12 @@ export default class Navbar extends React.Component {
});
}
+ hideEditChannelHeaderModal() {
+ this.setState({
+ showEditChannelHeaderModal: false
+ });
+ }
+
showRenameChannelModal(e) {
e.preventDefault();