Pārlūkot izejas kodu

fix(dropbox): Address code review comments.

j8
hristoterezov 6 gadus atpakaļ
vecāks
revīzija
2704b2f822

+ 8
- 4
css/_recording.scss Parādīt failu

4
 
4
 
5
 .recording-dialog {
5
 .recording-dialog {
6
     .authorization-panel {
6
     .authorization-panel {
7
-        align-items: center;
8
         border-bottom: 2px solid rgba(0, 0, 0, 0.3);
7
         border-bottom: 2px solid rgba(0, 0, 0, 0.3);
9
         display: flex;
8
         display: flex;
10
         flex-direction: column;
9
         flex-direction: column;
12
         padding-bottom: 10px;
11
         padding-bottom: 10px;
13
 
12
 
14
         .dropbox-sign-in {
13
         .dropbox-sign-in {
15
-            background-color: #4285f4;
14
+            align-items: center;
15
+            border: 1px solid #4285f4;
16
+            background-color: white;
16
             border-radius: 2px;
17
             border-radius: 2px;
17
             cursor: pointer;
18
             cursor: pointer;
18
             display: inline-flex;
19
             display: inline-flex;
19
-            padding: 1px;
20
+            padding: 10px;
21
+            font-size: 18px;
22
+            font-weight: 600;
20
             margin: 10px 0px;
23
             margin: 10px 0px;
24
+            color: #4285f4;
21
 
25
 
22
             .dropbox-logo {
26
             .dropbox-logo {
23
                 background-color: white;
27
                 background-color: white;
24
                 border-radius: 2px;
28
                 border-radius: 2px;
25
                 display: inline-block;
29
                 display: inline-block;
26
-                padding: 8px;
30
+                padding-right: 5px;
27
                 height: 18px;
31
                 height: 18px;
28
             }
32
             }
29
         }
33
         }

+ 3
- 2
lang/main.json Parādīt failu

456
         "on": "Recording",
456
         "on": "Recording",
457
         "pending": "Preparing to record the meeting...",
457
         "pending": "Preparing to record the meeting...",
458
         "rec": "REC",
458
         "rec": "REC",
459
-        "authDropboxText": "To start the recording you need to first authorize our Dropbox recording app. After the recording is finished the file will be uploaded to your Dropbox account.",
460
-        "authDropboxCompletedText": "Our Dropbox app has been authorized successfully. You should see the recorded file in your Dropbox account shortly after the recording has finished.",
459
+        "authDropboxText": "Upload your recording to Dropbox.",
460
+        "authDropboxCompletedText": "Your recording file will appear in your Dropbox shortly after the recording has finished.",
461
         "serviceName": "Recording service",
461
         "serviceName": "Recording service",
462
         "signOut": "Sign Out",
462
         "signOut": "Sign Out",
463
+        "signIn": "sign in",
463
         "loggedIn": "Logged in as __userName__",
464
         "loggedIn": "Logged in as __userName__",
464
         "availableSpace": "Available space: __spaceLeft__ MB (approximately __duration__ minutes of recording)",
465
         "availableSpace": "Available space: __spaceLeft__ MB (approximately __duration__ minutes of recording)",
465
         "startRecordingBody": "Are you sure you would like to start recording?",
466
         "startRecordingBody": "Are you sure you would like to start recording?",

+ 0
- 29
react/features/base/oauth/functions.js Parādīt failu

1
-// @flow
2
-
3
-import { getJitsiMeetGlobalNS } from '../util';
4
-
5
-
6
-/**
7
- * Executes the oauth flow.
8
- *
9
- * @param {string} authUrl - The URL to oauth service.
10
- * @returns {Promise<string>} - The URL with the authorization details.
11
- */
12
-export function authorize(authUrl: string): Promise<string> {
13
-    const windowName = `oauth${Date.now()}`;
14
-    const gloabalNS = getJitsiMeetGlobalNS();
15
-
16
-    gloabalNS.oauthCallbacks = gloabalNS.oauthCallbacks || {};
17
-
18
-    return new Promise(resolve => {
19
-        const popup = window.open(authUrl, windowName);
20
-
21
-        gloabalNS.oauthCallbacks[windowName] = () => {
22
-            const returnURL = popup.location.href;
23
-
24
-            popup.close();
25
-            delete gloabalNS.oauthCallbacks.windowName;
26
-            resolve(returnURL);
27
-        };
28
-    });
29
-}

+ 0
- 38
react/features/base/oauth/reducer.js Parādīt failu

1
-// @flow
2
-
3
-import { ReducerRegistry } from '../redux';
4
-import { PersistenceRegistry } from '../storage';
5
-
6
-import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
7
-
8
-/**
9
- * The default state.
10
- */
11
-const DEFAULT_STATE = {
12
-    dropbox: {}
13
-};
14
-
15
-/**
16
- * The redux subtree of this feature.
17
- */
18
-const STORE_NAME = 'features/base/oauth';
19
-
20
-/**
21
- * Sets up the persistence of the feature {@code oauth}.
22
- */
23
-PersistenceRegistry.register(STORE_NAME);
24
-
25
-ReducerRegistry.register('features/base/oauth',
26
-(state = DEFAULT_STATE, action) => {
27
-    switch (action.type) {
28
-    case UPDATE_DROPBOX_TOKEN:
29
-        return {
30
-            ...state,
31
-            dropbox: {
32
-                token: action.token
33
-            }
34
-        };
35
-    default:
36
-        return state;
37
-    }
38
-});

react/features/base/oauth/actionTypes.js → react/features/dropbox/actionTypes.js Parādīt failu


react/features/base/oauth/actions.js → react/features/dropbox/actions.js Parādīt failu

2
 
2
 
3
 import { Dropbox } from 'dropbox';
3
 import { Dropbox } from 'dropbox';
4
 
4
 
5
-import { getLocationContextRoot, parseStandardURIString } from '../util';
6
-import { parseURLParams } from '../config';
5
+import {
6
+    getJitsiMeetGlobalNS,
7
+    getLocationContextRoot,
8
+    parseStandardURIString
9
+} from '../base/util';
10
+import { parseURLParams } from '../base/config';
7
 
11
 
8
-import { authorize } from './functions';
9
 import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
12
 import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
10
 
13
 
14
+/**
15
+ * Executes the oauth flow.
16
+ *
17
+ * @param {string} authUrl - The URL to oauth service.
18
+ * @returns {Promise<string>} - The URL with the authorization details.
19
+ */
20
+function authorize(authUrl: string): Promise<string> {
21
+    const windowName = `oauth${Date.now()}`;
22
+    const gloabalNS = getJitsiMeetGlobalNS();
23
+
24
+    gloabalNS.oauthCallbacks = gloabalNS.oauthCallbacks || {};
25
+
26
+    return new Promise(resolve => {
27
+        const popup = window.open(authUrl, windowName);
28
+
29
+        gloabalNS.oauthCallbacks[windowName] = () => {
30
+            const returnURL = popup.location.href;
31
+
32
+            popup.close();
33
+            delete gloabalNS.oauthCallbacks.windowName;
34
+            resolve(returnURL);
35
+        };
36
+    });
37
+}
38
+
11
 /**
39
 /**
12
  * Action to authorize the Jitsi Recording app in dropbox.
40
  * Action to authorize the Jitsi Recording app in dropbox.
13
  *
41
  *

+ 39
- 0
react/features/dropbox/functions.js Parādīt failu

1
+// @flow
2
+
3
+import { Dropbox } from 'dropbox';
4
+
5
+const logger = require('jitsi-meet-logger').getLogger(__filename);
6
+
7
+/**
8
+ * Fetches information about the user's dropbox account.
9
+ *
10
+ * @param {string} token - The dropbox access token.
11
+ * @param {string} clientId - The Jitsi Recorder dropbox app ID.
12
+ * @returns {Promise<Object|undefined>}
13
+ */
14
+export function getDropboxData(
15
+        token: string,
16
+        clientId: string
17
+): Promise<?Object> {
18
+    const dropboxAPI = new Dropbox({
19
+        accessToken: token,
20
+        clientId
21
+    });
22
+
23
+    return Promise.all(
24
+        [ dropboxAPI.usersGetCurrentAccount(), dropboxAPI.usersGetSpaceUsage() ]
25
+    ).then(([ account, space ]) => {
26
+        const { allocation, used } = space;
27
+        const { allocated } = allocation;
28
+
29
+        return {
30
+            userName: account.name.display_name,
31
+            spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
32
+        };
33
+
34
+    }, error => {
35
+        logger.error(error);
36
+
37
+        return undefined;
38
+    });
39
+}

react/features/base/oauth/index.js → react/features/dropbox/index.js Parādīt failu

1
 export * from './actions';
1
 export * from './actions';
2
+export * from './functions';
2
 
3
 
3
 import './reducer';
4
 import './reducer';

+ 28
- 0
react/features/dropbox/reducer.js Parādīt failu

1
+// @flow
2
+
3
+import { ReducerRegistry } from '../base/redux';
4
+import { PersistenceRegistry } from '../base/storage';
5
+
6
+import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
7
+
8
+/**
9
+ * The redux subtree of this feature.
10
+ */
11
+const STORE_NAME = 'features/dropbox';
12
+
13
+/**
14
+ * Sets up the persistence of the feature {@code dropbox}.
15
+ */
16
+PersistenceRegistry.register(STORE_NAME);
17
+
18
+ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
19
+    switch (action.type) {
20
+    case UPDATE_DROPBOX_TOKEN:
21
+        return {
22
+            ...state,
23
+            token: action.token
24
+        };
25
+    default:
26
+        return state;
27
+    }
28
+});

+ 10
- 9
react/features/recording/components/Recording/StartRecordingDialog.js Parādīt failu

11
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
11
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
12
 
12
 
13
 import StartRecordingDialogContent from './StartRecordingDialogContent';
13
 import StartRecordingDialogContent from './StartRecordingDialogContent';
14
-import { getDropboxData } from '../../functions';
14
+import { getDropboxData } from '../../../dropbox';
15
 
15
 
16
 type Props = {
16
 type Props = {
17
 
17
 
41
     t: Function
41
     t: Function
42
 }
42
 }
43
 
43
 
44
-
45
 type State = {
44
 type State = {
46
 
45
 
47
     /**
46
     /**
55
     isValidating: boolean,
54
     isValidating: boolean,
56
 
55
 
57
     /**
56
     /**
58
-     * The display name of the user's Dropbox account.
57
+     * Number of MiB of available space in user's Dropbox account.
59
      */
58
      */
60
-    userName: ?string,
59
+    spaceLeft: ?number,
61
 
60
 
62
     /**
61
     /**
63
-     * Number of MiB of available space in user's Dropbox account.
62
+     * The display name of the user's Dropbox account.
64
      */
63
      */
65
-    spaceLeft: ?number
64
+    userName: ?string
66
 };
65
 };
67
 
66
 
68
 /**
67
 /**
217
  * @param {Object} state - The Redux state.
216
  * @param {Object} state - The Redux state.
218
  * @private
217
  * @private
219
  * @returns {{
218
  * @returns {{
220
- *     _conference: JitsiConference
219
+ *     _clientId: string,
220
+ *     _conference: JitsiConference,
221
+ *     _token: string
221
  * }}
222
  * }}
222
  */
223
  */
223
 function mapStateToProps(state: Object) {
224
 function mapStateToProps(state: Object) {
224
     return {
225
     return {
226
+        _clientId: state['features/base/config'].dropbox.clientId,
225
         _conference: state['features/base/conference'].conference,
227
         _conference: state['features/base/conference'].conference,
226
-        _token: state['features/base/oauth'].dropbox.token,
227
-        _clientId: state['features/base/config'].dropbox.clientId
228
+        _token: state['features/dropbox'].token
228
     };
229
     };
229
 }
230
 }
230
 
231
 

+ 10
- 5
react/features/recording/components/Recording/StartRecordingDialogContent.web.js Parādīt failu

9
     sendAnalytics
9
     sendAnalytics
10
 } from '../../../analytics';
10
 } from '../../../analytics';
11
 import { translate } from '../../../base/i18n';
11
 import { translate } from '../../../base/i18n';
12
-import { authorizeDropbox, updateDropboxToken } from '../../../base/oauth';
12
+import { authorizeDropbox, updateDropboxToken } from '../../../dropbox';
13
 
13
 
14
 type Props = {
14
 type Props = {
15
 
15
 
111
      * @returns {React$Component}
111
      * @returns {React$Component}
112
      */
112
      */
113
     _renderSignIn() {
113
     _renderSignIn() {
114
+        const { t } = this.props;
115
+
114
         return (
116
         return (
115
             <div>
117
             <div>
116
-                <div>{ this.props.t('recording.authDropboxText') }</div>
118
+                <div>{ t('recording.authDropboxText') }</div>
117
                 <div
119
                 <div
118
                     className = 'dropbox-sign-in'
120
                     className = 'dropbox-sign-in'
119
                     onClick = { this._onSignInClick }>
121
                     onClick = { this._onSignInClick }>
120
                     <img
122
                     <img
121
                         className = 'dropbox-logo'
123
                         className = 'dropbox-logo'
122
                         src = 'images/dropboxLogo.svg' />
124
                         src = 'images/dropboxLogo.svg' />
125
+                    <span>{ t('recording.signIn') }</span>
123
                 </div>
126
                 </div>
124
-            </div>);
127
+            </div>
128
+        );
125
     }
129
     }
126
 
130
 
127
     /**
131
     /**
135
         return (
139
         return (
136
             <div>
140
             <div>
137
                 <div>{ t('recording.authDropboxCompletedText') }</div>
141
                 <div>{ t('recording.authDropboxCompletedText') }</div>
138
-                <div className = 'logged-in-pannel'>
142
+                <div className = 'logged-in-panel'>
139
                     <div>
143
                     <div>
140
                         { t('recording.loggedIn', { userName }) }&nbsp;(&nbsp;
144
                         { t('recording.loggedIn', { userName }) }&nbsp;(&nbsp;
141
                         <a onClick = { this._onSignOutClick }>
145
                         <a onClick = { this._onSignOutClick }>
154
                         }
158
                         }
155
                     </div>
159
                     </div>
156
                 </div>
160
                 </div>
157
-            </div>);
161
+            </div>
162
+        );
158
     }
163
     }
159
 
164
 
160
     _onSignInClick: () => {};
165
     _onSignInClick: () => {};

+ 0
- 38
react/features/recording/functions.js Parādīt failu

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { Dropbox } from 'dropbox';
4
-
5
 import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
3
 import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
6
 
4
 
7
-const logger = require('jitsi-meet-logger').getLogger(__filename);
8
-
9
 /**
5
 /**
10
  * Searches in the passed in redux state for an active recording session of the
6
  * Searches in the passed in redux state for an active recording session of the
11
  * passed in mode.
7
  * passed in mode.
35
     return state['features/recording'].sessionDatas.find(
31
     return state['features/recording'].sessionDatas.find(
36
         sessionData => sessionData.id === id);
32
         sessionData => sessionData.id === id);
37
 }
33
 }
38
-
39
-/**
40
- * Fetches information about the user's dropbox account.
41
- *
42
- * @param {string} token - The dropbox access token.
43
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
44
- * @returns {Promise<Object|undefined>}
45
- */
46
-export function getDropboxData(
47
-        token: string,
48
-        clientId: string
49
-): Promise<?Object> {
50
-    const dropboxAPI = new Dropbox({
51
-        accessToken: token,
52
-        clientId
53
-    });
54
-
55
-    return Promise.all(
56
-        [ dropboxAPI.usersGetCurrentAccount(), dropboxAPI.usersGetSpaceUsage() ]
57
-    ).then(([ account, space ]) => {
58
-        const { allocation, used } = space;
59
-        const { allocated } = allocation;
60
-
61
-        return {
62
-            userName: account.name.display_name,
63
-            spaceLeft: Math.floor((allocated - used) / 1048576)// 1MiB=1048576B
64
-        };
65
-
66
-    }, error => {
67
-        logger.error(error);
68
-
69
-        return undefined;
70
-    });
71
-}

+ 6
- 14
static/oauth.html Parādīt failu

6
     <!--#include virtual="/base.html" -->
6
     <!--#include virtual="/base.html" -->
7
     <!--#include virtual="/title.html" -->
7
     <!--#include virtual="/title.html" -->
8
     <script>
8
     <script>
9
-        function getParentWindowCallback() {
9
+        (function() {
10
             var windowName = window.name;
10
             var windowName = window.name;
11
             var parentWindow = window.opener;
11
             var parentWindow = window.opener;
12
             if (parentWindow
12
             if (parentWindow
13
                 && parentWindow.JitsiMeetJS
13
                 && parentWindow.JitsiMeetJS
14
                 && parentWindow.JitsiMeetJS.app) {
14
                 && parentWindow.JitsiMeetJS.app) {
15
                 var globalNS = parentWindow.JitsiMeetJS.app;
15
                 var globalNS = parentWindow.JitsiMeetJS.app;
16
-                if( globalNS.oauthCallbacks
16
+                if (globalNS.oauthCallbacks
17
                     && typeof globalNS.oauthCallbacks[windowName]
17
                     && typeof globalNS.oauthCallbacks[windowName]
18
                         === 'function') {
18
                         === 'function') {
19
-                    return globalNS.oauthCallbacks[windowName];
19
+                    globalNS.oauthCallbacks[windowName]();
20
                 }
20
                 }
21
             }
21
             }
22
-
23
-            return undefined;
24
-        }
25
-
26
-        var callback = getParentWindowCallback();
27
-        if (typeof callback === 'function') {
28
-            callback();
29
-        } else {
30
-            alert('Something went wrong!');
31
-        }
22
+        })();
32
     </script>
23
     </script>
33
 </head>
24
 </head>
34
-<body />
25
+<body>
26
+</body>
35
 </html>
27
 </html>

Notiek ielāde…
Atcelt
Saglabāt