summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-11-17 11:10:33 -0500
committerhmhealey <harrisonmhealey@gmail.com>2015-11-17 11:10:33 -0500
commit3d572be2f3bb0d4b6b2eb83b69a209234f807231 (patch)
tree4aa5cc719832ee6a283b75a0babb05896dec03fa
parent69e378c556e817ce494af8511220389407dbed89 (diff)
downloadchat-3d572be2f3bb0d4b6b2eb83b69a209234f807231.tar.gz
chat-3d572be2f3bb0d4b6b2eb83b69a209234f807231.tar.bz2
chat-3d572be2f3bb0d4b6b2eb83b69a209234f807231.zip
Converted DeleteChannelModal to React-Bootstrap
-rw-r--r--web/react/components/channel_header.jsx12
-rw-r--r--web/react/components/delete_channel_modal.jsx116
-rw-r--r--web/react/components/navbar.jsx12
-rw-r--r--web/react/pages/channel.jsx6
4 files changed, 53 insertions, 93 deletions
diff --git a/web/react/components/channel_header.jsx b/web/react/components/channel_header.jsx
index a0676e929..ffe7cbb5d 100644
--- a/web/react/components/channel_header.jsx
+++ b/web/react/components/channel_header.jsx
@@ -9,6 +9,7 @@ const ChannelInfoModal = require('./channel_info_modal.jsx');
const ChannelInviteModal = require('./channel_invite_modal.jsx');
const ChannelMembersModal = require('./channel_members_modal.jsx');
const ChannelNotificationsModal = require('./channel_notifications_modal.jsx');
+const DeleteChannelModal = require('./delete_channel_modal.jsx');
const ToggleModalButton = require('./toggle_modal_button.jsx');
const ChannelStore = require('../stores/channel_store.jsx');
@@ -300,16 +301,13 @@ export default class ChannelHeader extends React.Component {
key='delete_channel'
role='presentation'
>
- <a
+ <ToggleModalButton
role='menuitem'
- href='#'
- data-toggle='modal'
- data-target='#delete_channel'
- data-title={channel.display_name}
- data-channelid={channel.id}
+ dialogType={DeleteChannelModal}
+ dialogProps={{channel}}
>
{'Delete '}{channelTerm}{'...'}
- </a>
+ </ToggleModalButton>
</li>
);
}
diff --git a/web/react/components/delete_channel_modal.jsx b/web/react/components/delete_channel_modal.jsx
index b7d633b38..17694e779 100644
--- a/web/react/components/delete_channel_modal.jsx
+++ b/web/react/components/delete_channel_modal.jsx
@@ -1,102 +1,72 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-const Client = require('../utils/client.jsx');
const AsyncClient = require('../utils/async_client.jsx');
-const ChannelStore = require('../stores/channel_store.jsx');
-var TeamStore = require('../stores/team_store.jsx');
+const Client = require('../utils/client.jsx');
+const Modal = require('./modal.jsx');
+const TeamStore = require('../stores/team_store.jsx');
+const Utils = require('../utils/utils.jsx');
export default class DeleteChannelModal extends React.Component {
constructor(props) {
super(props);
this.handleDelete = this.handleDelete.bind(this);
- this.onShow = this.onShow.bind(this);
-
- this.state = {
- title: '',
- channelId: ''
- };
}
+
handleDelete() {
- if (this.state.channelId.length !== 26) {
+ if (this.props.channel.id.length !== 26) {
return;
}
- Client.deleteChannel(this.state.channelId,
- function handleDeleteSuccess() {
+ Client.deleteChannel(
+ this.props.channel.id,
+ () => {
AsyncClient.getChannels(true);
window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/town-square';
},
- function handleDeleteError(err) {
+ (err) => {
AsyncClient.dispatchError(err, 'handleDelete');
}
);
}
- onShow(e) {
- var button = $(e.relatedTarget);
- this.setState({
- title: button.attr('data-title'),
- channelId: button.attr('data-channelid')
- });
- }
- componentDidMount() {
- $(ReactDOM.findDOMNode(this.refs.modal)).on('show.bs.modal', this.onShow);
- }
+
render() {
- const channel = ChannelStore.getCurrent();
- let channelType = 'channel';
- if (channel && channel.type === 'P') {
- channelType = 'private group';
- }
+ const channelTerm = Utils.getChannelTerm(this.props.channel.type).toLowerCase();
return (
- <div
- className='modal fade'
- ref='modal'
- id='delete_channel'
- role='dialog'
- tabIndex='-1'
- aria-hidden='true'
+ <Modal
+ show={this.props.show}
+ onHide={this.props.onHide}
>
- <div className='modal-dialog'>
- <div className='modal-content'>
- <div className='modal-header'>
- <button
- type='button'
- className='close'
- data-dismiss='modal'
- aria-label='Close'
- >
- <span aria-hidden='true'>&times;</span>
- </button>
- <h4 className='modal-title'>Confirm DELETE Channel</h4>
- </div>
- <div className='modal-body'>
- <p>
- Are you sure you wish to delete the {this.state.title} {channelType}?
- </p>
- </div>
- <div className='modal-footer'>
- <button
- type='button'
- className='btn btn-default'
- data-dismiss='modal'
- >
- Cancel
- </button>
- <button
- type='button'
- className='btn btn-danger'
- data-dismiss='modal'
- onClick={this.handleDelete}
- >
- Delete
- </button>
- </div>
- </div>
- </div>
- </div>
+ <Modal.Header closeButton={true}>{'Confirm DELETE Channel'}</Modal.Header>
+ <Modal.Body>
+ {`Are you sure you wish to delete the ${this.props.channel.display_name} ${channelTerm}?`}
+ </Modal.Body>
+ <Modal.Footer>
+ <button
+ type='button'
+ className='btn btn-default'
+ onClick={this.props.onHide}
+ >
+ {'Cancel'}
+ </button>
+ <button
+ type='button'
+ className='btn btn-danger'
+ data-dismiss='modal'
+ onClick={this.handleDelete}
+ >
+ {'Delete'}
+ </button>
+ </Modal.Footer>
+ </Modal>
);
}
}
+
+DeleteChannelModal.propTypes = {
+ show: React.PropTypes.bool.isRequired,
+ onHide: React.PropTypes.func.isRequired,
+ channel: React.PropTypes.object.isRequired
+};
diff --git a/web/react/components/navbar.jsx b/web/react/components/navbar.jsx
index 85be96a92..1fcfabccd 100644
--- a/web/react/components/navbar.jsx
+++ b/web/react/components/navbar.jsx
@@ -8,6 +8,7 @@ const ChannelMembersModal = require('./channel_members_modal.jsx');
const ChannelInfoModal = require('./channel_info_modal.jsx');
const ChannelInviteModal = require('./channel_invite_modal.jsx');
const ChannelNotificationsModal = require('./channel_notifications_modal.jsx');
+const DeleteChannelModal = require('./delete_channel_modal.jsx');
const ToggleModalButton = require('./toggle_modal_button.jsx');
const UserStore = require('../stores/user_store.jsx');
@@ -195,16 +196,13 @@ export default class Navbar extends React.Component {
deleteChannelOption = (
<li role='presentation'>
- <a
+ <ToggleModalButton
role='menuitem'
- href='#'
- data-toggle='modal'
- data-target='#delete_channel'
- data-title={channel.display_name}
- data-channelid={channel.id}
+ dialogType={DeleteChannelModal}
+ dialogProps={{channel}}
>
{'Delete Channel...'}
- </a>
+ </ToggleModalButton>
</li>
);
}
diff --git a/web/react/pages/channel.jsx b/web/react/pages/channel.jsx
index b0c494a55..9aba1a564 100644
--- a/web/react/pages/channel.jsx
+++ b/web/react/pages/channel.jsx
@@ -10,7 +10,6 @@ var ErrorStore = require('../stores/error_store.jsx');
var MentionList = require('../components/mention_list.jsx');
var GetLinkModal = require('../components/get_link_modal.jsx');
var EditChannelModal = require('../components/edit_channel_modal.jsx');
-var DeleteChannelModal = require('../components/delete_channel_modal.jsx');
var RenameChannelModal = require('../components/rename_channel_modal.jsx');
var EditPostModal = require('../components/edit_post_modal.jsx');
var DeletePostModal = require('../components/delete_post_modal.jsx');
@@ -101,11 +100,6 @@ function setupChannelPage(props) {
);
ReactDOM.render(
- <DeleteChannelModal />,
- document.getElementById('delete_channel_modal')
- );
-
- ReactDOM.render(
<RenameChannelModal />,
document.getElementById('rename_channel_modal')
);