Skip to content

Commit

Permalink
Merge pull request #2396 from subjectix/dialog-clear-deprecated-api
Browse files Browse the repository at this point in the history
[Dialog] clear deprecated api
  • Loading branch information
alitaheri committed Dec 7, 2015
2 parents 5986097 + 921d06a commit d5bbcad
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 145 deletions.
46 changes: 2 additions & 44 deletions docs/src/app/components/pages/components/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,12 @@ export default class DialogPage extends React.Component {
type: 'bool',
header: 'default: false',
desc: `Force the user to use one of the actions in the dialog.
Clicking outside the dialog will not dismiss the dialog.`,
},
{
name: 'Deprecated: openImmediately',
type: 'bool',
header: 'default: false',
desc: 'Deprecated: Set to true to have the dialog automatically open on mount.',
},
{
name: 'defaultOpen',
type: 'bool',
header: 'default: false',
desc: 'Set to true to have the dialog automatically open on mount.',
Clicking outside the dialog will not trigger the onRequestClose.`,
},
{
name: 'open',
type: 'bool',
header: 'default: null',
header: 'required',
desc: 'Controls whether the Dialog is opened or not.',
},
{
Expand Down Expand Up @@ -127,39 +115,9 @@ export default class DialogPage extends React.Component {
},
],
},
{
name: 'Methods',
infoArray: [
{
name: 'Deprecated: dismiss',
header: 'Dialog.dismiss()',
desc: 'Hides the dialog.',
},
{
name: 'Deprecated: show',
header: 'Dialog.show()',
desc: 'Shows the dialog.',
},
{
name: 'isOpen',
header: 'Dialog.isOpen()',
desc: 'Get the dialog open state.',
},
],
},
{
name: 'Events',
infoArray: [
{
name: 'Deprecated: onDismiss',
header: 'function()',
desc: 'Fired when the dialog is dismissed.',
},
{
name: 'Deprecated: onShow',
header: 'function()',
desc: 'Fired when the dialog is shown.',
},
{
name: 'onRequestClose',
header: 'function(buttonClicked)',
Expand Down
12 changes: 2 additions & 10 deletions src/date-picker/date-picker-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ const DatePickerDialog = React.createClass({
onAccept,
style,
container,
onDismiss,
onShow,
...other,
} = this.props;

Expand Down Expand Up @@ -155,14 +153,6 @@ const DatePickerDialog = React.createClass({
);
}

// Those two properties are deprecated, we will remove them at some point
if (typeof onDismiss === 'function') {
other.onDismiss = onDismiss;
}
if (typeof onShow === 'function') {
other.onShow = onShow;
}

// will change later when Popover is available.
const Container = (container === 'inline' ? DatePickerInline : Dialog);
return (
Expand Down Expand Up @@ -193,12 +183,14 @@ const DatePickerDialog = React.createClass({
},

show() {
if (this.props.onShow && !this.state.open) this.props.onShow();
this.setState({
open: true,
});
},

dismiss() {
if (this.props.onDismiss && this.state.open) this.props.onDismiss();
this.setState({
open: false,
});
Expand Down
83 changes: 2 additions & 81 deletions src/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import RenderToLayer from './render-to-layer';
import Paper from './paper';
import DefaultRawTheme from './styles/raw-themes/light-raw-theme';
import ThemeManager from './styles/theme-manager';
import warning from 'warning';

import ReactTransitionGroup from 'react-addons-transition-group';

Expand Down Expand Up @@ -409,13 +408,9 @@ const Dialog = React.createClass({
bodyStyle: React.PropTypes.object,
contentClassName: React.PropTypes.string,
contentStyle: React.PropTypes.object,
defaultOpen: React.PropTypes.bool,
modal: React.PropTypes.bool,
onDismiss: React.PropTypes.func,
onRequestClose: React.PropTypes.func,
onShow: React.PropTypes.func,
open: React.PropTypes.bool,
openImmediately: React.PropTypes.bool,
open: React.PropTypes.bool.isRequired,
repositionOnUpdate: React.PropTypes.bool,
style: React.PropTypes.object,
title: React.PropTypes.node,
Expand All @@ -439,26 +434,13 @@ const Dialog = React.createClass({
},

getInitialState() {
if (process.env.NODE_ENV !== 'production') {
this._testDeprecations();
}

let open = this.props.open;

if (open === null) {
open = (this.props.openImmediately || this.props.defaultOpen);
}

return {
open: open,
muiTheme: this.context.muiTheme ? this.context.muiTheme : ThemeManager.getMuiTheme(DefaultRawTheme),
};
},

getDefaultProps() {
return {
open: null,
defaultOpen: false,
modal: false,
};
},
Expand All @@ -469,16 +451,6 @@ const Dialog = React.createClass({
const newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({muiTheme: newMuiTheme});

if (process.env.NODE_ENV !== 'production') {
this._testDeprecations();
}
if (nextProps.open !== this.props.open) {
if (nextProps.open && !this.state.open) {
this._show();
} else if (!nextProps.open && this.state.open) {
this._dismiss();
}
}
},

render() {
Expand All @@ -489,61 +461,10 @@ const Dialog = React.createClass({

renderLayer() {
return (
<DialogInline {...this.props} onRequestClose={this.props.onRequestClose} open={this.state.open} />
<DialogInline {...this.props} onRequestClose={this.props.onRequestClose} open={this.props.open} />
);
},

_testDeprecations() {
warning(!this.props.hasOwnProperty('openImmediately'),
'openImmediately has been deprecated in favor of defaultOpen');

warning(!(typeof this.props.onShow === 'function'),
'onShow will be removed in favor of explicitly setting open');

warning(!(typeof this.props.onDismiss === 'function'),
'onDismiss will be removed in favor of explicitly setting open and can be replaced by onRequestClose');
},

show() {
warning(false, 'show has been deprecated in favor of explicitly setting the open property.');

this._show();
},

_onShow() {
if (this.props.onShow) {
this.props.onShow();
}
},

_show() {
this.setState({
open: true,
}, this._onShow);
},

dismiss() {
warning(false, 'dismiss has been deprecated in favor of explicitly setting the open property.');

this._dismiss();
},

_onDismiss() {
if (this.props.onDismiss) {
this.props.onDismiss();
}
},

_dismiss() {
this.setState({
open: false,
}, this._onDismiss);
},

isOpen() {
return this.state.openImmediately;
},

});

export default Dialog;
12 changes: 2 additions & 10 deletions src/time-picker/time-picker-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const TimePickerDialog = React.createClass({
onAccept,
format,
autoOk,
onShow,
onDismiss,
...other,
} = this.props;

Expand Down Expand Up @@ -98,14 +96,6 @@ const TimePickerDialog = React.createClass({

const onClockChangeMinutes = (autoOk === true ? this._handleOKTouchTap : undefined);

// Those two properties are deprecated, we will remove them at some point
if (typeof onDismiss === 'function') {
other.onDismiss = onDismiss;
}
if (typeof onShow === 'function') {
other.onShow = onShow;
}

return (
<Dialog {...other}
ref="dialogWindow"
Expand All @@ -126,12 +116,14 @@ const TimePickerDialog = React.createClass({
},

show() {
if (this.props.onShow && !this.state.open) this.props.onShow();
this.setState({
open: true,
});
},

dismiss() {
if (this.props.onDismiss && this.state.open) this.props.onDismiss();
this.setState({
open: false,
});
Expand Down

0 comments on commit d5bbcad

Please sign in to comment.