Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SharedVideoDialog.tsx 2.6KB

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