Просмотр исходного кода

feat(shared-video): show invalid URL error.

master
Hristo Terezov 3 лет назад
Родитель
Сommit
b5551880f7

+ 9
- 0
css/modals/_dialog.scss Просмотреть файл

@@ -140,3 +140,12 @@
140 140
         margin: 16px auto 0 auto;
141 141
     }
142 142
 }
143
+
144
+/**
145
+ * Styling shared video dialog errors.
146
+ */
147
+.shared-video-dialog-error {
148
+    color: #E04757;
149
+    margin-top: 2px;
150
+    display: block;
151
+}

+ 1
- 0
lang/main.json Просмотреть файл

@@ -365,6 +365,7 @@
365 365
         "shareVideoTitle": "Share video",
366 366
         "shareYourScreen": "Share your screen",
367 367
         "shareYourScreenDisabled": "Screen sharing disabled.",
368
+        "sharedVideoDialogError": "Error: Invalid URL",
368 369
         "sharedVideoLinkPlaceholder": "YouTube link or direct video link",
369 370
         "startLiveStreaming": "Start live stream",
370 371
         "startRecording": "Start recording",

+ 13
- 1
react/features/shared-video/components/native/SharedVideoDialog.js Просмотреть файл

@@ -20,6 +20,10 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
20 20
     constructor(props) {
21 21
         super(props);
22 22
 
23
+        this.state = {
24
+            error: false
25
+        };
26
+
23 27
         this._onSubmitValue = this._onSubmitValue.bind(this);
24 28
     }
25 29
 
@@ -32,7 +36,13 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
32 36
      * @returns {boolean}
33 37
      */
34 38
     _onSubmitValue(value) {
35
-        return super._onSetVideoLink(value);
39
+        const result = super._onSetVideoLink(value);
40
+
41
+        if (!result) {
42
+            this.setState({ error: true });
43
+        }
44
+
45
+        return result;
36 46
     }
37 47
 
38 48
     /**
@@ -42,10 +52,12 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
42 52
      */
43 53
     render() {
44 54
         const { t } = this.props;
55
+        const { error } = this.state;
45 56
 
46 57
         return (
47 58
             <InputDialog
48 59
                 contentKey = 'dialog.shareVideoTitle'
60
+                messageKey = { error ? 'dialog.sharedVideoDialogError' : undefined }
49 61
                 onSubmit = { this._onSubmitValue }
50 62
                 textInputProps = {{
51 63
                     autoCapitalize: 'none',

+ 14
- 2
react/features/shared-video/components/web/SharedVideoDialog.js Просмотреть файл

@@ -26,7 +26,8 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
26 26
 
27 27
         this.state = {
28 28
             value: '',
29
-            okDisabled: true
29
+            okDisabled: true,
30
+            error: false
30 31
         };
31 32
 
32 33
         this._onChange = this._onChange.bind(this);
@@ -58,7 +59,15 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
58 59
      * @returns {boolean}
59 60
      */
60 61
     _onSubmitValue() {
61
-        return super._onSetVideoLink(this.state.value);
62
+        const result = super._onSetVideoLink(this.state.value);
63
+
64
+        if (!result) {
65
+            this.setState({
66
+                error: true
67
+            });
68
+        }
69
+
70
+        return result;
62 71
     }
63 72
 
64 73
     /**
@@ -68,6 +77,7 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
68 77
      */
69 78
     render() {
70 79
         const { t } = this.props;
80
+        const { error } = this.state;
71 81
 
72 82
         return (
73 83
             <Dialog
@@ -81,6 +91,7 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
81 91
                     autoFocus = { true }
82 92
                     className = 'input-control'
83 93
                     compact = { false }
94
+                    isInvalid = { error }
84 95
                     label = { t('dialog.videoLink') }
85 96
                     name = 'sharedVideoUrl'
86 97
                     onChange = { this._onChange }
@@ -88,6 +99,7 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
88 99
                     shouldFitContainer = { true }
89 100
                     type = 'text'
90 101
                     value = { this.state.value } />
102
+                { error && <span className = 'shared-video-dialog-error'>{ t('dialog.sharedVideoDialogError') }</span> }
91 103
             </Dialog>
92 104
         );
93 105
     }

Загрузка…
Отмена
Сохранить