Переглянути джерело

Handles disabled dial-out codes. (#1847)

Hides the UI component showing dialout codes and uses the dial input without validating it.

Skips printing error when dial-in numbers is not configured.
master
Дамян Минков 7 роки тому
джерело
коміт
82117a0aef

+ 17
- 0
react/features/dial-out/actions.js Переглянути файл

@@ -47,6 +47,19 @@ export function checkDialNumber(dialNumber) {
47 47
     return (dispatch, getState) => {
48 48
         const { dialOutAuthUrl } = getState()['features/base/config'];
49 49
 
50
+        if (!dialOutAuthUrl) {
51
+            // no auth url, let's say it is valid
52
+            const response = {};
53
+
54
+            response.allow = true;
55
+            dispatch({
56
+                type: PHONE_NUMBER_CHECKED,
57
+                response
58
+            });
59
+
60
+            return;
61
+        }
62
+
50 63
         const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
51 64
 
52 65
         $.getJSON(fullUrl)
@@ -82,6 +95,10 @@ export function updateDialOutCodes() {
82 95
     return (dispatch, getState) => {
83 96
         const { dialOutCodesUrl } = getState()['features/base/config'];
84 97
 
98
+        if (!dialOutCodesUrl) {
99
+            return;
100
+        }
101
+
85 102
         $.getJSON(dialOutCodesUrl)
86 103
             .success(response =>
87 104
                 dispatch({

+ 28
- 7
react/features/dial-out/components/DialOutDialog.web.js Переглянути файл

@@ -18,6 +18,11 @@ class DialOutDialog extends Component {
18 18
      * @static
19 19
      */
20 20
     static propTypes = {
21
+        /**
22
+         * The redux state representing the list of dial-out codes.
23
+         */
24
+        _dialOutCodes: React.PropTypes.array,
25
+
21 26
         /**
22 27
          * Property indicating if a dial number is allowed.
23 28
          */
@@ -176,15 +181,23 @@ class DialOutDialog extends Component {
176 181
      * @returns {void}
177 182
      */
178 183
     _onDialNumberChange(dialCode, dialInput) {
179
-        // We remove all starting zeros from the dial input before attaching it
180
-        // to the country code.
181
-        const formattedDialInput = dialInput.replace(/^(0+)/, '');
184
+        let formattedDialInput, formattedNumber;
182 185
 
183
-        const dialNumber = `${dialCode}${formattedDialInput}`;
186
+        // if there are no dial out codes it is possible they are disabled
187
+        // so we get the input as is, it can be just a sip address
188
+        if (this.props._dialOutCodes) {
189
+            // We remove all starting zeros from the dial input before attaching
190
+            // it to the country code.
191
+            formattedDialInput = dialInput.replace(/^(0+)/, '');
184 192
 
185
-        const formattedNumber = this._formatDialNumber(dialNumber);
193
+            const dialNumber = `${dialCode}${formattedDialInput}`;
186 194
 
187
-        this.props.checkDialNumber(formattedNumber);
195
+            formattedNumber = this._formatDialNumber(dialNumber);
196
+
197
+            this.props.checkDialNumber(formattedNumber);
198
+        } else {
199
+            formattedNumber = formattedDialInput = dialInput;
200
+        }
188 201
 
189 202
         this.setState({
190 203
             dialNumber: formattedNumber,
@@ -205,9 +218,17 @@ class DialOutDialog extends Component {
205 218
  * }}
206 219
  */
207 220
 function _mapStateToProps(state) {
208
-    const { isDialNumberAllowed } = state['features/dial-out'];
221
+    const { dialOutCodes, isDialNumberAllowed } = state['features/dial-out'];
209 222
 
210 223
     return {
224
+        /**
225
+         * List of dial-out codes.
226
+         *
227
+         * @private
228
+         * @type {array}
229
+         */
230
+        _dialOutCodes: dialOutCodes,
231
+
211 232
         /**
212 233
          * Property indicating if a dial number is allowed.
213 234
          *

+ 4
- 4
react/features/dial-out/components/DialOutNumbersForm.web.js Переглянути файл

@@ -141,12 +141,11 @@ class DialOutNumbersForm extends Component {
141 141
      */
142 142
     render() {
143 143
         const { t, _dialOutCodes } = this.props;
144
-        const items
145
-            = _dialOutCodes ? this._formatCountryCodes(_dialOutCodes) : [];
146 144
 
147 145
         return (
148 146
             <div className = 'form-control'>
149
-                { this._createDropdownMenu(items) }
147
+                { _dialOutCodes ? this._createDropdownMenu(
148
+                        this._formatCountryCodes(_dialOutCodes)) : null }
150 149
                 <div className = 'dial-out-input'>
151 150
                     <AKFieldText
152 151
                         autoFocus = { true }
@@ -155,7 +154,8 @@ class DialOutNumbersForm extends Component {
155 154
                         onChange = { this._onInputChange }
156 155
                         placeholder = { t('dialOut.enterPhone') }
157 156
                         ref = { this._setDialInputElement }
158
-                        shouldFitContainer = { true } />
157
+                        shouldFitContainer = { true }
158
+                        value = { this.state.dialInput } />
159 159
                 </div>
160 160
             </div>
161 161
         );

+ 6
- 1
react/features/dial-out/reducer.js Переглянути файл

@@ -20,7 +20,12 @@ ReducerRegistry.register(
20 20
     (state = DEFAULT_STATE, action) => {
21 21
         switch (action.type) {
22 22
         case DIAL_OUT_CANCELED: {
23
-            return DEFAULT_STATE;
23
+            // if we have already downloaded codes fill them in default state
24
+            // to skip another ajax query
25
+            return {
26
+                ...DEFAULT_STATE,
27
+                dialOutCodes: state.dialOutCodes
28
+            };
24 29
         }
25 30
         case DIAL_OUT_CODES_UPDATED: {
26 31
             return {

+ 1
- 5
react/features/invite/actions.js Переглянути файл

@@ -40,11 +40,7 @@ export function updateDialInNumbers() {
40 40
         const mucURL = hosts && hosts.muc;
41 41
 
42 42
         if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
43
-            dispatch({
44
-                type: UPDATE_DIAL_IN_NUMBERS_FAILED,
45
-                error: 'URLs for fetching dial in numbers not properly defined'
46
-            });
47
-
43
+            // URLs for fetching dial in numbers not defined
48 44
             return;
49 45
         }
50 46
 

Завантаження…
Відмінити
Зберегти