jiti-meet/react/features/base/dialog/components/Dialog.web.js

83 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-09-18 07:01:14 +00:00
import PropTypes from 'prop-types';
2017-03-07 03:34:51 +00:00
import React from 'react';
import { connect } from 'react-redux';
import AbstractDialog from './AbstractDialog';
import StatelessDialog from './StatelessDialog';
2017-03-07 03:34:51 +00:00
/**
* Web dialog that uses atlaskit modal-dialog to display dialogs.
*/
class Dialog extends AbstractDialog {
/**
* Web dialog component's property types.
*
* @static
*/
static propTypes = {
...AbstractDialog.propTypes,
2017-03-07 03:34:51 +00:00
/**
* Whether the dialog is modal. This means clicking on the blanket will
* leave the dialog open. No cancel button.
*/
2017-09-18 07:01:14 +00:00
isModal: PropTypes.bool,
2017-03-07 03:34:51 +00:00
/**
* Disables rendering of the submit button.
*/
2017-09-18 07:01:14 +00:00
submitDisabled: PropTypes.bool,
2017-03-07 03:34:51 +00:00
/**
* Width of the dialog, can be:
* - 'small' (400px), 'medium' (600px), 'large' (800px),
* 'x-large' (968px)
* - integer value for pixel width
* - string value for percentage
*/
2017-09-18 07:01:14 +00:00
width: PropTypes.string
};
2017-03-07 03:34:51 +00:00
/**
* Initializes a new Dialog instance.
2017-03-07 03:34:51 +00:00
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
2017-03-07 03:34:51 +00:00
*/
constructor(props) {
super(props);
2017-03-07 03:34:51 +00:00
this._onCancel = this._onCancel.bind(this);
this._onSubmit = this._onSubmit.bind(this);
2017-03-07 03:34:51 +00:00
}
/**
* Implements React's {@link Component#render()}.
2017-03-07 03:34:51 +00:00
*
* @inheritdoc
2017-03-07 03:34:51 +00:00
* @returns {ReactElement}
*/
render() {
const props = {
...this.props,
2017-09-18 07:01:14 +00:00
onCancel: this._onCancel,
onSubmit: this._onSubmit
};
2017-03-07 03:34:51 +00:00
delete props.dispatch;
2017-03-07 03:34:51 +00:00
return <StatelessDialog { ...props } />;
2017-03-07 03:34:51 +00:00
}
/**
* Dispatches action to hide the dialog.
*
* @returns {void}
*/
_onCancel() {
2017-09-18 07:01:14 +00:00
this.props.isModal || super._onCancel();
2017-03-07 03:34:51 +00:00
}
}
export default connect()(Dialog);