瀏覽代碼

Merge pull request #1379 from jitsi/base-react-dialogs-2

Password required dialog (web&native) and native room lock using basic react dialogs.
j8
yanas 8 年之前
父節點
當前提交
3daae94bca

+ 0
- 4
conference.js 查看文件

@@ -385,10 +385,6 @@ class ConferenceConnector {
385 385
         logger.error('CONFERENCE FAILED:', err, ...params);
386 386
         APP.UI.hideRingOverLay();
387 387
         switch (err) {
388
-            // room is locked by the password
389
-        case ConferenceErrors.PASSWORD_REQUIRED:
390
-            APP.UI.emitEvent(UIEvents.PASSWORD_REQUIRED);
391
-            break;
392 388
 
393 389
         case ConferenceErrors.CONNECTION_ERROR:
394 390
             {

+ 0
- 23
modules/UI/invite/Invite.js 查看文件

@@ -47,31 +47,8 @@ class Invite {
47 47
             }
48 48
         });
49 49
 
50
-        this.conference.on(ConferenceEvents.CONFERENCE_JOINED, () => {
51
-            let roomLocker = this.getRoomLocker();
52
-            roomLocker.hideRequirePasswordDialog();
53
-        });
54
-
55 50
         APP.UI.addListener( UIEvents.INVITE_CLICKED,
56 51
                             () => { this.openLinkDialog(); });
57
-
58
-        APP.UI.addListener( UIEvents.PASSWORD_REQUIRED,
59
-            () => {
60
-                let roomLocker = this.getRoomLocker();
61
-                this.setLockedFromElsewhere(true);
62
-                roomLocker.requirePassword().then(() => {
63
-                    let pass = roomLocker.password;
64
-                    // we received that password is required, but user is trying
65
-                    // anyway to login without a password, mark room as not
66
-                    // locked in case he succeeds (maybe someone removed the
67
-                    // password meanwhile), if it is still locked another
68
-                    // password required will be received and the room again
69
-                    // will be marked as locked.
70
-                    if (!pass)
71
-                        this.setLockedFromElsewhere(false);
72
-                    this.conference.join(pass);
73
-                });
74
-            });
75 52
     }
76 53
 
77 54
     /**

+ 0
- 162
modules/UI/invite/RequirePasswordDialog.js 查看文件

@@ -1,162 +0,0 @@
1
-/* global APP */
2
-
3
-import UIUtil from '../util/UIUtil';
4
-
5
-/**
6
- * Show dialog which asks for required conference password.
7
- * @returns {Promise<string>} password or nothing if user canceled
8
- */
9
-export default class RequirePasswordDialog {
10
-    constructor() {
11
-        this.titleKey = 'dialog.passwordRequired';
12
-        this.labelKey = 'dialog.passwordLabel';
13
-        this.errorKey = 'dialog.incorrectPassword';
14
-        this.errorId = 'passwordRequiredError';
15
-        this.inputId = 'passwordRequiredInput';
16
-        this.inputErrorClass = 'error';
17
-        this.isOpened = false;
18
-    }
19
-
20
-    /**
21
-     * Registering dialog listeners
22
-     * @private
23
-     */
24
-    _registerListeners() {
25
-        let el = document.getElementById(this.inputId);
26
-        el.addEventListener('keypress', this._hideError.bind(this));
27
-    }
28
-
29
-    /**
30
-     * Helper method returning dialog body
31
-     * @returns {string}
32
-     * @private
33
-     */
34
-    _getBodyMessage() {
35
-        return (
36
-            `<div class="form-control">
37
-                <label class="input-control__label"
38
-                       data-i18n="${this.labelKey}"></label>
39
-                <input class="input-control__input input-control"
40
-                       name="lockKey" type="text"
41
-                   data-i18n="[placeholder]dialog.password"
42
-                   autofocus id="${this.inputId}">
43
-                <p class="form-control__hint form-control__hint_error hide"
44
-                   id="${this.errorId}"
45
-                   data-i18n="${this.errorKey}"></p>
46
-            </div>`
47
-        );
48
-    }
49
-
50
-    /**
51
-     * Asking for a password
52
-     * @returns {Promise}
53
-     */
54
-    askForPassword() {
55
-        if (!this.isOpened) {
56
-            return this.open();
57
-        }
58
-
59
-        return new Promise((resolve, reject) => {
60
-            this.resolve = resolve;
61
-            this.reject = reject;
62
-            this._showError();
63
-        });
64
-    }
65
-
66
-    /**
67
-     * Opens the dialog
68
-     * @returns {Promise}
69
-     */
70
-    open() {
71
-        let { titleKey } = this;
72
-        let msgString = this._getBodyMessage();
73
-
74
-        return new Promise((resolve, reject) => {
75
-            this.resolve = resolve;
76
-            this.reject = reject;
77
-            let submitFunction = this._submitFunction.bind(this);
78
-            let closeFunction = this._closeFunction.bind(this);
79
-
80
-            this._dialog = APP.UI.messageHandler.openTwoButtonDialog({
81
-                titleKey,
82
-                msgString,
83
-                leftButtonKey: "dialog.Ok",
84
-                submitFunction,
85
-                closeFunction,
86
-                focus: ':input:first'
87
-            });
88
-
89
-            this._registerListeners();
90
-            this.isOpened = true;
91
-        });
92
-    }
93
-
94
-    /**
95
-     * Submit dialog callback
96
-     * @param e - event
97
-     * @param v - value
98
-     * @param m - message
99
-     * @param f - form
100
-     * @private
101
-     */
102
-    _submitFunction(e, v, m, f) {
103
-        e.preventDefault();
104
-        this._processInput(v, f);
105
-    }
106
-
107
-    /**
108
-     * Processing input in dialog
109
-     * @param v - value
110
-     * @param f - form
111
-     * @private
112
-     */
113
-    _processInput(v, f) {
114
-        if (v && f.lockKey) {
115
-            this.resolve(UIUtil.escapeHtml(f.lockKey));
116
-        } else {
117
-            this.reject(APP.UI.messageHandler.CANCEL);
118
-        }
119
-    }
120
-
121
-    /**
122
-     * Close dialog callback
123
-     * @private
124
-     */
125
-    _closeFunction(e, v, m, f) {
126
-        this._processInput(v, f);
127
-        this._hideError();
128
-        this.close();
129
-    }
130
-
131
-    /**
132
-     * Method showing error hint
133
-     * @private
134
-     */
135
-    _showError() {
136
-        let className = this.inputErrorClass;
137
-        let input = document.getElementById(this.inputId);
138
-        document.getElementById(this.errorId).classList.remove('hide');
139
-        input.classList.add(className);
140
-        input.select();
141
-    }
142
-
143
-    /**
144
-     * Method hiding error hint
145
-     * @private
146
-     */
147
-    _hideError() {
148
-        let className = this.inputErrorClass;
149
-        document.getElementById(this.errorId).classList.add('hide');
150
-        document.getElementById(this.inputId).classList.remove(className);
151
-    }
152
-
153
-    /**
154
-     * Close the dialog
155
-     */
156
-    close() {
157
-        if (this._dialog) {
158
-            this._dialog.close();
159
-        }
160
-        this.isOpened = false;
161
-    }
162
-}

+ 0
- 29
modules/UI/invite/RoomLocker.js 查看文件

@@ -1,8 +1,6 @@
1 1
 /* global APP, JitsiMeetJS */
2 2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3 3
 
4
-import RequirePasswordDialog from './RequirePasswordDialog';
5
-
6 4
 /**
7 5
  * Show notification that user cannot set password for the conference
8 6
  * because server doesn't support that.
@@ -33,7 +31,6 @@ const ConferenceErrors = JitsiMeetJS.errors.conference;
33 31
  */
34 32
 export default function createRoomLocker (room) {
35 33
     let password;
36
-    let requirePasswordDialog = new RequirePasswordDialog();
37 34
     /**
38 35
      * If the room was locked from someone other than us, we indicate it with
39 36
      * this property in order to have correct roomLocker state of isLocked.
@@ -102,31 +99,5 @@ export default function createRoomLocker (room) {
102 99
             password = null;
103 100
         },
104 101
 
105
-        /**
106
-         * Asks user for required conference password.
107
-         */
108
-        requirePassword () {
109
-            return requirePasswordDialog.askForPassword().then(
110
-                newPass => { password = newPass; }
111
-            ).catch(
112
-                reason => {
113
-                    // user canceled, no pass was entered.
114
-                    // clear, as if we use the same instance several times
115
-                    // pass stays between attempts
116
-                    password = null;
117
-                    if (reason !== APP.UI.messageHandler.CANCEL)
118
-                        logger.error(reason);
119
-                }
120
-            );
121
-        },
122
-
123
-        /**
124
-         * Hides require password dialog
125
-         */
126
-        hideRequirePasswordDialog() {
127
-            if (requirePasswordDialog.isOpened) {
128
-                requirePasswordDialog.close();
129
-            }
130
-        }
131 102
     };
132 103
 }

+ 1
- 0
package.json 查看文件

@@ -19,6 +19,7 @@
19 19
     "@atlassian/aui": "6.0.6",
20 20
     "@atlaskit/button": "1.0.3",
21 21
     "@atlaskit/button-group": "1.0.0",
22
+    "@atlaskit/field-text": "2.0.3",
22 23
     "@atlaskit/modal-dialog": "1.2.4",
23 24
     "@atlaskit/tabs": "1.2.5",
24 25
     "async": "0.9.0",

+ 2
- 0
react/features/app/components/App.web.js 查看文件

@@ -1,6 +1,8 @@
1 1
 import { appInit } from '../actions';
2 2
 import { AbstractApp } from './AbstractApp';
3 3
 
4
+import '../../room-lock';
5
+
4 6
 /**
5 7
  * Root application component.
6 8
  *

+ 1
- 104
react/features/conference/components/Conference.native.js 查看文件

@@ -6,10 +6,8 @@ import { DialogContainer } from '../../base/dialog';
6 6
 import { Container } from '../../base/react';
7 7
 import { FilmStrip } from '../../film-strip';
8 8
 import { LargeVideo } from '../../large-video';
9
-import { RoomLockPrompt } from '../../room-lock';
10 9
 import { Toolbar } from '../../toolbar';
11 10
 
12
-import PasswordRequiredPrompt from './PasswordRequiredPrompt';
13 11
 import { styles } from './styles';
14 12
 
15 13
 /**
@@ -30,23 +28,6 @@ class Conference extends Component {
30 28
      * @static
31 29
      */
32 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 31
         dispatch: React.PropTypes.func
51 32
     }
52 33
 
@@ -128,9 +109,6 @@ class Conference extends Component {
128 109
 
129 110
                 <DialogContainer />
130 111
 
131
-                {
132
-                    this._renderPrompt()
133
-                }
134 112
             </Container>
135 113
         );
136 114
     }
@@ -164,56 +142,6 @@ class Conference extends Component {
164 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 146
      * Triggers the default toolbar timeout.
219 147
      *
@@ -231,35 +159,4 @@ class Conference extends Component {
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 查看文件

@@ -1,24 +0,0 @@
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');

+ 20
- 11
react/features/room-lock/actions.js 查看文件

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

react/features/conference/components/PasswordRequiredPrompt.native.js → react/features/room-lock/components/PasswordRequiredPrompt.native.js 查看文件

@@ -1,9 +1,8 @@
1 1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3 2
 import { connect } from 'react-redux';
3
+import { Dialog } from '../../base/dialog';
4 4
 
5 5
 import { setPassword } from '../../base/conference';
6
-import { translate } from '../../base/i18n';
7 6
 
8 7
 /**
9 8
  * Implements a React Component which prompts the user when a password is
@@ -22,15 +21,7 @@ class PasswordRequiredPrompt extends Component {
22 21
          * @type {JitsiConference}
23 22
          */
24 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,15 +45,13 @@ class PasswordRequiredPrompt extends Component {
54 45
      * @returns {ReactElement}
55 46
      */
56 47
     render() {
57
-        const { t } = this.props;
58 48
 
59 49
         return (
60
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
61 52
                 onCancel = { this._onCancel }
62 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,14 +59,14 @@ class PasswordRequiredPrompt extends Component {
70 59
      * Notifies this prompt that it has been dismissed by cancel.
71 60
      *
72 61
      * @private
73
-     * @returns {void}
62
+     * @returns {boolean} whether to hide dialog.
74 63
      */
75 64
     _onCancel() {
76 65
         // XXX The user has canceled this prompt for a password so we are to
77 66
         // attempt joining the conference without a password. If the conference
78 67
         // still requires a password to join, the user will be prompted again
79 68
         // later.
80
-        this._onSubmit(undefined);
69
+        return this._onSubmit(undefined);
81 70
     }
82 71
 
83 72
     /**
@@ -86,13 +75,15 @@ class PasswordRequiredPrompt extends Component {
86 75
      *
87 76
      * @param {string} value - The submitted value.
88 77
      * @private
89
-     * @returns {void}
78
+     * @returns {boolean} whether to hide dialog.
90 79
      */
91 80
     _onSubmit(value) {
92 81
         const conference = this.props.conference;
93 82
 
94 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);

+ 127
- 0
react/features/room-lock/components/PasswordRequiredPrompt.web.js 查看文件

@@ -0,0 +1,127 @@
1
+/* global APP */
2
+import React, { Component } from 'react';
3
+import { connect } from 'react-redux';
4
+import AKFieldText from '@atlaskit/field-text';
5
+
6
+import { setPassword } from '../../base/conference';
7
+import { Dialog } from '../../base/dialog';
8
+import { translate } from '../../base/i18n';
9
+
10
+/**
11
+ * Implements a React Component which prompts the user when a password is
12
+ * required to join a conference.
13
+ */
14
+class PasswordRequiredPrompt extends Component {
15
+    /**
16
+     * PasswordRequiredPrompt component's property types.
17
+     *
18
+     * @static
19
+     */
20
+    static propTypes = {
21
+        /**
22
+         * The JitsiConference which requires a password.
23
+         *
24
+         * @type {JitsiConference}
25
+         */
26
+        conference: React.PropTypes.object,
27
+        dispatch: React.PropTypes.func,
28
+        t: React.PropTypes.func
29
+    }
30
+
31
+    /**
32
+     * Initializes a new PasswordRequiredPrompt instance.
33
+     *
34
+     * @param {Object} props - The read-only properties with which the new
35
+     * instance is to be initialized.
36
+     */
37
+    constructor(props) {
38
+        super(props);
39
+
40
+        this.state = { password: '' };
41
+
42
+        this._onPasswordChanged = this._onPasswordChanged.bind(this);
43
+        this._onSubmit = this._onSubmit.bind(this);
44
+    }
45
+
46
+    /**
47
+     * Implements React's {@link Component#render()}.
48
+     *
49
+     * @inheritdoc
50
+     * @returns {ReactElement}
51
+     */
52
+    render() {
53
+        return (
54
+            <Dialog
55
+                isModal = { true }
56
+                onSubmit = { this._onSubmit }
57
+                titleKey = 'dialog.passwordRequired'
58
+                width = 'small'>
59
+                { this._renderBody() }
60
+            </Dialog>);
61
+    }
62
+
63
+    /**
64
+     * Display component in dialog body.
65
+     *
66
+     * @returns {ReactElement}
67
+     * @protected
68
+     */
69
+    _renderBody() {
70
+        const { t } = this.props;
71
+
72
+        return (
73
+            <div>
74
+                <AKFieldText
75
+                    compact = { true }
76
+                    label = { t('dialog.passwordLabel') }
77
+                    name = 'lockKey'
78
+                    onChange = { this._onPasswordChanged }
79
+                    shouldFitContainer = { true }
80
+                    type = 'text'
81
+                    value = { this.state.password } />
82
+            </div>);
83
+    }
84
+
85
+    /**
86
+     * Notifies this dialog that password has changed.
87
+     *
88
+     * @param {Object} event - The details of the notification/event.
89
+     * @private
90
+     * @returns {void}
91
+     */
92
+    _onPasswordChanged(event) {
93
+        this.setState({ password: event.target.value });
94
+    }
95
+
96
+    /**
97
+     * Dispatches action to submit value from thus dialog.
98
+     *
99
+     * @private
100
+     * @returns {void}
101
+     */
102
+    _onSubmit() {
103
+        const conference = this.props.conference;
104
+
105
+        // we received that password is required, but user is trying
106
+        // anyway to login without a password, mark room as not
107
+        // locked in case he succeeds (maybe someone removed the
108
+        // password meanwhile), if it is still locked another
109
+        // password required will be received and the room again
110
+        // will be marked as locked.
111
+        if (!this.state.password || this.state.password === '') {
112
+            // XXX temporary solution till we move the whole invite logic
113
+            // in react
114
+            APP.conference.invite.setLockedFromElsewhere(false);
115
+        }
116
+
117
+        this.props.dispatch(setPassword(
118
+            conference, conference.join, this.state.password));
119
+
120
+        // we have used the password lets clean it
121
+        this.setState({ password: undefined });
122
+
123
+        return true;
124
+    }
125
+}
126
+
127
+export default translate(connect()(PasswordRequiredPrompt));

+ 14
- 21
react/features/room-lock/components/RoomLockPrompt.native.js 查看文件

@@ -1,8 +1,6 @@
1 1
 import React, { Component } from 'react';
2
-import Prompt from 'react-native-prompt';
3 2
 import { connect } from 'react-redux';
4
-
5
-import { translate } from '../../base/i18n';
3
+import { Dialog } from '../../base/dialog';
6 4
 
7 5
 import { endRoomLockRequest } from '../actions';
8 6
 
@@ -23,15 +21,7 @@ class RoomLockPrompt extends Component {
23 21
          * @type {JitsiConference}
24 22
          */
25 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,15 +45,13 @@ class RoomLockPrompt extends Component {
55 45
      * @returns {ReactElement}
56 46
      */
57 47
     render() {
58
-        const { t } = this.props;
59 48
 
60 49
         return (
61
-            <Prompt
50
+            <Dialog
51
+                bodyKey = 'dialog.passwordLabel'
62 52
                 onCancel = { this._onCancel }
63 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,12 +59,12 @@ class RoomLockPrompt extends Component {
71 59
      * Notifies this prompt that it has been dismissed by cancel.
72 60
      *
73 61
      * @private
74
-     * @returns {void}
62
+     * @returns {boolean} whether to hide the dialog
75 63
      */
76 64
     _onCancel() {
77 65
         // An undefined password is understood to cancel the request to lock the
78 66
         // conference/room.
79
-        this._onSubmit(undefined);
67
+        return this._onSubmit(undefined);
80 68
     }
81 69
 
82 70
     /**
@@ -85,11 +73,16 @@ class RoomLockPrompt extends Component {
85 73
      *
86 74
      * @param {string} value - The submitted value.
87 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 80
     _onSubmit(value) {
91 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
- 0
react/features/room-lock/components/RoomLockPrompt.web.js 查看文件


+ 1
- 0
react/features/room-lock/components/index.js 查看文件

@@ -1 +1,2 @@
1 1
 export { default as RoomLockPrompt } from './RoomLockPrompt';
2
+export { default as PasswordRequiredPrompt } from './PasswordRequiredPrompt';

+ 1
- 1
react/features/room-lock/index.js 查看文件

@@ -1,4 +1,4 @@
1 1
 export * from './actions';
2 2
 export * from './components';
3 3
 
4
-import './reducer';
4
+import './middleware';

+ 36
- 0
react/features/room-lock/middleware.js 查看文件

@@ -0,0 +1,36 @@
1
+/* global APP */
2
+import JitsiMeetJS from '../base/lib-jitsi-meet';
3
+
4
+import { CONFERENCE_FAILED } from '../base/conference';
5
+import { MiddlewareRegistry } from '../base/redux';
6
+import { _showPasswordDialog } from './actions';
7
+
8
+/**
9
+ * Middleware that captures conference failed and checks for password required
10
+ * error and requests a dialog for user to enter password.
11
+ *
12
+ * @param {Store} store - Redux store.
13
+ * @returns {Function}
14
+ */
15
+MiddlewareRegistry.register(store => next => action => {
16
+
17
+    switch (action.type) {
18
+    case CONFERENCE_FAILED: {
19
+        const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
20
+
21
+        if (action.conference
22
+            && JitsiConferenceErrors.PASSWORD_REQUIRED === action.error) {
23
+            // XXX temporary solution till we move the whole invite
24
+            // logic in react
25
+            if (typeof APP !== 'undefined') {
26
+                APP.conference.invite.setLockedFromElsewhere(true);
27
+            }
28
+
29
+            store.dispatch(_showPasswordDialog(action.conference));
30
+        }
31
+        break;
32
+    }
33
+    }
34
+
35
+    return next(action);
36
+});

+ 0
- 33
react/features/room-lock/reducer.js 查看文件

@@ -1,33 +0,0 @@
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
-});

+ 0
- 5
service/UI/UIEvents.js 查看文件

@@ -150,11 +150,6 @@ export default {
150 150
      */
151 151
     DISPLAY_NAME_CHANGED: "UI.display_name_changed",
152 152
 
153
-    /**
154
-     * Indicates that a password is required for the call.
155
-     */
156
-    PASSWORD_REQUIRED: "UI.password_required",
157
-
158 153
     /**
159 154
      * Show custom popup/tooltip for a specified button.
160 155
      */

Loading…
取消
儲存