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/navbar.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/navbar.jsx')
-rw-r--r-- | webapp/components/navbar.jsx | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx index 81959f352..0217dc15c 100644 --- a/webapp/components/navbar.jsx +++ b/webapp/components/navbar.jsx @@ -12,7 +12,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 StatusIcon from './status_icon.jsx'; @@ -75,9 +74,6 @@ export default class Navbar extends React.Component { this.openDirectMessageModal = this.openDirectMessageModal.bind(this); this.getPinnedPosts = this.getPinnedPosts.bind(this); - this.createLeaveChannelModal = this.createLeaveChannelModal.bind(this); - this.hideLeaveChannelModal = this.hideLeaveChannelModal.bind(this); - const state = this.getStateFromStores(); state.showEditChannelPurposeModal = false; state.showEditChannelHeaderModal = false; @@ -97,8 +93,7 @@ export default class Navbar extends React.Component { users: [], userCount: ChannelStore.getCurrentStats().member_count, currentUser: UserStore.getCurrentUser(), - isFavorite: channel && ChannelUtils.isFavoriteChannel(channel), - showLeaveChannelModal: false + isFavorite: channel && ChannelUtils.isFavoriteChannel(channel) }; } @@ -139,9 +134,7 @@ export default class Navbar 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); } @@ -739,54 +732,6 @@ export default class Navbar extends React.Component { return buttons; } - 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} - /> - ); - } - getTeammateStatus() { const channel = this.state.channel; @@ -961,8 +906,6 @@ export default class Navbar extends React.Component { var channelMenuDropdown = this.createDropdown(channel, channelTitle, isSystemAdmin, isTeamAdmin, isChannelAdmin, isDirect, isGroup, popoverContent); - const leaveChannelModal = this.createLeaveChannelModal(); - return ( <div> <nav @@ -979,7 +922,6 @@ export default class Navbar extends React.Component { </nav> {editChannelHeaderModal} {editChannelPurposeModal} - {leaveChannelModal} {renameChannelModal} {channelMembersModal} {quickSwitchModal} |