diff --git a/package.json b/package.json index 49bc6507ab39a8..122ae8e16d22c4 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "sinon": "^1.15.4", "sinon-chai": "^2.8.0", "transfer-webpack-plugin": "^0.1.4", + "warning": "^2.1.0", "webpack": "^1.11.0" } } diff --git a/src/dialog.jsx b/src/dialog.jsx index e0823f6b2dcdfa..b7796e8dcb9138 100644 --- a/src/dialog.jsx +++ b/src/dialog.jsx @@ -10,6 +10,7 @@ const Overlay = require('./overlay'); const Paper = require('./paper'); const DefaultRawTheme = require('./styles/raw-themes/light-raw-theme'); const ThemeManager = require('./styles/theme-manager'); +const warning = require('warning'); const ReactTransitionGroup = require('react-addons-transition-group'); @@ -134,6 +135,8 @@ let Dialog = React.createClass({ }, getInitialState() { + this._testDeprecations(); + let open = this.props.isOpen; if (open === null) @@ -151,6 +154,8 @@ let Dialog = React.createClass({ let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme; this.setState({muiTheme: newMuiTheme}); + this._testDeprecations(); + if (nextProps.isOpen !== this.props.isOpen) { if (nextProps.isOpen && !this.state.open) this._show(); @@ -276,6 +281,20 @@ let Dialog = React.createClass({ return this.state.open; }, + _testDeprecations() { + warning(!this.props.hasOwnProperty('openImmediately'), + 'openImmediately has been deprecated in favor of defaultIsOpen'); + + warning(!this.props.hasOwnProperty('onShow'), + 'onShow will be removed in favor of explicitly setting isOpen'); + + warning(!this.props.hasOwnProperty('onDismiss'), + 'onDismiss will be removed in favor of explicitly setting isOpen and can be replaced by onRequestClose'); + + warning(!this.props.hasOwnProperty('modal'), + 'modal will be removed in favor of explicitly setting isOpen and onRequestClose'); + }, + _getAction(actionJSON, key) { let styles = {marginRight: 8}; let props = { @@ -376,6 +395,16 @@ let Dialog = React.createClass({ } }, + show() { + warning(false, 'show has been deprecated in favor of explicitly setting the isOpen property.'); + this._show(); + }, + + dismiss() { + warning(false, 'dismiss has been deprecated in favor of explicitly setting the isOpen property.'); + this._dismiss(); + }, + _show() { this.refs.dialogOverlay.preventScrolling(); this.setState({ open: true }); @@ -390,6 +419,10 @@ let Dialog = React.createClass({ }, _requestClose(buttonClicked) { + warning(!this.props.hasOwnProperty('modal'), + 'modal will be removed in favor of explicitly setting isOpen and onRequestClose'); + if (!buttonClicked && this.props.modal) return; + // Close the dialog if the isOpen state is not explicitly set. if (this.props.isOpen === null) this._dismiss(); if (this.props.onRequestClose) this.props.onRequestClose(!!buttonClicked);