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

SharedVideoDialog.tsx 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React from 'react';
  2. import { translate } from '../../../base/i18n/functions';
  3. import { connect } from '../../../base/redux/functions';
  4. import Dialog from '../../../base/ui/components/web/Dialog';
  5. import Input from '../../../base/ui/components/web/Input';
  6. import AbstractSharedVideoDialog from '../AbstractSharedVideoDialog';
  7. /**
  8. * Component that renders the video share dialog.
  9. *
  10. * @returns {React$Element<any>}
  11. */
  12. class SharedVideoDialog extends AbstractSharedVideoDialog<any> {
  13. /**
  14. * Instantiates a new component.
  15. *
  16. * @inheritdoc
  17. */
  18. constructor(props: any) {
  19. super(props);
  20. this.state = {
  21. value: '',
  22. okDisabled: true,
  23. error: false
  24. };
  25. this._onChange = this._onChange.bind(this);
  26. this._onSubmitValue = this._onSubmitValue.bind(this);
  27. }
  28. /**
  29. * Callback for the onChange event of the field.
  30. *
  31. * @param {string} value - The static event.
  32. * @returns {void}
  33. */
  34. _onChange(value: string) {
  35. this.setState({
  36. value,
  37. okDisabled: !value
  38. });
  39. }
  40. /**
  41. * Callback to be invoked when the value of the link input is submitted.
  42. *
  43. * @returns {boolean}
  44. */
  45. _onSubmitValue() {
  46. const result = super._onSetVideoLink(this.state.value);
  47. if (!result) {
  48. this.setState({
  49. error: true
  50. });
  51. }
  52. return result;
  53. }
  54. /**
  55. * Implements React's {@link Component#render()}.
  56. *
  57. * @inheritdoc
  58. */
  59. render() {
  60. const { t } = this.props;
  61. const { error } = this.state;
  62. return (
  63. <Dialog
  64. ok = {{
  65. disabled: this.state.okDisabled,
  66. translationKey: 'dialog.Share'
  67. }}
  68. onSubmit = { this._onSubmitValue }
  69. titleKey = 'dialog.shareVideoTitle'>
  70. <Input
  71. autoFocus = { true }
  72. className = 'dialog-bottom-margin'
  73. error = { error }
  74. label = { t('dialog.videoLink') }
  75. name = 'sharedVideoUrl'
  76. onChange = { this._onChange }
  77. placeholder = { t('dialog.sharedVideoLinkPlaceholder') }
  78. type = 'text'
  79. value = { this.state.value } />
  80. { error && <span className = 'shared-video-dialog-error'>{ t('dialog.sharedVideoDialogError') }</span> }
  81. </Dialog>
  82. );
  83. }
  84. }
  85. export default translate(connect()(SharedVideoDialog));