Sfoglia il codice sorgente

Moves native password required prompt to room lock feature.

Moves native dialogs to use dialog container. Implements native Dialog that uses react native Prompt.
master
damencho 8 anni fa
parent
commit
309ce43e05

+ 1
- 104
react/features/conference/components/Conference.native.js Vedi File

6
 import { Container } from '../../base/react';
6
 import { Container } from '../../base/react';
7
 import { FilmStrip } from '../../film-strip';
7
 import { FilmStrip } from '../../film-strip';
8
 import { LargeVideo } from '../../large-video';
8
 import { LargeVideo } from '../../large-video';
9
-import { RoomLockPrompt } from '../../room-lock';
10
 import { Toolbar } from '../../toolbar';
9
 import { Toolbar } from '../../toolbar';
11
 
10
 
12
-import PasswordRequiredPrompt from './PasswordRequiredPrompt';
13
 import { styles } from './styles';
11
 import { styles } from './styles';
14
 
12
 
15
 /**
13
 /**
30
      * @static
28
      * @static
31
      */
29
      */
32
     static propTypes = {
30
     static propTypes = {
33
-        /**
34
-         * The indicator which determines whether a password is required to join
35
-         * the conference and has not been provided yet.
36
-         *
37
-         * @private
38
-         * @type {JitsiConference}
39
-         */
40
-        _passwordRequired: React.PropTypes.object,
41
-
42
-        /**
43
-         * The indicator which determines whether the user has requested to lock
44
-         * the conference/room.
45
-         *
46
-         * @private
47
-         * @type {JitsiConference}
48
-         */
49
-        _roomLockRequested: React.PropTypes.object,
50
         dispatch: React.PropTypes.func
31
         dispatch: React.PropTypes.func
51
     }
32
     }
52
 
33
 
128
 
109
 
129
                 <DialogContainer />
110
                 <DialogContainer />
130
 
111
 
131
-                {
132
-                    this._renderPrompt()
133
-                }
134
             </Container>
112
             </Container>
135
         );
113
         );
136
     }
114
     }
164
         this._setToolbarTimeout(toolbarVisible);
142
         this._setToolbarTimeout(toolbarVisible);
165
     }
143
     }
166
 
144
 
167
-    /**
168
-     * Renders a prompt if a password is required to join the conference.
169
-     *
170
-     * @private
171
-     * @returns {ReactElement}
172
-     */
173
-    _renderPasswordRequiredPrompt() {
174
-        const required = this.props._passwordRequired;
175
-
176
-        if (required) {
177
-            return (
178
-                <PasswordRequiredPrompt conference = { required } />
179
-            );
180
-        }
181
-
182
-        return null;
183
-    }
184
-
185
-    /**
186
-     * Renders a prompt if necessary such as when a password is required to join
187
-     * the conference or the user has requested to lock the conference/room.
188
-     *
189
-     * @private
190
-     * @returns {ReactElement}
191
-     */
192
-    _renderPrompt() {
193
-        return (
194
-            this._renderPasswordRequiredPrompt()
195
-                || this._renderRoomLockPrompt()
196
-        );
197
-    }
198
-
199
-    /**
200
-     * Renders a prompt if the user has requested to lock the conference/room.
201
-     *
202
-     * @private
203
-     * @returns {ReactElement}
204
-     */
205
-    _renderRoomLockPrompt() {
206
-        const requested = this.props._roomLockRequested;
207
-
208
-        if (requested) {
209
-            return (
210
-                <RoomLockPrompt conference = { requested } />
211
-            );
212
-        }
213
-
214
-        return null;
215
-    }
216
-
217
     /**
145
     /**
218
      * Triggers the default toolbar timeout.
146
      * Triggers the default toolbar timeout.
219
      *
147
      *
231
     }
159
     }
232
 }
160
 }
233
 
161
 
234
-/**
235
- * Maps (parts of) the Redux state to the associated Conference's props.
236
- *
237
- * @param {Object} state - The Redux state.
238
- * @private
239
- * @returns {{
240
- *     _passwordRequired: boolean
241
- * }}
242
- */
243
-function _mapStateToProps(state) {
244
-    return {
245
-        /**
246
-         * The indicator which determines whether a password is required to join
247
-         * the conference and has not been provided yet.
248
-         *
249
-         * @private
250
-         * @type {JitsiConference}
251
-         */
252
-        _passwordRequired: state['features/base/conference'].passwordRequired,
253
-
254
-        /**
255
-         * The indicator which determines whether the user has requested to lock
256
-         * the conference/room.
257
-         *
258
-         * @private
259
-         * @type {JitsiConference}
260
-         */
261
-        _roomLockRequested: state['features/room-lock'].requested
262
-    };
263
-}
264
-
265
-export default reactReduxConnect(_mapStateToProps)(Conference);
162
+export default reactReduxConnect()(Conference);

+ 0
- 24
react/features/room-lock/actionTypes.js Vedi File

1
-import { Symbol } from '../base/react';
2
-
3
-/**
4
- * The type of Redux action which begins a (user) request to lock a specific
5
- * JitsiConference.
6
- *
7
- * {
8
- *     type: BEGIN_ROOM_LOCK_REQUEST,
9
- *     conference: JitsiConference
10
- * }
11
- */
12
-export const BEGIN_ROOM_LOCK_REQUEST = Symbol('BEGIN_ROOM_LOCK_REQUEST');
13
-
14
-/**
15
- * The type of Redux action which end a (user) request to lock a specific
16
- * JitsiConference.
17
- *
18
- * {
19
- *     type: END_ROOM_LOCK_REQUEST,
20
- *     conference: JitsiConference,
21
- *     password: string
22
- * }
23
- */
24
-export const END_ROOM_LOCK_REQUEST = Symbol('END_ROOM_LOCK_REQUEST');

+ 5
- 14
react/features/room-lock/actions.js Vedi File

1
 import { setPassword } from '../base/conference';
1
 import { setPassword } from '../base/conference';
2
-import { openDialog } from '../base/dialog';
3
-import { PasswordRequiredPrompt } from './components';
4
-
5
-import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes';
2
+import { hideDialog, openDialog } from '../base/dialog';
3
+import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
6
 
4
 
7
 /**
5
 /**
8
  * Begins a (user) request to lock a specific conference/room.
6
  * Begins a (user) request to lock a specific conference/room.
21
         }
19
         }
22
 
20
 
23
         if (conference) {
21
         if (conference) {
24
-            dispatch({
25
-                type: BEGIN_ROOM_LOCK_REQUEST,
26
-                conference
27
-            });
22
+            dispatch(openDialog(RoomLockPrompt, { conference }));
28
         }
23
         }
29
     };
24
     };
30
 }
25
 }
45
                 ? dispatch(setPassword(conference, conference.lock, password))
40
                 ? dispatch(setPassword(conference, conference.lock, password))
46
                 : Promise.resolve();
41
                 : Promise.resolve();
47
         const endRoomLockRequest_ = () => {
42
         const endRoomLockRequest_ = () => {
48
-            dispatch({
49
-                type: END_ROOM_LOCK_REQUEST,
50
-                conference,
51
-                password
52
-            });
43
+            dispatch(hideDialog());
53
         };
44
         };
54
 
45
 
55
         setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
46
         setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
63
  * requesting password.
54
  * requesting password.
64
  * @protected
55
  * @protected
65
  * @returns {{
56
  * @returns {{
66
- *     type: BEGIN_DIALOG_REQUEST,
57
+ *     type: OPEN_DIALOG,
67
  *     component: Component,
58
  *     component: Component,
68
  *     props: React.PropTypes
59
  *     props: React.PropTypes
69
  * }}
60
  * }}

react/features/conference/components/PasswordRequiredPrompt.native.js → react/features/room-lock/components/PasswordRequiredPrompt.native.js Vedi File

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3
 import { connect } from 'react-redux';
2
 import { connect } from 'react-redux';
3
+import { Dialog } from '../../base/dialog';
4
 
4
 
5
 import { setPassword } from '../../base/conference';
5
 import { setPassword } from '../../base/conference';
6
-import { translate } from '../../base/i18n';
7
 
6
 
8
 /**
7
 /**
9
  * Implements a React Component which prompts the user when a password is
8
  * Implements a React Component which prompts the user when a password is
22
          * @type {JitsiConference}
21
          * @type {JitsiConference}
23
          */
22
          */
24
         conference: React.PropTypes.object,
23
         conference: React.PropTypes.object,
25
-        dispatch: React.PropTypes.func,
26
-
27
-        /**
28
-         * The function to translate human-readable text.
29
-         *
30
-         * @public
31
-         * @type {Function}
32
-         */
33
-        t: React.PropTypes.func
24
+        dispatch: React.PropTypes.func
34
     }
25
     }
35
 
26
 
36
     /**
27
     /**
54
      * @returns {ReactElement}
45
      * @returns {ReactElement}
55
      */
46
      */
56
     render() {
47
     render() {
57
-        const { t } = this.props;
58
 
48
 
59
         return (
49
         return (
60
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
61
                 onCancel = { this._onCancel }
52
                 onCancel = { this._onCancel }
62
                 onSubmit = { this._onSubmit }
53
                 onSubmit = { this._onSubmit }
63
-                placeholder = { t('dialog.passwordLabel') }
64
-                title = { t('dialog.passwordRequired') }
65
-                visible = { true } />
54
+                titleKey = 'dialog.passwordRequired' />
66
         );
55
         );
67
     }
56
     }
68
 
57
 
70
      * Notifies this prompt that it has been dismissed by cancel.
59
      * Notifies this prompt that it has been dismissed by cancel.
71
      *
60
      *
72
      * @private
61
      * @private
73
-     * @returns {void}
62
+     * @returns {boolean} whether to hide dialog.
74
      */
63
      */
75
     _onCancel() {
64
     _onCancel() {
76
         // XXX The user has canceled this prompt for a password so we are to
65
         // XXX The user has canceled this prompt for a password so we are to
77
         // attempt joining the conference without a password. If the conference
66
         // attempt joining the conference without a password. If the conference
78
         // still requires a password to join, the user will be prompted again
67
         // still requires a password to join, the user will be prompted again
79
         // later.
68
         // later.
80
-        this._onSubmit(undefined);
69
+        return this._onSubmit(undefined);
81
     }
70
     }
82
 
71
 
83
     /**
72
     /**
86
      *
75
      *
87
      * @param {string} value - The submitted value.
76
      * @param {string} value - The submitted value.
88
      * @private
77
      * @private
89
-     * @returns {void}
78
+     * @returns {boolean} whether to hide dialog.
90
      */
79
      */
91
     _onSubmit(value) {
80
     _onSubmit(value) {
92
         const conference = this.props.conference;
81
         const conference = this.props.conference;
93
 
82
 
94
         this.props.dispatch(setPassword(conference, conference.join, value));
83
         this.props.dispatch(setPassword(conference, conference.join, value));
84
+
85
+        return true;
95
     }
86
     }
96
 }
87
 }
97
 
88
 
98
-export default translate(connect()(PasswordRequiredPrompt));
89
+export default connect()(PasswordRequiredPrompt);

+ 14
- 21
react/features/room-lock/components/RoomLockPrompt.native.js Vedi File

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3
 import { connect } from 'react-redux';
2
 import { connect } from 'react-redux';
4
-
5
-import { translate } from '../../base/i18n';
3
+import { Dialog } from '../../base/dialog';
6
 
4
 
7
 import { endRoomLockRequest } from '../actions';
5
 import { endRoomLockRequest } from '../actions';
8
 
6
 
23
          * @type {JitsiConference}
21
          * @type {JitsiConference}
24
          */
22
          */
25
         conference: React.PropTypes.object,
23
         conference: React.PropTypes.object,
26
-        dispatch: React.PropTypes.func,
27
-
28
-        /**
29
-         * The function to translate human-readable text.
30
-         *
31
-         * @public
32
-         * @type {Function}
33
-         */
34
-        t: React.PropTypes.func
24
+        dispatch: React.PropTypes.func
35
     }
25
     }
36
 
26
 
37
     /**
27
     /**
55
      * @returns {ReactElement}
45
      * @returns {ReactElement}
56
      */
46
      */
57
     render() {
47
     render() {
58
-        const { t } = this.props;
59
 
48
 
60
         return (
49
         return (
61
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
62
                 onCancel = { this._onCancel }
52
                 onCancel = { this._onCancel }
63
                 onSubmit = { this._onSubmit }
53
                 onSubmit = { this._onSubmit }
64
-                placeholder = { t('dialog.passwordLabel') }
65
-                title = { t('toolbar.lock') }
66
-                visible = { true } />
54
+                titleKey = 'toolbar.lock' />
67
         );
55
         );
68
     }
56
     }
69
 
57
 
71
      * Notifies this prompt that it has been dismissed by cancel.
59
      * Notifies this prompt that it has been dismissed by cancel.
72
      *
60
      *
73
      * @private
61
      * @private
74
-     * @returns {void}
62
+     * @returns {boolean} whether to hide the dialog
75
      */
63
      */
76
     _onCancel() {
64
     _onCancel() {
77
         // An undefined password is understood to cancel the request to lock the
65
         // An undefined password is understood to cancel the request to lock the
78
         // conference/room.
66
         // conference/room.
79
-        this._onSubmit(undefined);
67
+        return this._onSubmit(undefined);
80
     }
68
     }
81
 
69
 
82
     /**
70
     /**
85
      *
73
      *
86
      * @param {string} value - The submitted value.
74
      * @param {string} value - The submitted value.
87
      * @private
75
      * @private
88
-     * @returns {void}
76
+     * @returns {boolean} returns false, we do not want to hide dialog as this
77
+     * will be handled inside endRoomLockRequest after setting password is
78
+     * resolved.
89
      */
79
      */
90
     _onSubmit(value) {
80
     _onSubmit(value) {
91
         this.props.dispatch(endRoomLockRequest(this.props.conference, value));
81
         this.props.dispatch(endRoomLockRequest(this.props.conference, value));
82
+
83
+        // do not hide
84
+        return false;
92
     }
85
     }
93
 }
86
 }
94
 
87
 
95
-export default translate(connect()(RoomLockPrompt));
88
+export default connect()(RoomLockPrompt);

+ 0
- 1
react/features/room-lock/index.js Vedi File

2
 export * from './components';
2
 export * from './components';
3
 
3
 
4
 import './middleware';
4
 import './middleware';
5
-import './reducer';

+ 0
- 33
react/features/room-lock/reducer.js Vedi File

1
-import {
2
-    CONFERENCE_FAILED,
3
-    CONFERENCE_JOINED,
4
-    CONFERENCE_LEFT
5
-} from '../base/conference';
6
-import { ReducerRegistry, setStateProperty } from '../base/redux';
7
-
8
-import { BEGIN_ROOM_LOCK_REQUEST, END_ROOM_LOCK_REQUEST } from './actionTypes';
9
-
10
-ReducerRegistry.register('features/room-lock', (state = {}, action) => {
11
-    switch (action.type) {
12
-    case BEGIN_ROOM_LOCK_REQUEST:
13
-        return setStateProperty(state, 'requested', action.conference);
14
-
15
-    case CONFERENCE_FAILED:
16
-    case CONFERENCE_LEFT:
17
-    case END_ROOM_LOCK_REQUEST: {
18
-        if (state.requested === action.conference) {
19
-            return setStateProperty(state, 'requested', undefined);
20
-        }
21
-        break;
22
-    }
23
-
24
-    case CONFERENCE_JOINED: {
25
-        if (state.requested !== action.conference) {
26
-            return setStateProperty(state, 'requested', undefined);
27
-        }
28
-        break;
29
-    }
30
-    }
31
-
32
-    return state;
33
-});

Loading…
Annulla
Salva