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

80 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-03-07 03:34:51 +00:00
import React from 'react';
import { connect } from 'react-redux';
2017-11-13 15:54:04 +00:00
import AbstractDialog, { AbstractDialogPropTypes } from './AbstractDialog';
import StatelessDialog from './StatelessDialog';
2017-03-07 03:34:51 +00:00
/**
2017-11-13 15:54:04 +00:00
* Web dialog component's property types.
2017-03-07 03:34:51 +00:00
*/
2017-11-13 15:54:04 +00:00
type DialogPropTypes = {
...AbstractDialogPropTypes,
2017-03-07 03:34:51 +00:00
/**
2017-11-13 15:54:04 +00:00
* Whether the dialog is modal. This means clicking on the blanket will
* leave the dialog open. No cancel button.
2017-03-07 03:34:51 +00:00
*/
2017-11-13 15:54:04 +00:00
isModal: boolean,
2017-11-13 15:54:04 +00:00
/**
* Disables rendering of the submit button.
*/
submitDisabled: boolean,
2017-11-13 15:54:04 +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
*/
width: String
}
2017-03-07 03:34:51 +00:00
2017-11-13 15:54:04 +00:00
/**
* Web dialog that uses atlaskit modal-dialog to display dialogs.
*/
class Dialog extends AbstractDialog<DialogPropTypes> {
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);