Browse Source

etherpad: refactor to share code with mobile

- simplify initialization procedure
- set user display name as the Etherpad name\
- use SharedDocumentButton
master
Saúl Ibarra Corretgé 5 years ago
parent
commit
98698ba89a

+ 6
- 4
modules/UI/UI.js View File

15
 
15
 
16
 import { getLocalParticipant } from '../../react/features/base/participants';
16
 import { getLocalParticipant } from '../../react/features/base/participants';
17
 import { toggleChat } from '../../react/features/chat';
17
 import { toggleChat } from '../../react/features/chat';
18
-import { setEtherpadHasInitialzied } from '../../react/features/etherpad';
18
+import { setDocumentUrl } from '../../react/features/etherpad';
19
 import { setFilmstripVisible } from '../../react/features/filmstrip';
19
 import { setFilmstripVisible } from '../../react/features/filmstrip';
20
 import { setNotificationsEnabled } from '../../react/features/notifications';
20
 import { setNotificationsEnabled } from '../../react/features/notifications';
21
 import {
21
 import {
240
         return;
240
         return;
241
     }
241
     }
242
     logger.log('Etherpad is enabled');
242
     logger.log('Etherpad is enabled');
243
-    etherpadManager
244
-        = new EtherpadManager(config.etherpad_base, name, eventEmitter);
245
 
243
 
246
-    APP.store.dispatch(setEtherpadHasInitialzied());
244
+    etherpadManager = new EtherpadManager(eventEmitter);
245
+
246
+    const url = new URL(name, config.etherpad_base);
247
+
248
+    APP.store.dispatch(setDocumentUrl(url.toString()));
247
 };
249
 };
248
 
250
 
249
 /**
251
 /**

+ 5
- 21
modules/UI/etherpad/Etherpad.js View File

1
 /* global $, APP, interfaceConfig */
1
 /* global $, APP, interfaceConfig */
2
 
2
 
3
-import { setDocumentEditingState } from '../../../react/features/etherpad';
3
+import { getSharedDocumentUrl, setDocumentEditingState } from '../../../react/features/etherpad';
4
 import { getToolboxHeight } from '../../../react/features/toolbox';
4
 import { getToolboxHeight } from '../../../react/features/toolbox';
5
 
5
 
6
 import VideoLayout from '../videolayout/VideoLayout';
6
 import VideoLayout from '../videolayout/VideoLayout';
7
 import LargeContainer from '../videolayout/LargeContainer';
7
 import LargeContainer from '../videolayout/LargeContainer';
8
 import Filmstrip from '../videolayout/Filmstrip';
8
 import Filmstrip from '../videolayout/Filmstrip';
9
 
9
 
10
-/**
11
- * Etherpad options.
12
- */
13
-const options = $.param({
14
-    showControls: true,
15
-    showChat: false,
16
-    showLineNumbers: true,
17
-    useMonospaceFont: false
18
-});
19
-
20
 /**
10
 /**
21
  *
11
  *
22
  */
12
  */
70
     /**
60
     /**
71
      * Creates new Etherpad object
61
      * Creates new Etherpad object
72
      */
62
      */
73
-    constructor(domain, name) {
63
+    constructor(url) {
74
         super();
64
         super();
75
 
65
 
76
         const iframe = document.createElement('iframe');
66
         const iframe = document.createElement('iframe');
77
 
67
 
78
         iframe.id = 'etherpadIFrame';
68
         iframe.id = 'etherpadIFrame';
79
-        iframe.src = `${domain + name}?${options}`;
69
+        iframe.src = url;
80
         iframe.frameBorder = 0;
70
         iframe.frameBorder = 0;
81
         iframe.scrolling = 'no';
71
         iframe.scrolling = 'no';
82
         iframe.width = DEFAULT_WIDTH;
72
         iframe.width = DEFAULT_WIDTH;
199
     /**
189
     /**
200
      *
190
      *
201
      */
191
      */
202
-    constructor(domain, name, eventEmitter) {
203
-        if (!domain || !name) {
204
-            throw new Error('missing domain or name');
205
-        }
206
-
207
-        this.domain = domain;
208
-        this.name = name;
192
+    constructor(eventEmitter) {
209
         this.eventEmitter = eventEmitter;
193
         this.eventEmitter = eventEmitter;
210
         this.etherpad = null;
194
         this.etherpad = null;
211
     }
195
     }
228
      * Create new Etherpad frame.
212
      * Create new Etherpad frame.
229
      */
213
      */
230
     openEtherpad() {
214
     openEtherpad() {
231
-        this.etherpad = new Etherpad(this.domain, this.name);
215
+        this.etherpad = new Etherpad(getSharedDocumentUrl(APP.store.getState));
232
         VideoLayout.addLargeVideoContainer(
216
         VideoLayout.addLargeVideoContainer(
233
             ETHERPAD_CONTAINER_TYPE,
217
             ETHERPAD_CONTAINER_TYPE,
234
             this.etherpad
218
             this.etherpad

+ 0
- 10
react/features/etherpad/actionTypes.js View File

1
-/**
2
- * The type of the action which signals document editing has been enabled.
3
- *
4
- * {
5
- *     type: ETHERPAD_INITIALIZED
6
- * }
7
- */
8
-export const ETHERPAD_INITIALIZED = 'ETHERPAD_INITIALIZED';
9
-
10
-
11
 /**
1
 /**
12
  * The type of the action which signals document editing has stopped or started.
2
  * The type of the action which signals document editing has stopped or started.
13
  *
3
  *

+ 0
- 14
react/features/etherpad/actions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import {
3
 import {
4
-    ETHERPAD_INITIALIZED,
5
     SET_DOCUMENT_EDITING_STATUS,
4
     SET_DOCUMENT_EDITING_STATUS,
6
     SET_DOCUMENT_URL,
5
     SET_DOCUMENT_URL,
7
     TOGGLE_DOCUMENT_EDITING
6
     TOGGLE_DOCUMENT_EDITING
40
     };
39
     };
41
 }
40
 }
42
 
41
 
43
-/**
44
- * Dispatches an action to set Etherpad as having been initialized.
45
- *
46
- * @returns {{
47
- *    type: ETHERPAD_INITIALIZED
48
- * }}
49
- */
50
-export function setEtherpadHasInitialzied() {
51
-    return {
52
-        type: ETHERPAD_INITIALIZED
53
-    };
54
-}
55
-
56
 /**
42
 /**
57
  * Dispatches an action to show or hide Etherpad.
43
  * Dispatches an action to show or hide Etherpad.
58
  *
44
  *

+ 2
- 20
react/features/etherpad/reducer.js View File

2
 
2
 
3
 import { ReducerRegistry } from '../base/redux';
3
 import { ReducerRegistry } from '../base/redux';
4
 
4
 
5
-import {
6
-    ETHERPAD_INITIALIZED,
7
-    SET_DOCUMENT_EDITING_STATUS,
8
-    SET_DOCUMENT_URL
9
-} from './actionTypes';
5
+import { SET_DOCUMENT_EDITING_STATUS, SET_DOCUMENT_URL } from './actionTypes';
10
 
6
 
11
 const DEFAULT_STATE = {
7
 const DEFAULT_STATE = {
12
 
8
 
21
      * @public
17
      * @public
22
      * @type {boolean}
18
      * @type {boolean}
23
      */
19
      */
24
-    editing: false,
25
-
26
-    /**
27
-     * Whether or not Etherpad is ready to use.
28
-     *
29
-     * @public
30
-     * @type {boolean}
31
-     */
32
-    initialized: false
20
+    editing: false
33
 };
21
 };
34
 
22
 
35
 /**
23
 /**
39
     'features/etherpad',
27
     'features/etherpad',
40
     (state = DEFAULT_STATE, action) => {
28
     (state = DEFAULT_STATE, action) => {
41
         switch (action.type) {
29
         switch (action.type) {
42
-        case ETHERPAD_INITIALIZED:
43
-            return {
44
-                ...state,
45
-                initialized: true
46
-            };
47
-
48
         case SET_DOCUMENT_EDITING_STATUS:
30
         case SET_DOCUMENT_EDITING_STATUS:
49
             return {
31
             return {
50
                 ...state,
32
                 ...state,

+ 3
- 56
react/features/toolbox/components/web/Toolbox.js View File

21
     IconRaisedHand,
21
     IconRaisedHand,
22
     IconRec,
22
     IconRec,
23
     IconShareDesktop,
23
     IconShareDesktop,
24
-    IconShareDoc,
25
     IconShareVideo
24
     IconShareVideo
26
 } from '../../../base/icons';
25
 } from '../../../base/icons';
27
 import {
26
 import {
34
 import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
33
 import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
35
 import { VideoBlurButton } from '../../../blur';
34
 import { VideoBlurButton } from '../../../blur';
36
 import { ChatCounter, toggleChat } from '../../../chat';
35
 import { ChatCounter, toggleChat } from '../../../chat';
37
-import { toggleDocument } from '../../../etherpad';
36
+import { SharedDocumentButton } from '../../../etherpad';
38
 import { openFeedbackDialog } from '../../../feedback';
37
 import { openFeedbackDialog } from '../../../feedback';
39
 import {
38
 import {
40
     beginAddPeople,
39
     beginAddPeople,
111
      */
110
      */
112
     _dialog: boolean,
111
     _dialog: boolean,
113
 
112
 
114
-    /**
115
-     * Whether or not the local participant is currently editing a document.
116
-     */
117
-    _editingDocument: boolean,
118
-
119
-    /**
120
-     * Whether or not collaborative document editing is enabled.
121
-     */
122
-    _etherpadInitialized: boolean,
123
-
124
     /**
113
     /**
125
      * Whether or not call feedback can be sent.
114
      * Whether or not call feedback can be sent.
126
      */
115
      */
247
         this._onToolbarOpenVideoQuality
236
         this._onToolbarOpenVideoQuality
248
             = this._onToolbarOpenVideoQuality.bind(this);
237
             = this._onToolbarOpenVideoQuality.bind(this);
249
         this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
238
         this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
250
-        this._onToolbarToggleEtherpad
251
-            = this._onToolbarToggleEtherpad.bind(this);
252
         this._onToolbarToggleFullScreen
239
         this._onToolbarToggleFullScreen
253
             = this._onToolbarToggleFullScreen.bind(this);
240
             = this._onToolbarToggleFullScreen.bind(this);
254
         this._onToolbarToggleProfile
241
         this._onToolbarToggleProfile
424
         this.props.dispatch(toggleChat());
411
         this.props.dispatch(toggleChat());
425
     }
412
     }
426
 
413
 
427
-    /**
428
-     * Dispatches an action to show or hide document editing.
429
-     *
430
-     * @private
431
-     * @returns {void}
432
-     */
433
-    _doToggleEtherpad() {
434
-        this.props.dispatch(toggleDocument());
435
-    }
436
-
437
     /**
414
     /**
438
      * Dispatches an action to toggle screensharing.
415
      * Dispatches an action to toggle screensharing.
439
      *
416
      *
749
         this._doToggleChat();
726
         this._doToggleChat();
750
     }
727
     }
751
 
728
 
752
-    _onToolbarToggleEtherpad: () => void;
753
-
754
-    /**
755
-     * Creates an analytics toolbar event and dispatches an action for toggling
756
-     * the display of document editing.
757
-     *
758
-     * @private
759
-     * @returns {void}
760
-     */
761
-    _onToolbarToggleEtherpad() {
762
-        sendAnalytics(createToolbarEvent(
763
-            'toggle.etherpad',
764
-            {
765
-                enable: !this.props._editingDocument
766
-            }));
767
-
768
-        this._doToggleEtherpad();
769
-    }
770
-
771
     _onToolbarToggleFullScreen: () => void;
729
     _onToolbarToggleFullScreen: () => void;
772
 
730
 
773
     /**
731
     /**
960
      */
918
      */
961
     _renderOverflowMenuContent() {
919
     _renderOverflowMenuContent() {
962
         const {
920
         const {
963
-            _editingDocument,
964
-            _etherpadInitialized,
965
             _feedbackConfigured,
921
             _feedbackConfigured,
966
             _fullScreen,
922
             _fullScreen,
967
             _screensharing,
923
             _screensharing,
1007
                         ? t('toolbar.stopSharedVideo')
963
                         ? t('toolbar.stopSharedVideo')
1008
                         : t('toolbar.sharedvideo') } />,
964
                         : t('toolbar.sharedvideo') } />,
1009
             this._shouldShowButton('etherpad')
965
             this._shouldShowButton('etherpad')
1010
-                && _etherpadInitialized
1011
-                && <OverflowMenuItem
1012
-                    accessibilityLabel =
1013
-                        { t('toolbar.accessibilityLabel.document') }
1014
-                    icon = { IconShareDoc }
966
+                && <SharedDocumentButton
1015
                     key = 'etherpad'
967
                     key = 'etherpad'
1016
-                    onClick = { this._onToolbarToggleEtherpad }
1017
-                    text = { _editingDocument
1018
-                        ? t('toolbar.documentClose')
1019
-                        : t('toolbar.documentOpen') } />,
968
+                    showLabel = { true } />,
1020
             <VideoBlurButton
969
             <VideoBlurButton
1021
                 key = 'videobackgroundblur'
970
                 key = 'videobackgroundblur'
1022
                 showLabel = { true }
971
                 showLabel = { true }
1365
         _desktopSharingEnabled: desktopSharingEnabled,
1314
         _desktopSharingEnabled: desktopSharingEnabled,
1366
         _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
1315
         _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
1367
         _dialog: Boolean(state['features/base/dialog'].component),
1316
         _dialog: Boolean(state['features/base/dialog'].component),
1368
-        _editingDocument: Boolean(state['features/etherpad'].editing),
1369
-        _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
1370
         _feedbackConfigured: Boolean(callStatsID),
1317
         _feedbackConfigured: Boolean(callStatsID),
1371
         _hideInviteButton:
1318
         _hideInviteButton:
1372
             iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),
1319
             iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),

Loading…
Cancel
Save