diff options
author | David Meza <dmeza@users.noreply.github.com> | 2017-08-03 07:59:42 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-08-03 08:59:42 -0400 |
commit | b54d1342990253d3fe4a00c64df27cdd1bb0719b (patch) | |
tree | dadf9452248080b1a976d37430409696091fe52b /webapp/components/channel_header.jsx | |
parent | 19804c4e40340cc4c0093197f71216719ffe4050 (diff) | |
download | chat-b54d1342990253d3fe4a00c64df27cdd1bb0719b.tar.gz chat-b54d1342990253d3fe4a00c64df27cdd1bb0719b.tar.bz2 chat-b54d1342990253d3fe4a00c64df27cdd1bb0719b.zip |
PLT-6484 Add /leave command to leave a channel (#6402)
* PLT-6484 Add /leave command to leave a channel
* Text changes requeted on review.
* PLT-6484 Display the right error message when trying to /leave town-square
* PLT-6484 Be able to execute /leave command in direct and group message channels with the same effect as clicking x
* PLT-6484 Refactor to create new leave_private_channel_modal.jsx
* PLT-6484 Remove previous leave private channel logic to use new leave_private_channel_modal.jsx
* Remove dot in command description. Change localized error when leaving Town square.
* disable /leave command in reply threads on the right-hand sidebar, since it is not obvious which channel you should leave
Diffstat (limited to 'webapp/components/channel_header.jsx')
-rw-r--r-- | webapp/components/channel_header.jsx | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/webapp/components/channel_header.jsx b/webapp/components/channel_header.jsx index 10e568794..bee06c700 100644 --- a/webapp/components/channel_header.jsx +++ b/webapp/components/channel_header.jsx @@ -14,7 +14,6 @@ import ChannelMembersModal from './channel_members_modal.jsx'; import ChannelNotificationsModal from './channel_notifications_modal.jsx'; import DeleteChannelModal from './delete_channel_modal.jsx'; import RenameChannelModal from './rename_channel_modal.jsx'; -import ConfirmModal from './confirm_modal.jsx'; import ToggleModalButton from './toggle_modal_button.jsx'; import ChannelStore from 'stores/channel_store.jsx'; @@ -60,8 +59,6 @@ export default class ChannelHeader extends React.Component { this.initWebrtc = this.initWebrtc.bind(this); this.onBusy = this.onBusy.bind(this); this.openDirectMessageModal = this.openDirectMessageModal.bind(this); - this.createLeaveChannelModal = this.createLeaveChannelModal.bind(this); - this.hideLeaveChannelModal = this.hideLeaveChannelModal.bind(this); const state = this.getStateFromStores(); state.showEditChannelHeaderModal = false; @@ -91,7 +88,6 @@ export default class ChannelHeader extends React.Component { enableFormatting: PreferenceStore.getBool(Preferences.CATEGORY_ADVANCED_SETTINGS, 'formatting', true), isBusy: WebrtcStore.isBusy(), isFavorite: channel && ChannelUtils.isFavoriteChannel(channel), - showLeaveChannelModal: false, pinsOpen: SearchStore.getIsPinnedPosts() }; } @@ -144,9 +140,7 @@ export default class ChannelHeader extends React.Component { handleLeave() { if (this.state.channel.type === Constants.PRIVATE_CHANNEL) { - this.setState({ - showLeaveChannelModal: true - }); + GlobalActions.showLeavePrivateChannelModal(this.state.channel); } else { ChannelActions.leaveChannel(this.state.channel.id); } @@ -233,54 +227,6 @@ export default class ChannelHeader extends React.Component { }); } - hideLeaveChannelModal() { - this.setState({ - showLeaveChannelModal: false - }); - } - - createLeaveChannelModal() { - const title = ( - <FormattedMessage - id='leave_private_channel_modal.title' - defaultMessage='Leave Private Channel {channel}' - values={{ - channel: <b>{this.state.channel.display_name}</b> - }} - /> - ); - - const message = ( - <FormattedMessage - id='leave_private_channel_modal.message' - defaultMessage='Are you sure you wish to leave the private channel {channel}? You must be re-invited in order to re-join this channel in the future.' - values={{ - channel: <b>{this.state.channel.display_name}</b> - }} - /> - ); - - const buttonClass = 'btn btn-danger'; - const button = ( - <FormattedMessage - id='leave_private_channel_modal.leave' - defaultMessage='Yes, leave channel' - /> - ); - - return ( - <ConfirmModal - show={this.state.showLeaveChannelModal} - title={title} - message={message} - confirmButtonClass={buttonClass} - confirmButtonText={button} - onConfirm={() => ChannelActions.leaveChannel(this.state.channel.id)} - onCancel={this.hideLeaveChannelModal} - /> - ); - } - render() { const flagIcon = Constants.FLAG_ICON_SVG; const pinIcon = Constants.PIN_ICON_SVG; @@ -885,8 +831,6 @@ export default class ChannelHeader extends React.Component { ); } - const leaveChannelModal = this.createLeaveChannelModal(); - let pinnedIconClass = 'channel-header__icon'; if (this.state.pinsOpen) { pinnedIconClass += ' active'; @@ -1001,7 +945,6 @@ export default class ChannelHeader extends React.Component { {editHeaderModal} {editPurposeModal} {channelMembersModal} - {leaveChannelModal} <RenameChannelModal show={this.state.showRenameChannelModal} onHide={this.hideRenameChannelModal} |