Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SharedVideoDialog.tsx 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import InputDialog from '../../../base/dialog/components/native/InputDialog';
  5. import { translate } from '../../../base/i18n/functions';
  6. import AbstractSharedVideoDialog, { IProps } from '../AbstractSharedVideoDialog';
  7. interface IState {
  8. error: boolean;
  9. }
  10. /**
  11. * Implements a component to render a display name prompt.
  12. */
  13. class SharedVideoDialog extends AbstractSharedVideoDialog<IState> {
  14. /**
  15. * Instantiates a new component.
  16. *
  17. * @inheritdoc
  18. */
  19. constructor(props: IProps) {
  20. super(props);
  21. this.state = {
  22. error: false
  23. };
  24. this._onSubmitValue = this._onSubmitValue.bind(this);
  25. }
  26. /**
  27. * Callback to be invoked when the value of the link input is submitted.
  28. *
  29. * @param {string} value - The entered video link.
  30. * @returns {boolean}
  31. */
  32. _onSubmitValue(value: string) {
  33. const result = super._onSetVideoLink(value);
  34. if (!result) {
  35. this.setState({ error: true });
  36. }
  37. return result;
  38. }
  39. /**
  40. * Implements React's {@link Component#render()}.
  41. *
  42. * @inheritdoc
  43. */
  44. render() {
  45. const { t } = this.props;
  46. const { error } = this.state;
  47. return (
  48. <InputDialog
  49. messageKey = { error ? 'dialog.sharedVideoDialogError' : undefined }
  50. onSubmit = { this._onSubmitValue }
  51. textInputProps = {{
  52. autoCapitalize: 'none',
  53. autoCorrect: false,
  54. placeholder: t('dialog.sharedVideoLinkPlaceholder')
  55. }}
  56. titleKey = 'dialog.shareVideoTitle' />
  57. );
  58. }
  59. }
  60. /**
  61. * Maps part of the Redux state to the props of this component.
  62. *
  63. * @param {Object} state - The Redux state.
  64. * @private
  65. * @returns {IProps}
  66. */
  67. function mapStateToProps(state: IReduxState) {
  68. const { allowedUrlDomains } = state['features/shared-video'];
  69. return {
  70. _allowedUrlDomains: allowedUrlDomains
  71. };
  72. }
  73. export default translate(connect(mapStateToProps)(SharedVideoDialog));