From 251f000c68ed384923d3b2bc6b3caea9aef2a089 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Mon, 31 Jul 2017 18:54:34 +0200 Subject: [PLT-6710] /rename [text] slash command: Rename the channel (#6570) * /rename [text] slash command: Rename the channel * update strings per review --- webapp/actions/global_actions.jsx | 8 ++++++++ webapp/components/create_post.jsx | 6 ++++++ webapp/components/navbar.jsx | 6 +++--- webapp/stores/modal_store.jsx | 1 + webapp/utils/constants.jsx | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) (limited to 'webapp') diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index dc5617dde..ce14661f6 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -235,6 +235,14 @@ export function showChannelPurposeUpdateModal(channel) { }); } +export function showChannelNameUpdateModal(channel) { + AppDispatcher.handleViewAction({ + type: ActionTypes.TOGGLE_CHANNEL_NAME_UPDATE_MODAL, + value: true, + channel + }); +} + export function showGetPostLinkModal(post) { AppDispatcher.handleViewAction({ type: ActionTypes.TOGGLE_GET_POST_LINK_MODAL, diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx index 328f182a3..e5ead4e84 100644 --- a/webapp/components/create_post.jsx +++ b/webapp/components/create_post.jsx @@ -243,6 +243,12 @@ export default class CreatePost extends React.Component { return; } + if (!isDirectOrGroup && this.state.message.trimRight() === '/rename') { + GlobalActions.showChannelNameUpdateModal(updateChannel); + this.setState({message: ''}); + return; + } + this.doSubmit(e); } diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx index fc2ade7ab..81959f352 100644 --- a/webapp/components/navbar.jsx +++ b/webapp/components/navbar.jsx @@ -115,6 +115,7 @@ export default class Navbar extends React.Component { ModalStore.addModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal); ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.showEditChannelHeaderModal); ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL, this.showChannelPurposeModal); + ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_NAME_UPDATE_MODAL, this.showRenameChannelModal); $('.inner-wrap').click(this.hideSidebars); document.addEventListener('keydown', this.handleQuickSwitchKeyPress); } @@ -128,6 +129,7 @@ export default class Navbar extends React.Component { ModalStore.removeModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal); ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.hideEditChannelHeaderModal); ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL, this.hideChannelPurposeModal); + ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_NAME_UPDATE_MODAL, this.hideRenameChannelModal); document.removeEventListener('keydown', this.handleQuickSwitchKeyPress); } @@ -218,9 +220,7 @@ export default class Navbar extends React.Component { }); } - showRenameChannelModal(e) { - e.preventDefault(); - + showRenameChannelModal() { this.setState({ showRenameChannelModal: true }); diff --git a/webapp/stores/modal_store.jsx b/webapp/stores/modal_store.jsx index 666219d41..34bab780c 100644 --- a/webapp/stores/modal_store.jsx +++ b/webapp/stores/modal_store.jsx @@ -43,6 +43,7 @@ class ModalStoreClass extends EventEmitter { case ActionTypes.TOGGLE_QUICK_SWITCH_MODAL: case ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL: case ActionTypes.TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL: + case ActionTypes.TOGGLE_CHANNEL_NAME_UPDATE_MODAL: this.emit(type, value, args); break; } diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 69492e95c..31211952a 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -176,6 +176,7 @@ export const ActionTypes = keyMirror({ TOGGLE_QUICK_SWITCH_MODAL: null, TOGGLE_CHANNEL_HEADER_UPDATE_MODAL: null, TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL: null, + TOGGLE_CHANNEL_NAME_UPDATE_MODAL: null, SUGGESTION_PRETEXT_CHANGED: null, SUGGESTION_RECEIVED_SUGGESTIONS: null, -- cgit v1.2.3-1-g7c22