Switched ChannelInviteModal to use a ToggleModalButton wherever possible

Этот коммит содержится в:
hmhealey
2015-12-03 10:31:05 -05:00
родитель ffd5d55465
Коммит d09ace15f2
6 изменённых файлов: 30 добавлений и 47 удалений

Просмотреть файл

@@ -40,7 +40,6 @@ export default class ChannelHeader extends React.Component {
const state = this.getStateFromStores(); const state = this.getStateFromStores();
state.showEditChannelPurposeModal = false; state.showEditChannelPurposeModal = false;
state.showInviteModal = false;
state.showMembersModal = false; state.showMembersModal = false;
this.state = state; this.state = state;
} }
@@ -201,13 +200,12 @@ export default class ChannelHeader extends React.Component {
key='add_members' key='add_members'
role='presentation' role='presentation'
> >
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={ChannelInviteModal}
onClick={() => this.setState({showInviteModal: true})}
> >
{'Add Members'} {'Add Members'}
</a> </ToggleModalButton>
</li> </li>
); );
@@ -402,10 +400,6 @@ export default class ChannelHeader extends React.Component {
onModalDismissed={() => this.setState({showEditChannelPurposeModal: false})} onModalDismissed={() => this.setState({showEditChannelPurposeModal: false})}
channel={channel} channel={channel}
/> />
<ChannelInviteModal
show={this.state.showInviteModal}
onModalDismissed={() => this.setState({showInviteModal: false})}
/>
<ChannelMembersModal <ChannelMembersModal
show={this.state.showMembersModal} show={this.state.showMembersModal}
onModalDismissed={() => this.setState({showMembersModal: false})} onModalDismissed={() => this.setState({showMembersModal: false})}

Просмотреть файл

@@ -157,7 +157,7 @@ export default class ChannelInviteModal extends React.Component {
<Modal <Modal
dialogClassName='more-modal' dialogClassName='more-modal'
show={this.props.show} show={this.props.show}
onHide={this.props.onModalDismissed} onHide={this.props.onHide}
> >
<Modal.Header closeButton={true}> <Modal.Header closeButton={true}>
<Modal.Title>{'Add New Members to '}<span className='name'>{this.state.channelName}</span></Modal.Title> <Modal.Title>{'Add New Members to '}<span className='name'>{this.state.channelName}</span></Modal.Title>
@@ -173,7 +173,7 @@ export default class ChannelInviteModal extends React.Component {
<button <button
type='button' type='button'
className='btn btn-default' className='btn btn-default'
onClick={this.props.onModalDismissed} onClick={this.props.onHide}
> >
{'Close'} {'Close'}
</button> </button>
@@ -185,5 +185,5 @@ export default class ChannelInviteModal extends React.Component {
ChannelInviteModal.propTypes = { ChannelInviteModal.propTypes = {
show: React.PropTypes.bool.isRequired, show: React.PropTypes.bool.isRequired,
onModalDismissed: React.PropTypes.func.isRequired onHide: React.PropTypes.func.isRequired
}; };

Просмотреть файл

@@ -205,7 +205,7 @@ export default class ChannelMembersModal extends React.Component {
</Modal> </Modal>
<ChannelInviteModal <ChannelInviteModal
show={this.state.showInviteModal} show={this.state.showInviteModal}
onModalDismissed={() => this.setState({showInviteModal: false})} onHide={() => this.setState({showInviteModal: false})}
/> />
</div> </div>
); );

Просмотреть файл

@@ -44,7 +44,6 @@ export default class Navbar extends React.Component {
state.showEditChannelPurposeModal = false; state.showEditChannelPurposeModal = false;
state.showEditChannelHeaderModal = false; state.showEditChannelHeaderModal = false;
state.showMembersModal = false; state.showMembersModal = false;
state.showInviteModal = false;
this.state = state; this.state = state;
} }
getStateFromStores() { getStateFromStores() {
@@ -171,13 +170,12 @@ export default class Navbar extends React.Component {
if (!isDirect && !ChannelStore.isDefault(channel)) { if (!isDirect && !ChannelStore.isDefault(channel)) {
addMembersOption = ( addMembersOption = (
<li role='presentation'> <li role='presentation'>
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={ChannelInviteModal}
onClick={() => this.setState({showInviteModal: true})}
> >
{'Add Members'} {'Add Members'}
</a> </ToggleModalButton>
</li> </li>
); );
@@ -476,10 +474,6 @@ export default class Navbar extends React.Component {
show={this.state.showMembersModal} show={this.state.showMembersModal}
onModalDismissed={() => this.setState({showMembersModal: false})} onModalDismissed={() => this.setState({showMembersModal: false})}
/> />
<ChannelInviteModal
show={this.state.showInviteModal}
onModalDismissed={() => this.setState({showInviteModal: false})}
/>
</div> </div>
); );
} }

Просмотреть файл

@@ -3,7 +3,6 @@
import PostsView from './posts_view.jsx'; import PostsView from './posts_view.jsx';
import LoadingScreen from './loading_screen.jsx'; import LoadingScreen from './loading_screen.jsx';
import ChannelInviteModal from './channel_invite_modal.jsx';
import ChannelStore from '../stores/channel_store.jsx'; import ChannelStore from '../stores/channel_store.jsx';
import PostStore from '../stores/post_store.jsx'; import PostStore from '../stores/post_store.jsx';
@@ -177,7 +176,7 @@ export default class PostsViewContainer extends React.Component {
loadMorePostsBottomClicked={() => {}} loadMorePostsBottomClicked={() => {}}
showMoreMessagesTop={!this.state.atTop[this.state.currentChannelIndex]} showMoreMessagesTop={!this.state.atTop[this.state.currentChannelIndex]}
showMoreMessagesBottom={false} showMoreMessagesBottom={false}
introText={channel ? createChannelIntroMessage(channel, () => this.setState({showInviteModal: true})) : null} introText={channel ? createChannelIntroMessage(channel) : null}
messageSeparatorTime={this.state.currentLastViewed} messageSeparatorTime={this.state.currentLastViewed}
/> />
); );
@@ -194,10 +193,6 @@ export default class PostsViewContainer extends React.Component {
return ( return (
<div id='post-list'> <div id='post-list'>
{postListCtls} {postListCtls}
<ChannelInviteModal
show={this.state.showInviteModal}
onModalDismissed={() => this.setState({showInviteModal: false})}
/>
</div> </div>
); );
} }

Просмотреть файл

@@ -2,6 +2,7 @@
// See License.txt for license information. // See License.txt for license information.
import * as Utils from './utils.jsx'; import * as Utils from './utils.jsx';
import ChannelInviteModal from '../components/channel_invite_modal.jsx';
import EditChannelHeaderModal from '../components/edit_channel_header_modal.jsx'; import EditChannelHeaderModal from '../components/edit_channel_header_modal.jsx';
import ToggleModalButton from '../components/toggle_modal_button.jsx'; import ToggleModalButton from '../components/toggle_modal_button.jsx';
import UserProfile from '../components/user_profile.jsx'; import UserProfile from '../components/user_profile.jsx';
@@ -10,15 +11,15 @@ import Constants from '../utils/constants.jsx';
import TeamStore from '../stores/team_store.jsx'; import TeamStore from '../stores/team_store.jsx';
import * as EventHelpers from '../dispatcher/event_helpers.jsx'; import * as EventHelpers from '../dispatcher/event_helpers.jsx';
export function createChannelIntroMessage(channel, showInviteModal) { export function createChannelIntroMessage(channel) {
if (channel.type === 'D') { if (channel.type === 'D') {
return createDMIntroMessage(channel); return createDMIntroMessage(channel);
} else if (ChannelStore.isDefault(channel)) { } else if (ChannelStore.isDefault(channel)) {
return createDefaultIntroMessage(channel); return createDefaultIntroMessage(channel);
} else if (channel.name === Constants.OFFTOPIC_CHANNEL) { } else if (channel.name === Constants.OFFTOPIC_CHANNEL) {
return createOffTopicIntroMessage(channel, showInviteModal); return createOffTopicIntroMessage(channel);
} else if (channel.type === 'O' || channel.type === 'P') { } else if (channel.type === 'O' || channel.type === 'P') {
return createStandardIntroMessage(channel, showInviteModal); return createStandardIntroMessage(channel);
} }
} }
@@ -62,7 +63,7 @@ export function createDMIntroMessage(channel) {
); );
} }
export function createOffTopicIntroMessage(channel, showInviteModal) { export function createOffTopicIntroMessage(channel) {
return ( return (
<div className='channel-intro'> <div className='channel-intro'>
<h4 className='channel-intro__title'>{'Beginning of ' + channel.display_name}</h4> <h4 className='channel-intro__title'>{'Beginning of ' + channel.display_name}</h4>
@@ -71,13 +72,7 @@ export function createOffTopicIntroMessage(channel, showInviteModal) {
<br/> <br/>
</p> </p>
{createSetHeaderButton(channel)} {createSetHeaderButton(channel)}
<a {createInviteChannelMemberButton(channel, 'channel')}
href='#'
className='intro-links'
onClick={showInviteModal}
>
<i className='fa fa-user-plus'></i>{'Invite others to this channel'}
</a>
</div> </div>
); );
} }
@@ -122,7 +117,7 @@ export function createDefaultIntroMessage(channel) {
); );
} }
export function createStandardIntroMessage(channel, showInviteModal) { export function createStandardIntroMessage(channel) {
var uiName = channel.display_name; var uiName = channel.display_name;
var creatorName = ''; var creatorName = '';
@@ -162,17 +157,22 @@ export function createStandardIntroMessage(channel, showInviteModal) {
<br/> <br/>
</p> </p>
{createSetHeaderButton(channel)} {createSetHeaderButton(channel)}
<a {createInviteChannelMemberButton(channel, uiType)}
className='intro-links'
href='#'
onClick={showInviteModal}
>
<i className='fa fa-user-plus'></i>{'Invite others to this ' + uiType}
</a>
</div> </div>
); );
} }
function createInviteChannelMemberButton(channel, uiType) {
return (
<ToggleModalButton
className='intro-links'
dialogType={ChannelInviteModal}
>
<i className='fa fa-user-plus'></i>{'Invite others to this ' + uiType}
</ToggleModalButton>
);
}
function createSetHeaderButton(channel) { function createSetHeaderButton(channel) {
return ( return (
<ToggleModalButton <ToggleModalButton