You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SharedVideoDialog.js 2.6KB

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