2021-03-03 14:37:38 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-11-17 22:12:40 +00:00
|
|
|
import { hideDialog } from '../../../base/dialog/actions';
|
2022-08-05 12:07:28 +00:00
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
import { connect } from '../../../base/redux/functions';
|
2022-10-10 09:12:02 +00:00
|
|
|
import Dialog from '../../../base/ui/components/web/Dialog';
|
2022-08-05 12:07:28 +00:00
|
|
|
import Input from '../../../base/ui/components/web/Input';
|
2021-03-03 14:37:38 +00:00
|
|
|
import AbstractSharedVideoDialog from '../AbstractSharedVideoDialog';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders the video share dialog.
|
|
|
|
*
|
|
|
|
* @returns {React$Element<any>}
|
|
|
|
*/
|
2022-08-05 12:07:28 +00:00
|
|
|
class SharedVideoDialog extends AbstractSharedVideoDialog<any> {
|
2021-03-03 14:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-08-05 12:07:28 +00:00
|
|
|
constructor(props: any) {
|
2021-03-03 14:37:38 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
value: '',
|
2022-01-22 00:50:33 +00:00
|
|
|
okDisabled: true,
|
|
|
|
error: false
|
2021-03-03 14:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this._onChange = this._onChange.bind(this);
|
|
|
|
this._onSubmitValue = this._onSubmitValue.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback for the onChange event of the field.
|
|
|
|
*
|
2022-08-05 12:07:28 +00:00
|
|
|
* @param {string} value - The static event.
|
2021-03-03 14:37:38 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-08-05 12:07:28 +00:00
|
|
|
_onChange(value: string) {
|
2021-03-03 14:37:38 +00:00
|
|
|
this.setState({
|
2022-08-05 12:07:28 +00:00
|
|
|
value,
|
|
|
|
okDisabled: !value
|
2021-03-03 14:37:38 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to be invoked when the value of the link input is submitted.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onSubmitValue() {
|
2022-01-22 00:50:33 +00:00
|
|
|
const result = super._onSetVideoLink(this.state.value);
|
|
|
|
|
2022-11-17 22:12:40 +00:00
|
|
|
if (result) {
|
|
|
|
this.props.dispatch(hideDialog());
|
|
|
|
} else {
|
2022-01-22 00:50:33 +00:00
|
|
|
this.setState({
|
|
|
|
error: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2021-03-03 14:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { t } = this.props;
|
2022-01-22 00:50:33 +00:00
|
|
|
const { error } = this.state;
|
2021-03-03 14:37:38 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
2022-11-17 22:12:40 +00:00
|
|
|
disableAutoHideOnSubmit = { true }
|
2022-10-10 09:12:02 +00:00
|
|
|
ok = {{
|
|
|
|
disabled: this.state.okDisabled,
|
|
|
|
translationKey: 'dialog.Share'
|
|
|
|
}}
|
2021-03-03 14:37:38 +00:00
|
|
|
onSubmit = { this._onSubmitValue }
|
2022-10-10 09:12:02 +00:00
|
|
|
titleKey = 'dialog.shareVideoTitle'>
|
2022-08-05 12:07:28 +00:00
|
|
|
<Input
|
2021-03-03 14:37:38 +00:00
|
|
|
autoFocus = { true }
|
2022-10-10 09:12:02 +00:00
|
|
|
className = 'dialog-bottom-margin'
|
2022-08-05 12:07:28 +00:00
|
|
|
error = { error }
|
2021-03-03 14:37:38 +00:00
|
|
|
label = { t('dialog.videoLink') }
|
|
|
|
name = 'sharedVideoUrl'
|
|
|
|
onChange = { this._onChange }
|
2021-09-14 10:22:45 +00:00
|
|
|
placeholder = { t('dialog.sharedVideoLinkPlaceholder') }
|
2021-03-03 14:37:38 +00:00
|
|
|
type = 'text'
|
|
|
|
value = { this.state.value } />
|
2022-01-22 00:50:33 +00:00
|
|
|
{ error && <span className = 'shared-video-dialog-error'>{ t('dialog.sharedVideoDialogError') }</span> }
|
2021-03-03 14:37:38 +00:00
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect()(SharedVideoDialog));
|