2020-06-12 10:15:16 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { InputDialog } from '../../../base/dialog';
|
2021-09-14 10:22:45 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2020-06-12 10:15:16 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2021-03-03 14:37:38 +00:00
|
|
|
import AbstractSharedVideoDialog from '../AbstractSharedVideoDialog';
|
2020-06-12 10:15:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a component to render a display name prompt.
|
|
|
|
*/
|
2021-03-03 14:37:38 +00:00
|
|
|
class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
|
2021-08-02 12:55:52 +00:00
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2022-01-22 00:50:33 +00:00
|
|
|
this.state = {
|
|
|
|
error: false
|
|
|
|
};
|
|
|
|
|
2021-08-02 12:55:52 +00:00
|
|
|
this._onSubmitValue = this._onSubmitValue.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onSubmitValue: () => boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to be invoked when the value of the link input is submitted.
|
|
|
|
*
|
|
|
|
* @param {string} value - The entered video link.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onSubmitValue(value) {
|
2022-01-22 00:50:33 +00:00
|
|
|
const result = super._onSetVideoLink(value);
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
this.setState({ error: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2021-08-02 12:55:52 +00:00
|
|
|
}
|
2021-05-13 11:36:19 +00:00
|
|
|
|
2020-06-12 10:15:16 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-09-14 10:22:45 +00:00
|
|
|
const { t } = this.props;
|
2022-01-22 00:50:33 +00:00
|
|
|
const { error } = this.state;
|
2021-09-14 10:22:45 +00:00
|
|
|
|
2020-06-12 10:15:16 +00:00
|
|
|
return (
|
|
|
|
<InputDialog
|
2022-01-22 00:50:33 +00:00
|
|
|
messageKey = { error ? 'dialog.sharedVideoDialogError' : undefined }
|
2021-08-02 12:55:52 +00:00
|
|
|
onSubmit = { this._onSubmitValue }
|
2020-06-12 10:15:16 +00:00
|
|
|
textInputProps = {{
|
2021-09-14 10:22:45 +00:00
|
|
|
autoCapitalize: 'none',
|
|
|
|
autoCorrect: false,
|
2022-02-04 10:20:47 +00:00
|
|
|
placeholder: t('dialog.sharedVideoLinkPlaceholder')
|
|
|
|
}}
|
|
|
|
titleKey = 'dialog.shareVideoTitle' />
|
2020-06-12 10:15:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-14 10:22:45 +00:00
|
|
|
export default translate(connect()(SharedVideoDialog));
|