diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-11-04 11:21:14 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-11-04 11:21:14 -0400 |
commit | e6f7a47c99075a39d862308659b904bfaf64a11a (patch) | |
tree | 863f6eb80a2367fb080437d9e037fca283e3c270 /webapp/components/access_history_modal.jsx | |
parent | dbdd719c51d061dfc327644d4b2ca89a0595b4f1 (diff) | |
download | chat-e6f7a47c99075a39d862308659b904bfaf64a11a.tar.gz chat-e6f7a47c99075a39d862308659b904bfaf64a11a.tar.bz2 chat-e6f7a47c99075a39d862308659b904bfaf64a11a.zip |
PLT-4507 Don't mount modals until opened to make resetting state automatic (#4358)
* Don't mount modals until opened to make resetting state automatic
* Move dimiss handler to be fired after modal exit animation complete
Diffstat (limited to 'webapp/components/access_history_modal.jsx')
-rw-r--r-- | webapp/components/access_history_modal.jsx | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/webapp/components/access_history_modal.jsx b/webapp/components/access_history_modal.jsx index 9c49c3879..4ed2ad9ab 100644 --- a/webapp/components/access_history_modal.jsx +++ b/webapp/components/access_history_modal.jsx @@ -1,8 +1,6 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import $ from 'jquery'; -import {Modal} from 'react-bootstrap'; import LoadingScreen from './loading_screen.jsx'; import AuditTable from './audit_table.jsx'; @@ -11,11 +9,13 @@ import UserStore from 'stores/user_store.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; -import {intlShape, injectIntl, FormattedMessage} from 'react-intl'; - +import $ from 'jquery'; import React from 'react'; -class AccessHistoryModal extends React.Component { +import {Modal} from 'react-bootstrap'; +import {FormattedMessage} from 'react-intl'; + +export default class AccessHistoryModal extends React.Component { constructor(props) { super(props); @@ -25,45 +25,44 @@ class AccessHistoryModal extends React.Component { const state = this.getStateFromStoresForAudits(); state.moreInfo = []; + state.show = true; this.state = state; } + getStateFromStoresForAudits() { return { audits: UserStore.getAudits() }; } + onShow() { AsyncClient.getAudits(); if (!Utils.isMobile()) { $('.modal-body').perfectScrollbar(); } } + onHide() { - this.setState({moreInfo: []}); - this.props.onHide(); + this.setState({show: false}); } + componentDidMount() { UserStore.addAuditsChangeListener(this.onAuditChange); - - if (this.props.show) { - this.onShow(); - } - } - componentDidUpdate(prevProps) { - if (this.props.show && !prevProps.show) { - this.onShow(); - } + this.onShow(); } + componentWillUnmount() { UserStore.removeAuditsChangeListener(this.onAuditChange); } + onAuditChange() { var newState = this.getStateFromStoresForAudits(); if (!Utils.areObjectsEqual(newState.audits, this.state.audits)) { this.setState(newState); } } + render() { var content; if (this.state.audits.loading) { @@ -80,8 +79,9 @@ class AccessHistoryModal extends React.Component { return ( <Modal - show={this.props.show} + show={this.state.show} onHide={this.onHide} + onExited={this.props.onHide} bsSize='large' > <Modal.Header closeButton={true}> @@ -101,9 +101,5 @@ class AccessHistoryModal extends React.Component { } AccessHistoryModal.propTypes = { - intl: intlShape.isRequired, - show: React.PropTypes.bool.isRequired, onHide: React.PropTypes.func.isRequired }; - -export default injectIntl(AccessHistoryModal); |