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.5KB

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