From 70de0125abdc84d70580f82b29a4314e3515a587 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 17 Nov 2015 16:10:16 -0500 Subject: Removed Modal base class --- web/react/components/access_history_modal.jsx | 12 +++++- web/react/components/activity_log_modal.jsx | 12 +++++- web/react/components/channel_info_modal.jsx | 3 +- .../components/channel_notifications_modal.jsx | 2 +- web/react/components/confirm_modal.jsx | 2 +- web/react/components/delete_channel_modal.jsx | 2 +- web/react/components/modal.jsx | 48 ---------------------- .../user_settings/user_settings_modal.jsx | 15 ++++++- 8 files changed, 37 insertions(+), 59 deletions(-) delete mode 100644 web/react/components/modal.jsx (limited to 'web/react/components') diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx index 8306a4e8c..65b80dfb7 100644 --- a/web/react/components/access_history_modal.jsx +++ b/web/react/components/access_history_modal.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -var Modal = require('./modal.jsx'); +var Modal = ReactBootstrap.Modal; var UserStore = require('../stores/user_store.jsx'); var ChannelStore = require('../stores/channel_store.jsx'); var AsyncClient = require('../utils/async_client.jsx'); @@ -43,6 +43,15 @@ export default class AccessHistoryModal extends React.Component { } componentDidMount() { UserStore.addAuditsChangeListener(this.onAuditChange); + + if (this.props.show) { + this.onShow(); + } + } + componentDidUpdate(prevProps) { + if (this.props.show && !prevProps.show) { + this.onShow(); + } } componentWillUnmount() { UserStore.removeAuditsChangeListener(this.onAuditChange); @@ -386,7 +395,6 @@ export default class AccessHistoryModal extends React.Component { diff --git a/web/react/components/activity_log_modal.jsx b/web/react/components/activity_log_modal.jsx index 5c385c93d..5824ce7e2 100644 --- a/web/react/components/activity_log_modal.jsx +++ b/web/react/components/activity_log_modal.jsx @@ -4,7 +4,7 @@ const UserStore = require('../stores/user_store.jsx'); const Client = require('../utils/client.jsx'); const AsyncClient = require('../utils/async_client.jsx'); -const Modal = require('./modal.jsx'); +const Modal = ReactBootstrap.Modal; const LoadingScreen = require('./loading_screen.jsx'); const Utils = require('../utils/utils.jsx'); @@ -62,6 +62,15 @@ export default class ActivityLogModal extends React.Component { } componentDidMount() { UserStore.addSessionsChangeListener(this.onListenerChange); + + if (this.props.show) { + this.onShow(); + } + } + componentDidUpdate(prevProps) { + if (this.props.show && !prevProps.show) { + this.onShow(); + } } componentWillUnmount() { UserStore.removeSessionsChangeListener(this.onListenerChange); @@ -156,7 +165,6 @@ export default class ActivityLogModal extends React.Component { return ( diff --git a/web/react/components/channel_info_modal.jsx b/web/react/components/channel_info_modal.jsx index 5eac6be0f..18e125de3 100644 --- a/web/react/components/channel_info_modal.jsx +++ b/web/react/components/channel_info_modal.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -const Modal = require('./modal.jsx'); +const Modal = ReactBootstrap.Modal; export default class ChannelInfoModal extends React.Component { render() { @@ -18,7 +18,6 @@ export default class ChannelInfoModal extends React.Component { {channel.display_name} diff --git a/web/react/components/channel_notifications_modal.jsx b/web/react/components/channel_notifications_modal.jsx index e93aae438..c8bd1c2dc 100644 --- a/web/react/components/channel_notifications_modal.jsx +++ b/web/react/components/channel_notifications_modal.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -var Modal = require('./modal.jsx'); +var Modal = ReactBootstrap.Modal; var SettingItemMin = require('./setting_item_min.jsx'); var SettingItemMax = require('./setting_item_max.jsx'); diff --git a/web/react/components/confirm_modal.jsx b/web/react/components/confirm_modal.jsx index a1138bf45..cdef1c1ea 100644 --- a/web/react/components/confirm_modal.jsx +++ b/web/react/components/confirm_modal.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -const Modal = require('./modal.jsx'); +const Modal = ReactBootstrap.Modal; export default class ConfirmModal extends React.Component { constructor(props) { diff --git a/web/react/components/delete_channel_modal.jsx b/web/react/components/delete_channel_modal.jsx index 17694e779..271f21c3a 100644 --- a/web/react/components/delete_channel_modal.jsx +++ b/web/react/components/delete_channel_modal.jsx @@ -3,7 +3,7 @@ const AsyncClient = require('../utils/async_client.jsx'); const Client = require('../utils/client.jsx'); -const Modal = require('./modal.jsx'); +const Modal = ReactBootstrap.Modal; const TeamStore = require('../stores/team_store.jsx'); const Utils = require('../utils/utils.jsx'); diff --git a/web/react/components/modal.jsx b/web/react/components/modal.jsx deleted file mode 100644 index 758a68847..000000000 --- a/web/react/components/modal.jsx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -export default class Modal extends ReactBootstrap.Modal { - constructor(props) { - super(props); - } - - componentWillMount() { - if (this.props.show && this.props.onPreshow) { - this.props.onPreshow(); - } - } - - componentDidMount() { - super.componentDidMount(); - - if (this.props.show && this.props.onShow) { - this.props.onShow(); - } - } - - componentDidUpdate(prevProps) { - super.componentDidUpdate(prevProps); - - if (this.props.show && !prevProps.show && this.props.onShow) { - this.props.onShow(); - } - } - - componentWillReceiveProps(nextProps) { - super.componentWillReceiveProps(nextProps); - - if (nextProps.show && !this.props.show && this.props.onPreshow) { - this.props.onPreshow(); - } - } -} - -Modal.propTypes = { - ...ReactBootstrap.Modal.propTypes, - - // called before showing the dialog to allow for a state change before rendering - onPreshow: React.PropTypes.func, - - // called after the dialog has been shown and rendered - onShow: React.PropTypes.func -}; diff --git a/web/react/components/user_settings/user_settings_modal.jsx b/web/react/components/user_settings/user_settings_modal.jsx index 85a8d0473..776201295 100644 --- a/web/react/components/user_settings/user_settings_modal.jsx +++ b/web/react/components/user_settings/user_settings_modal.jsx @@ -2,7 +2,7 @@ // See License.txt for license information. const ConfirmModal = require('../confirm_modal.jsx'); -const Modal = require('../modal.jsx'); +const Modal = ReactBootstrap.Modal; const SettingsSidebar = require('../settings_sidebar.jsx'); const UserSettings = require('./user_settings.jsx'); @@ -34,6 +34,18 @@ export default class UserSettingsModal extends React.Component { this.requireConfirm = false; } + componentDidMount() { + if (this.props.show) { + this.handleShow(); + } + } + + componentDidUpdate(prevProps) { + if (this.props.show && !prevProps.show) { + this.handleShow(); + } + } + handleShow() { $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 300); if ($(window).width() > 768) { @@ -175,7 +187,6 @@ export default class UserSettingsModal extends React.Component {