Bläddra i källkod

fix(peopleSearch): queryTypes are defined in config.js

master
hristoterezov 7 år sedan
förälder
incheckning
cd3dad956b

+ 33
- 9
react/features/invite/components/AddPeopleDialog.web.js Visa fil

@@ -14,6 +14,8 @@ import { invitePeople, searchPeople } from '../functions';
14 14
 
15 15
 declare var interfaceConfig: Object;
16 16
 
17
+const { PropTypes } = React;
18
+
17 19
 /**
18 20
  * The dialog that allows to invite people to the call.
19 21
  */
@@ -27,32 +29,37 @@ class AddPeopleDialog extends Component {
27 29
         /**
28 30
          * The URL pointing to the service allowing for people invite.
29 31
          */
30
-        _inviteServiceUrl: React.PropTypes.string,
32
+        _inviteServiceUrl: PropTypes.string,
31 33
 
32 34
         /**
33 35
          * The url of the conference to invite people to.
34 36
          */
35
-        _inviteUrl: React.PropTypes.string,
37
+        _inviteUrl: PropTypes.string,
36 38
 
37 39
         /**
38 40
          * The JWT token.
39 41
          */
40
-        _jwt: React.PropTypes.string,
42
+        _jwt: PropTypes.string,
43
+
44
+        /**
45
+         * The query types used when searching people.
46
+         */
47
+        _peopleSearchQueryTypes: PropTypes.arrayOf(PropTypes.string),
41 48
 
42 49
         /**
43 50
          * The URL pointing to the service allowing for people search.
44 51
          */
45
-        _peopleSearchUrl: React.PropTypes.string,
52
+        _peopleSearchUrl: PropTypes.string,
46 53
 
47 54
         /**
48 55
          * The function closing the dialog.
49 56
          */
50
-        hideDialog: React.PropTypes.func,
57
+        hideDialog: PropTypes.func,
51 58
 
52 59
         /**
53 60
          * Invoked to obtain translated strings.
54 61
          */
55
-        t: React.PropTypes.func
62
+        t: PropTypes.func
56 63
     };
57 64
 
58 65
     /**
@@ -84,8 +91,20 @@ class AddPeopleDialog extends Component {
84 91
 
85 92
         this._multiselect = null;
86 93
         this._resourceClient = {
87
-            makeQuery: text => searchPeople(
88
-                this.props._peopleSearchUrl, this.props._jwt, text),
94
+            makeQuery: text => {
95
+                const {
96
+                    _jwt,
97
+                    _peopleSearchQueryTypes,
98
+                    _peopleSearchUrl
99
+                } = this.props;
100
+
101
+                return searchPeople(
102
+                    _peopleSearchUrl,
103
+                    _jwt,
104
+                    text,
105
+                    _peopleSearchQueryTypes
106
+                );
107
+            },
89 108
             parseResults: response => response.map(user => {
90 109
                 const avatar = ( // eslint-disable-line no-extra-parens
91 110
                     <Avatar
@@ -299,12 +318,17 @@ class AddPeopleDialog extends Component {
299 318
  * }}
300 319
  */
301 320
 function _mapStateToProps(state) {
302
-    const { peopleSearchUrl, inviteServiceUrl } = state['features/base/config'];
321
+    const {
322
+        inviteServiceUrl,
323
+        peopleSearchQueryTypes,
324
+        peopleSearchUrl
325
+     } = state['features/base/config'];
303 326
 
304 327
     return {
305 328
         _jwt: state['features/jwt'].jwt,
306 329
         _inviteUrl: getInviteURL(state),
307 330
         _inviteServiceUrl: inviteServiceUrl,
331
+        _peopleSearchQueryTypes: peopleSearchQueryTypes,
308 332
         _peopleSearchUrl: peopleSearchUrl
309 333
     };
310 334
 }

+ 10
- 3
react/features/invite/functions.js Visa fil

@@ -6,14 +6,21 @@ declare var $: Function;
6 6
  * @param {string} serviceUrl - The service to query.
7 7
  * @param {string} jwt - The jwt token to pass to the search service.
8 8
  * @param {string} text - Text to search.
9
+ * @param {Array<string>} queryTypes - Array with the query types that will be
10
+ * executed - "conferenceRooms" | "user" | "room".
9 11
  * @returns {Promise} - The promise created by the request.
10 12
  */
11
-export function searchPeople(serviceUrl, jwt, text) {
12
-    const queryTypes = '["conferenceRooms","user","room"]';
13
+export function searchPeople(// eslint-disable-line max-params
14
+    serviceUrl,
15
+    jwt,
16
+    text,
17
+    queryTypes = [ 'conferenceRooms', 'user', 'room' ]
18
+) {
19
+    const queryTypesString = JSON.stringify(queryTypes);
13 20
 
14 21
     return new Promise((resolve, reject) => {
15 22
         $.getJSON(`${serviceUrl}?query=${encodeURIComponent(text)}`
16
-            + `&queryTypes=${queryTypes}&jwt=${jwt}`,
23
+            + `&queryTypes=${queryTypesString}&jwt=${jwt}`,
17 24
         response => resolve(response)
18 25
         ).fail((jqxhr, textStatus, error) =>
19 26
             reject(error)

Laddar…
Avbryt
Spara