您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Dialog.web.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import AbstractDialog from './AbstractDialog';
  4. import StatelessDialog from './StatelessDialog';
  5. /**
  6. * Web dialog that uses atlaskit modal-dialog to display dialogs.
  7. */
  8. class Dialog extends AbstractDialog {
  9. /**
  10. * Web dialog component's property types.
  11. *
  12. * @static
  13. */
  14. static propTypes = {
  15. ...AbstractDialog.propTypes,
  16. /**
  17. * This is the body of the dialog, the component children.
  18. */
  19. children: React.PropTypes.node,
  20. /**
  21. * Whether the dialog is modal. This means clicking on the blanket will
  22. * leave the dialog open. No cancel button.
  23. */
  24. isModal: React.PropTypes.bool,
  25. /**
  26. * Disables rendering of the submit button.
  27. */
  28. submitDisabled: React.PropTypes.bool,
  29. /**
  30. * Width of the dialog, can be:
  31. * - 'small' (400px), 'medium' (600px), 'large' (800px),
  32. * 'x-large' (968px)
  33. * - integer value for pixel width
  34. * - string value for percentage
  35. */
  36. width: React.PropTypes.string
  37. };
  38. /**
  39. * Initializes a new Dialog instance.
  40. *
  41. * @param {Object} props - The read-only properties with which the new
  42. * instance is to be initialized.
  43. */
  44. constructor(props) {
  45. super(props);
  46. this._onCancel = this._onCancel.bind(this);
  47. this._onSubmit = this._onSubmit.bind(this);
  48. }
  49. /**
  50. * Implements React's {@link Component#render()}.
  51. *
  52. * @inheritdoc
  53. * @returns {ReactElement}
  54. */
  55. render() {
  56. const props = {
  57. ...this.props,
  58. onSubmit: this._onSubmit,
  59. onCancel: this._onCancel
  60. };
  61. delete props.dispatch;
  62. return <StatelessDialog { ...props } />;
  63. }
  64. /**
  65. * Dispatches action to hide the dialog.
  66. *
  67. * @returns {void}
  68. */
  69. _onCancel() {
  70. if (this.props.isModal) {
  71. return;
  72. }
  73. super._onCancel();
  74. }
  75. }
  76. export default connect()(Dialog);