Skip to content

Commit

Permalink
feat(shared-video): show invalid URL error.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Jan 24, 2022
1 parent c34d2de commit b555188
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
9 changes: 9 additions & 0 deletions css/modals/_dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,12 @@
margin: 16px auto 0 auto;
}
}

/**
* Styling shared video dialog errors.
*/
.shared-video-dialog-error {
color: #E04757;
margin-top: 2px;
display: block;
}
1 change: 1 addition & 0 deletions lang/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@
"shareVideoTitle": "Share video",
"shareYourScreen": "Share your screen",
"shareYourScreenDisabled": "Screen sharing disabled.",
"sharedVideoDialogError": "Error: Invalid URL",
"sharedVideoLinkPlaceholder": "YouTube link or direct video link",
"startLiveStreaming": "Start live stream",
"startRecording": "Start recording",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
constructor(props) {
super(props);

this.state = {
error: false
};

this._onSubmitValue = this._onSubmitValue.bind(this);
}

Expand All @@ -32,7 +36,13 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
* @returns {boolean}
*/
_onSubmitValue(value) {
return super._onSetVideoLink(value);
const result = super._onSetVideoLink(value);

if (!result) {
this.setState({ error: true });
}

return result;
}

/**
Expand All @@ -42,10 +52,12 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
*/
render() {
const { t } = this.props;
const { error } = this.state;

return (
<InputDialog
contentKey = 'dialog.shareVideoTitle'
messageKey = { error ? 'dialog.sharedVideoDialogError' : undefined }
onSubmit = { this._onSubmitValue }
textInputProps = {{
autoCapitalize: 'none',
Expand Down
16 changes: 14 additions & 2 deletions react/features/shared-video/components/web/SharedVideoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {

this.state = {
value: '',
okDisabled: true
okDisabled: true,
error: false
};

this._onChange = this._onChange.bind(this);
Expand Down Expand Up @@ -58,7 +59,15 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
* @returns {boolean}
*/
_onSubmitValue() {
return super._onSetVideoLink(this.state.value);
const result = super._onSetVideoLink(this.state.value);

if (!result) {
this.setState({
error: true
});
}

return result;
}

/**
Expand All @@ -68,6 +77,7 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
*/
render() {
const { t } = this.props;
const { error } = this.state;

return (
<Dialog
Expand All @@ -81,13 +91,15 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
autoFocus = { true }
className = 'input-control'
compact = { false }
isInvalid = { error }
label = { t('dialog.videoLink') }
name = 'sharedVideoUrl'
onChange = { this._onChange }
placeholder = { t('dialog.sharedVideoLinkPlaceholder') }
shouldFitContainer = { true }
type = 'text'
value = { this.state.value } />
{ error && <span className = 'shared-video-dialog-error'>{ t('dialog.sharedVideoDialogError') }</span> }
</Dialog>
);
}
Expand Down

0 comments on commit b555188

Please sign in to comment.