Merge pull request #1423 from hmhealey/plt737

PLT-737 Converted first set of Modals to ReactBootstrap
Этот коммит содержится в:
Christopher Speller
2015-11-18 08:49:29 -05:00
родитель 5716a5e2fd 70de0125ab
Коммит 7b01528d17
11 изменённых файлов: 254 добавлений и 322 удалений

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

@@ -14,8 +14,8 @@ export default class AccessHistoryModal extends React.Component {
this.onAuditChange = this.onAuditChange.bind(this); this.onAuditChange = this.onAuditChange.bind(this);
this.handleMoreInfo = this.handleMoreInfo.bind(this); this.handleMoreInfo = this.handleMoreInfo.bind(this);
this.onHide = this.onHide.bind(this);
this.onShow = this.onShow.bind(this); this.onShow = this.onShow.bind(this);
this.onHide = this.onHide.bind(this);
this.formatAuditInfo = this.formatAuditInfo.bind(this); this.formatAuditInfo = this.formatAuditInfo.bind(this);
this.handleRevokedSession = this.handleRevokedSession.bind(this); this.handleRevokedSession = this.handleRevokedSession.bind(this);
@@ -39,10 +39,14 @@ export default class AccessHistoryModal extends React.Component {
} }
onHide() { onHide() {
this.setState({moreInfo: []}); this.setState({moreInfo: []});
this.props.onModalDismissed(); this.props.onHide();
} }
componentDidMount() { componentDidMount() {
UserStore.addAuditsChangeListener(this.onAuditChange); UserStore.addAuditsChangeListener(this.onAuditChange);
if (this.props.show) {
this.onShow();
}
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.show && !prevProps.show) { if (this.props.show && !prevProps.show) {
@@ -406,5 +410,5 @@ export default class AccessHistoryModal extends React.Component {
AccessHistoryModal.propTypes = { AccessHistoryModal.propTypes = {
show: React.PropTypes.bool.isRequired, show: React.PropTypes.bool.isRequired,
onModalDismissed: React.PropTypes.func.isRequired onHide: React.PropTypes.func.isRequired
}; };

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

@@ -58,10 +58,14 @@ export default class ActivityLogModal extends React.Component {
} }
onHide() { onHide() {
this.setState({moreInfo: []}); this.setState({moreInfo: []});
this.props.onModalDismissed(); this.props.onHide();
} }
componentDidMount() { componentDidMount() {
UserStore.addSessionsChangeListener(this.onListenerChange); UserStore.addSessionsChangeListener(this.onListenerChange);
if (this.props.show) {
this.onShow();
}
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.show && !prevProps.show) { if (this.props.show && !prevProps.show) {
@@ -178,5 +182,5 @@ export default class ActivityLogModal extends React.Component {
ActivityLogModal.propTypes = { ActivityLogModal.propTypes = {
show: React.PropTypes.bool.isRequired, show: React.PropTypes.bool.isRequired,
onModalDismissed: React.PropTypes.func.isRequired onHide: React.PropTypes.func.isRequired
}; };

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

@@ -5,8 +5,12 @@ const NavbarSearchBox = require('./search_bar.jsx');
const MessageWrapper = require('./message_wrapper.jsx'); const MessageWrapper = require('./message_wrapper.jsx');
const PopoverListMembers = require('./popover_list_members.jsx'); const PopoverListMembers = require('./popover_list_members.jsx');
const EditChannelPurposeModal = require('./edit_channel_purpose_modal.jsx'); const EditChannelPurposeModal = require('./edit_channel_purpose_modal.jsx');
const ChannelInfoModal = require('./channel_info_modal.jsx');
const ChannelInviteModal = require('./channel_invite_modal.jsx'); const ChannelInviteModal = require('./channel_invite_modal.jsx');
const ChannelMembersModal = require('./channel_members_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'); const ChannelStore = require('../stores/channel_store.jsx');
const UserStore = require('../stores/user_store.jsx'); const UserStore = require('../stores/user_store.jsx');
@@ -180,15 +184,13 @@ export default class ChannelHeader extends React.Component {
key='view_info' key='view_info'
role='presentation' role='presentation'
> >
<a <ToggleModalButton
role='menuitem' role='menuitem'
data-toggle='modal' dialogType={ChannelInfoModal}
data-target='#channel_info' dialogProps={{channel}}
data-channelid={channel.id}
href='#'
> >
{'View Info'} {'View Info'}
</a> </ToggleModalButton>
</li> </li>
); );
@@ -263,16 +265,13 @@ export default class ChannelHeader extends React.Component {
key='notification_preferences' key='notification_preferences'
role='presentation' role='presentation'
> >
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={ChannelNotificationsModal}
data-toggle='modal' dialogProps={{channel}}
data-target='#channel_notifications'
data-title={channel.display_name}
data-channelid={channel.id}
> >
{'Notification Preferences'} {'Notification Preferences'}
</a> </ToggleModalButton>
</li> </li>
); );
@@ -302,16 +301,13 @@ export default class ChannelHeader extends React.Component {
key='delete_channel' key='delete_channel'
role='presentation' role='presentation'
> >
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={DeleteChannelModal}
data-toggle='modal' dialogProps={{channel}}
data-target='#delete_channel'
data-title={channel.display_name}
data-channelid={channel.id}
> >
{'Delete '}{channelTerm}{'...'} {'Delete '}{channelTerm}{'...'}
</a> </ToggleModalButton>
</li> </li>
); );
} }

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

@@ -1,88 +1,57 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
var ChannelStore = require('../stores/channel_store.jsx'); const Modal = ReactBootstrap.Modal;
export default class CommandList extends React.Component {
constructor(props) {
super(props);
this.state = {
channel_id: ChannelStore.getCurrentId()
};
}
componentDidMount() {
var self = this;
if (this.refs.modal) {
$(ReactDOM.findDOMNode(this.refs.modal)).on('show.bs.modal', function show(e) {
var button = e.relatedTarget;
self.setState({channel_id: $(button).attr('data-channelid')});
});
}
}
export default class ChannelInfoModal extends React.Component {
render() { render() {
var channel = ChannelStore.get(this.state.channel_id); let channel = this.props.channel;
if (!channel) { if (!channel) {
channel = {}; channel = {
channel.display_name = 'No Channel Found'; display_name: 'No Channel Found',
channel.name = 'No Channel Found'; name: 'No Channel Found',
channel.id = 'No Channel Found'; id: 'No Channel Found'
};
} }
return ( return (
<div <Modal
className='modal fade' show={this.props.show}
ref='modal' onHide={this.props.onHide}
id='channel_info'
tabIndex='-1'
role='dialog'
aria-hidden='true'
> >
<div className='modal-dialog'> <Modal.Header closeButtton={true}>
<div className='modal-content'> {channel.display_name}
<div className='modal-header'> </Modal.Header>
<button <Modal.Body ref='modalBody'>
type='button' <div className='row form-group'>
className='close' <div className='col-sm-3 info__label'>{'Channel Name:'}</div>
data-dismiss='modal'
aria-label='Close'
>
<span aria-hidden='true'>&times;</span>
</button>
<h4
className='modal-title'
id='myModalLabel'
>
<span className='name'>{channel.display_name}</span>
</h4>
</div>
<div className='modal-body'>
<div className='row form-group'>
<div className='col-sm-3 info__label'>Channel Name: </div>
<div className='col-sm-9'>{channel.display_name}</div> <div className='col-sm-9'>{channel.display_name}</div>
</div> </div>
<div className='row form-group'> <div className='row form-group'>
<div className='col-sm-3 info__label'>Channel Handle:</div> <div className='col-sm-3 info__label'>{'Channel Handle:'}</div>
<div className='col-sm-9'>{channel.name}</div> <div className='col-sm-9'>{channel.name}</div>
</div> </div>
<div className='row'> <div className='row'>
<div className='col-sm-3 info__label'>Channel ID:</div> <div className='col-sm-3 info__label'>{'Channel ID:'}</div>
<div className='col-sm-9'>{channel.id}</div> <div className='col-sm-9'>{channel.id}</div>
</div>
</div> </div>
<div className='modal-footer'> </Modal.Body>
<button <Modal.Footer>
type='button' <button
className='btn btn-default' type='button'
data-dismiss='modal' className='btn btn-default'
>Close</button> onClick={this.props.onHide}
</div> >
</div> {'Close'}
</div> </button>
</div> </Modal.Footer>
</Modal>
); );
} }
} }
ChannelInfoModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
channel: React.PropTypes.object.isRequired
};

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

@@ -1,15 +1,15 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
var Modal = ReactBootstrap.Modal;
var SettingItemMin = require('./setting_item_min.jsx'); var SettingItemMin = require('./setting_item_min.jsx');
var SettingItemMax = require('./setting_item_max.jsx'); var SettingItemMax = require('./setting_item_max.jsx');
var Utils = require('../utils/utils.jsx');
var Client = require('../utils/client.jsx'); var Client = require('../utils/client.jsx');
var UserStore = require('../stores/user_store.jsx'); var UserStore = require('../stores/user_store.jsx');
var ChannelStore = require('../stores/channel_store.jsx'); var ChannelStore = require('../stores/channel_store.jsx');
export default class ChannelNotifications extends React.Component { export default class ChannelNotificationsModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -23,35 +23,17 @@ export default class ChannelNotifications extends React.Component {
this.handleSubmitMarkUnreadLevel = this.handleSubmitMarkUnreadLevel.bind(this); this.handleSubmitMarkUnreadLevel = this.handleSubmitMarkUnreadLevel.bind(this);
this.handleUpdateMarkUnreadLevel = this.handleUpdateMarkUnreadLevel.bind(this); this.handleUpdateMarkUnreadLevel = this.handleUpdateMarkUnreadLevel.bind(this);
this.createMarkUnreadLevelSection = this.createMarkUnreadLevelSection.bind(this); this.createMarkUnreadLevelSection = this.createMarkUnreadLevelSection.bind(this);
this.onShow = this.onShow.bind(this);
const member = ChannelStore.getMember(props.channel.id);
this.state = { this.state = {
notifyLevel: '', notifyLevel: member.notify_props.desktop,
markUnreadLevel: '', markUnreadLevel: member.notify_props.mark_unread,
title: '',
channelId: '', channelId: '',
activeSection: '' activeSection: ''
}; };
} }
onShow(e) {
var button = e.relatedTarget;
var channelId = button.getAttribute('data-channelid');
const member = ChannelStore.getMember(channelId);
var notifyLevel = member.notify_props.desktop;
var markUnreadLevel = member.notify_props.mark_unread;
this.setState({
notifyLevel,
markUnreadLevel,
title: button.getAttribute('data-title'),
channelId
});
}
componentDidMount() { componentDidMount() {
ChannelStore.addChangeListener(this.onListenerChange); ChannelStore.addChangeListener(this.onListenerChange);
$(ReactDOM.findDOMNode(this.refs.modal)).on('show.bs.modal', this.onShow);
} }
componentWillUnmount() { componentWillUnmount() {
ChannelStore.removeChangeListener(this.onListenerChange); ChannelStore.removeChangeListener(this.onListenerChange);
@@ -62,15 +44,12 @@ export default class ChannelNotifications extends React.Component {
} }
const member = ChannelStore.getMember(this.state.channelId); const member = ChannelStore.getMember(this.state.channelId);
var notifyLevel = member.notify_props.desktop;
var markUnreadLevel = member.notify_props.mark_unread;
var newState = this.state; if (member.notify_props.desktop !== this.state.notifyLevel || member.notify_props.mark_unread !== this.state.mark_unread) {
newState.notifyLevel = notifyLevel; this.setState({
newState.markUnreadLevel = markUnreadLevel; notifyLevel: member.notify_props.desktop,
markUnreadLevel: member.notify_props.mark_unread
if (!Utils.areObjectsEqual(this.state, newState)) { });
this.setState(newState);
} }
} }
updateSection(section) { updateSection(section) {
@@ -104,7 +83,6 @@ export default class ChannelNotifications extends React.Component {
} }
handleUpdateNotifyLevel(notifyLevel) { handleUpdateNotifyLevel(notifyLevel) {
this.setState({notifyLevel}); this.setState({notifyLevel});
ReactDOM.findDOMNode(this.refs.modal).focus();
} }
createNotifyLevelSection(serverError) { createNotifyLevelSection(serverError) {
var handleUpdateSection; var handleUpdateSection;
@@ -262,7 +240,6 @@ export default class ChannelNotifications extends React.Component {
handleUpdateMarkUnreadLevel(markUnreadLevel) { handleUpdateMarkUnreadLevel(markUnreadLevel) {
this.setState({markUnreadLevel}); this.setState({markUnreadLevel});
ReactDOM.findDOMNode(this.refs.modal).focus();
} }
createMarkUnreadLevelSection(serverError) { createMarkUnreadLevelSection(serverError) {
@@ -347,48 +324,39 @@ export default class ChannelNotifications extends React.Component {
} }
return ( return (
<div <Modal
className='modal fade' show={this.props.show}
id='channel_notifications' dialogClassName='settings-modal'
ref='modal' onHide={this.props.onHide}
tabIndex='-1'
role='dialog'
aria-hidden='true'
> >
<div className='modal-dialog settings-modal'> <Modal.Header closeButton={true}>
<div className='modal-content'> {'Notification Preferences for '}<span className='name'>{this.props.channel.display_name}</span>
<div className='modal-header'> </Modal.Header>
<button <Modal.Body>
type='button' <div className='settings-table'>
className='close' <div className='settings-content'>
data-dismiss='modal' <div
ref='wrapper'
className='user-settings'
> >
<span aria-hidden='true'>&times;</span> <br/>
<span className='sr-only'>{'Close'}</span> <div className='divider-dark first'/>
</button> {this.createNotifyLevelSection(serverError)}
<h4 className='modal-title'>Notification Preferences for <span className='name'>{this.state.title}</span></h4> <div className='divider-light'/>
</div> {this.createMarkUnreadLevelSection(serverError)}
<div className='modal-body'> <div className='divider-dark'/>
<div className='settings-table'>
<div className='settings-content'>
<div
ref='wrapper'
className='user-settings'
>
<br/>
<div className='divider-dark first'/>
{this.createNotifyLevelSection(serverError)}
<div className='divider-light'/>
{this.createMarkUnreadLevelSection(serverError)}
<div className='divider-dark'/>
</div>
</div> </div>
</div>
{serverError}
</div> </div>
</div> </div>
</div> {serverError}
</div> </Modal.Body>
</Modal>
); );
} }
} }
ChannelNotificationsModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
channel: React.PropTypes.object.isRequired
};

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

@@ -1,102 +1,72 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
const Client = require('../utils/client.jsx');
const AsyncClient = require('../utils/async_client.jsx'); const AsyncClient = require('../utils/async_client.jsx');
const ChannelStore = require('../stores/channel_store.jsx'); const Client = require('../utils/client.jsx');
var TeamStore = require('../stores/team_store.jsx'); const Modal = ReactBootstrap.Modal;
const TeamStore = require('../stores/team_store.jsx');
const Utils = require('../utils/utils.jsx');
export default class DeleteChannelModal extends React.Component { export default class DeleteChannelModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleDelete = this.handleDelete.bind(this); this.handleDelete = this.handleDelete.bind(this);
this.onShow = this.onShow.bind(this);
this.state = {
title: '',
channelId: ''
};
} }
handleDelete() { handleDelete() {
if (this.state.channelId.length !== 26) { if (this.props.channel.id.length !== 26) {
return; return;
} }
Client.deleteChannel(this.state.channelId, Client.deleteChannel(
function handleDeleteSuccess() { this.props.channel.id,
() => {
AsyncClient.getChannels(true); AsyncClient.getChannels(true);
window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/town-square'; window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/town-square';
}, },
function handleDeleteError(err) { (err) => {
AsyncClient.dispatchError(err, 'handleDelete'); 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() { render() {
const channel = ChannelStore.getCurrent(); const channelTerm = Utils.getChannelTerm(this.props.channel.type).toLowerCase();
let channelType = 'channel';
if (channel && channel.type === 'P') {
channelType = 'private group';
}
return ( return (
<div <Modal
className='modal fade' show={this.props.show}
ref='modal' onHide={this.props.onHide}
id='delete_channel'
role='dialog'
tabIndex='-1'
aria-hidden='true'
> >
<div className='modal-dialog'> <Modal.Header closeButton={true}>{'Confirm DELETE Channel'}</Modal.Header>
<div className='modal-content'> <Modal.Body>
<div className='modal-header'> {`Are you sure you wish to delete the ${this.props.channel.display_name} ${channelTerm}?`}
<button </Modal.Body>
type='button' <Modal.Footer>
className='close' <button
data-dismiss='modal' type='button'
aria-label='Close' className='btn btn-default'
> onClick={this.props.onHide}
<span aria-hidden='true'>&times;</span> >
</button> {'Cancel'}
<h4 className='modal-title'>Confirm DELETE Channel</h4> </button>
</div> <button
<div className='modal-body'> type='button'
<p> className='btn btn-danger'
Are you sure you wish to delete the {this.state.title} {channelType}? data-dismiss='modal'
</p> onClick={this.handleDelete}
</div> >
<div className='modal-footer'> {'Delete'}
<button </button>
type='button' </Modal.Footer>
className='btn btn-default' </Modal>
data-dismiss='modal'
>
Cancel
</button>
<button
type='button'
className='btn btn-danger'
data-dismiss='modal'
onClick={this.handleDelete}
>
Delete
</button>
</div>
</div>
</div>
</div>
); );
} }
} }
DeleteChannelModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
channel: React.PropTypes.object.isRequired
};

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

@@ -5,7 +5,11 @@ const EditChannelPurposeModal = require('./edit_channel_purpose_modal.jsx');
const MessageWrapper = require('./message_wrapper.jsx'); const MessageWrapper = require('./message_wrapper.jsx');
const NotifyCounts = require('./notify_counts.jsx'); const NotifyCounts = require('./notify_counts.jsx');
const ChannelMembersModal = require('./channel_members_modal.jsx'); const ChannelMembersModal = require('./channel_members_modal.jsx');
const ChannelInfoModal = require('./channel_info_modal.jsx');
const ChannelInviteModal = require('./channel_invite_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'); const UserStore = require('../stores/user_store.jsx');
const ChannelStore = require('../stores/channel_store.jsx'); const ChannelStore = require('../stores/channel_store.jsx');
@@ -104,15 +108,13 @@ export default class Navbar extends React.Component {
if (channel) { if (channel) {
var viewInfoOption = ( var viewInfoOption = (
<li role='presentation'> <li role='presentation'>
<a <ToggleModalButton
role='menuitem' role='menuitem'
data-toggle='modal' dialogType={ChannelInfoModal}
data-target='#channel_info' dialogProps={{channel}}
data-channelid={channel.id}
href='#'
> >
{'View Info'} {'View Info'}
</a> </ToggleModalButton>
</li> </li>
); );
@@ -194,16 +196,13 @@ export default class Navbar extends React.Component {
deleteChannelOption = ( deleteChannelOption = (
<li role='presentation'> <li role='presentation'>
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={DeleteChannelModal}
data-toggle='modal' dialogProps={{channel}}
data-target='#delete_channel'
data-title={channel.display_name}
data-channelid={channel.id}
> >
{'Delete Channel...'} {'Delete Channel...'}
</a> </ToggleModalButton>
</li> </li>
); );
} }
@@ -229,16 +228,13 @@ export default class Navbar extends React.Component {
if (!isDirect) { if (!isDirect) {
notificationPreferenceOption = ( notificationPreferenceOption = (
<li role='presentation'> <li role='presentation'>
<a <ToggleModalButton
role='menuitem' role='menuitem'
href='#' dialogType={ChannelNotificationsModal}
data-toggle='modal' dialogProps={{channel}}
data-target='#channel_notifications'
data-title={channel.display_name}
data-channelid={channel.id}
> >
{'Notification Preferences'} {'Notification Preferences'}
</a> </ToggleModalButton>
</li> </li>
); );
} }

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

@@ -0,0 +1,62 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
export default class ModalToggleButton extends React.Component {
constructor(props) {
super(props);
this.show = this.show.bind(this);
this.hide = this.hide.bind(this);
this.state = {
show: false
};
}
show() {
this.setState({show: true});
}
hide() {
this.setState({show: false});
}
render() {
const {children, dialogType, dialogProps, ...props} = this.props;
// this assumes that all modals will have a show property and an onHide event
const dialog = React.createElement(this.props.dialogType, Object.assign({}, dialogProps, {
show: this.state.show,
onHide: () => {
this.hide();
if (dialogProps.onHide) {
dialogProps.onHide();
}
}
}));
// nesting the dialog in the anchor tag looks like it shouldn't work, but it does due to how react-bootstrap
// renders modals at the top level of the DOM instead of where you specify in the virtual DOM
return (
<a
{...props}
href='#'
onClick={this.show}
>
{children}
{dialog}
</a>
);
}
}
ModalToggleButton.propTypes = {
children: React.PropTypes.node.isRequired,
dialogType: React.PropTypes.func.isRequired,
dialogProps: React.PropTypes.object
};
ModalToggleButton.defaultProps = {
dialogProps: {}
};

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

@@ -10,6 +10,7 @@ export default class UserSettingsModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleShow = this.handleShow.bind(this);
this.handleHide = this.handleHide.bind(this); this.handleHide = this.handleHide.bind(this);
this.handleHidden = this.handleHidden.bind(this); this.handleHidden = this.handleHidden.bind(this);
this.handleCollapse = this.handleCollapse.bind(this); this.handleCollapse = this.handleCollapse.bind(this);
@@ -33,12 +34,22 @@ export default class UserSettingsModal extends React.Component {
this.requireConfirm = false; this.requireConfirm = false;
} }
componentDidMount() {
if (this.props.show) {
this.handleShow();
}
}
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (!prevProps.show && this.props.show) { if (this.props.show && !prevProps.show) {
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 300); this.handleShow();
if ($(window).width() > 768) { }
$(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar(); }
}
handleShow() {
$(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 300);
if ($(window).width() > 768) {
$(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
} }
} }

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

@@ -5,6 +5,7 @@ var SettingItemMin = require('../setting_item_min.jsx');
var SettingItemMax = require('../setting_item_max.jsx'); var SettingItemMax = require('../setting_item_max.jsx');
var AccessHistoryModal = require('../access_history_modal.jsx'); var AccessHistoryModal = require('../access_history_modal.jsx');
var ActivityLogModal = require('../activity_log_modal.jsx'); var ActivityLogModal = require('../activity_log_modal.jsx');
var ToggleModalButton = require('../toggle_modal_button.jsx');
var Client = require('../../utils/client.jsx'); var Client = require('../../utils/client.jsx');
var AsyncClient = require('../../utils/async_client.jsx'); var AsyncClient = require('../../utils/async_client.jsx');
var Constants = require('../../utils/constants.jsx'); var Constants = require('../../utils/constants.jsx');
@@ -13,34 +14,13 @@ export default class SecurityTab extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.showAccessHistoryModal = this.showAccessHistoryModal.bind(this);
this.showActivityLogModal = this.showActivityLogModal.bind(this);
this.hideModals = this.hideModals.bind(this);
this.submitPassword = this.submitPassword.bind(this); this.submitPassword = this.submitPassword.bind(this);
this.updateCurrentPassword = this.updateCurrentPassword.bind(this); this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
this.updateNewPassword = this.updateNewPassword.bind(this); this.updateNewPassword = this.updateNewPassword.bind(this);
this.updateConfirmPassword = this.updateConfirmPassword.bind(this); this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
this.setupInitialState = this.setupInitialState.bind(this); this.setupInitialState = this.setupInitialState.bind(this);
const state = this.setupInitialState(); this.state = this.setupInitialState();
state.showAccessHistoryModal = false;
state.showActivityLogModal = false;
this.state = state;
}
showAccessHistoryModal() {
this.props.setEnforceFocus(false);
this.setState({showAccessHistoryModal: true});
}
showActivityLogModal() {
this.props.setEnforceFocus(false);
this.setState({showActivityLogModal: true});
}
hideModals() {
this.props.setEnforceFocus(true);
this.setState({
showAccessHistoryModal: false,
showActivityLogModal: false
});
} }
submitPassword(e) { submitPassword(e) {
e.preventDefault(); e.preventDefault();
@@ -258,30 +238,20 @@ export default class SecurityTab extends React.Component {
{passwordSection} {passwordSection}
<div className='divider-dark'/> <div className='divider-dark'/>
<br></br> <br></br>
<a <ToggleModalButton
className='security-links theme' className='security-links theme'
href='#' dialogType={AccessHistoryModal}
onClick={this.showAccessHistoryModal}
> >
<i className='fa fa-clock-o'></i>View Access History <i className='fa fa-clock-o'></i>View Access History
</a> </ToggleModalButton>
<b> </b> <b> </b>
<a <ToggleModalButton
className='security-links theme' className='security-links theme'
href='#' dialogType={ActivityLogModal}
onClick={this.showActivityLogModal}
> >
<i className='fa fa-globe'></i>View and Logout of Active Sessions <i className='fa fa-clock-o'></i>{'View and Logout of Active Sessions'}
</a> </ToggleModalButton>
</div> </div>
<AccessHistoryModal
show={this.state.showAccessHistoryModal}
onModalDismissed={this.hideModals}
/>
<ActivityLogModal
show={this.state.showActivityLogModal}
onModalDismissed={this.hideModals}
/>
</div> </div>
); );
} }

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

@@ -10,16 +10,13 @@ var ErrorStore = require('../stores/error_store.jsx');
var MentionList = require('../components/mention_list.jsx'); var MentionList = require('../components/mention_list.jsx');
var GetLinkModal = require('../components/get_link_modal.jsx'); var GetLinkModal = require('../components/get_link_modal.jsx');
var EditChannelModal = require('../components/edit_channel_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 RenameChannelModal = require('../components/rename_channel_modal.jsx');
var EditPostModal = require('../components/edit_post_modal.jsx'); var EditPostModal = require('../components/edit_post_modal.jsx');
var DeletePostModal = require('../components/delete_post_modal.jsx'); var DeletePostModal = require('../components/delete_post_modal.jsx');
var MoreChannelsModal = require('../components/more_channels.jsx'); var MoreChannelsModal = require('../components/more_channels.jsx');
var PostDeletedModal = require('../components/post_deleted_modal.jsx'); var PostDeletedModal = require('../components/post_deleted_modal.jsx');
var ChannelNotificationsModal = require('../components/channel_notifications.jsx');
var TeamSettingsModal = require('../components/team_settings_modal.jsx'); var TeamSettingsModal = require('../components/team_settings_modal.jsx');
var TeamMembersModal = require('../components/team_members.jsx'); var TeamMembersModal = require('../components/team_members.jsx');
var ChannelInfoModal = require('../components/channel_info_modal.jsx');
var RemovedFromChannelModal = require('../components/removed_from_channel_modal.jsx'); var RemovedFromChannelModal = require('../components/removed_from_channel_modal.jsx');
var RegisterAppModal = require('../components/register_app_modal.jsx'); var RegisterAppModal = require('../components/register_app_modal.jsx');
var ImportThemeModal = require('../components/user_settings/import_theme_modal.jsx'); var ImportThemeModal = require('../components/user_settings/import_theme_modal.jsx');
@@ -102,26 +99,11 @@ function setupChannelPage(props) {
document.getElementById('edit_channel_modal') document.getElementById('edit_channel_modal')
); );
ReactDOM.render(
<DeleteChannelModal />,
document.getElementById('delete_channel_modal')
);
ReactDOM.render( ReactDOM.render(
<RenameChannelModal />, <RenameChannelModal />,
document.getElementById('rename_channel_modal') document.getElementById('rename_channel_modal')
); );
ReactDOM.render(
<ChannelNotificationsModal />,
document.getElementById('channel_notifications_modal')
);
ReactDOM.render(
<ChannelInfoModal />,
document.getElementById('channel_info_modal')
);
ReactDOM.render( ReactDOM.render(
<MoreChannelsModal />, <MoreChannelsModal />,
document.getElementById('more_channels_modal') document.getElementById('more_channels_modal')