Browse Source

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 years ago
parent
commit
82117a0aef

+ 17
- 0
react/features/dial-out/actions.js View File

47
     return (dispatch, getState) => {
47
     return (dispatch, getState) => {
48
         const { dialOutAuthUrl } = getState()['features/base/config'];
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
         const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
63
         const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
51
 
64
 
52
         $.getJSON(fullUrl)
65
         $.getJSON(fullUrl)
82
     return (dispatch, getState) => {
95
     return (dispatch, getState) => {
83
         const { dialOutCodesUrl } = getState()['features/base/config'];
96
         const { dialOutCodesUrl } = getState()['features/base/config'];
84
 
97
 
98
+        if (!dialOutCodesUrl) {
99
+            return;
100
+        }
101
+
85
         $.getJSON(dialOutCodesUrl)
102
         $.getJSON(dialOutCodesUrl)
86
             .success(response =>
103
             .success(response =>
87
                 dispatch({
104
                 dispatch({

+ 28
- 7
react/features/dial-out/components/DialOutDialog.web.js View File

18
      * @static
18
      * @static
19
      */
19
      */
20
     static propTypes = {
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
          * Property indicating if a dial number is allowed.
27
          * Property indicating if a dial number is allowed.
23
          */
28
          */
176
      * @returns {void}
181
      * @returns {void}
177
      */
182
      */
178
     _onDialNumberChange(dialCode, dialInput) {
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
         this.setState({
202
         this.setState({
190
             dialNumber: formattedNumber,
203
             dialNumber: formattedNumber,
205
  * }}
218
  * }}
206
  */
219
  */
207
 function _mapStateToProps(state) {
220
 function _mapStateToProps(state) {
208
-    const { isDialNumberAllowed } = state['features/dial-out'];
221
+    const { dialOutCodes, isDialNumberAllowed } = state['features/dial-out'];
209
 
222
 
210
     return {
223
     return {
224
+        /**
225
+         * List of dial-out codes.
226
+         *
227
+         * @private
228
+         * @type {array}
229
+         */
230
+        _dialOutCodes: dialOutCodes,
231
+
211
         /**
232
         /**
212
          * Property indicating if a dial number is allowed.
233
          * Property indicating if a dial number is allowed.
213
          *
234
          *

+ 4
- 4
react/features/dial-out/components/DialOutNumbersForm.web.js View File

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

+ 6
- 1
react/features/dial-out/reducer.js View File

20
     (state = DEFAULT_STATE, action) => {
20
     (state = DEFAULT_STATE, action) => {
21
         switch (action.type) {
21
         switch (action.type) {
22
         case DIAL_OUT_CANCELED: {
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
         case DIAL_OUT_CODES_UPDATED: {
30
         case DIAL_OUT_CODES_UPDATED: {
26
             return {
31
             return {

+ 1
- 5
react/features/invite/actions.js View File

40
         const mucURL = hosts && hosts.muc;
40
         const mucURL = hosts && hosts.muc;
41
 
41
 
42
         if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
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
             return;
44
             return;
49
         }
45
         }
50
 
46
 

Loading…
Cancel
Save