Parcourir la source

fix(dropbox): Address code review comments.

j8
hristoterezov il y a 6 ans
Parent
révision
2704b2f822

+ 8
- 4
css/_recording.scss Voir le fichier

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

+ 3
- 2
lang/main.json Voir le fichier

@@ -456,10 +456,11 @@
456 456
         "on": "Recording",
457 457
         "pending": "Preparing to record the meeting...",
458 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 461
         "serviceName": "Recording service",
462 462
         "signOut": "Sign Out",
463
+        "signIn": "sign in",
463 464
         "loggedIn": "Logged in as __userName__",
464 465
         "availableSpace": "Available space: __spaceLeft__ MB (approximately __duration__ minutes of recording)",
465 466
         "startRecordingBody": "Are you sure you would like to start recording?",

+ 0
- 29
react/features/base/oauth/functions.js Voir le fichier

@@ -1,29 +0,0 @@
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 Voir le fichier

@@ -1,38 +0,0 @@
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 Voir le fichier


react/features/base/oauth/actions.js → react/features/dropbox/actions.js Voir le fichier

@@ -2,12 +2,40 @@
2 2
 
3 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 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 40
  * Action to authorize the Jitsi Recording app in dropbox.
13 41
  *

+ 39
- 0
react/features/dropbox/functions.js Voir le fichier

@@ -0,0 +1,39 @@
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 Voir le fichier

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

+ 28
- 0
react/features/dropbox/reducer.js Voir le fichier

@@ -0,0 +1,28 @@
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 Voir le fichier

@@ -11,7 +11,7 @@ import { Dialog } from '../../../base/dialog';
11 11
 import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';
12 12
 
13 13
 import StartRecordingDialogContent from './StartRecordingDialogContent';
14
-import { getDropboxData } from '../../functions';
14
+import { getDropboxData } from '../../../dropbox';
15 15
 
16 16
 type Props = {
17 17
 
@@ -41,7 +41,6 @@ type Props = {
41 41
     t: Function
42 42
 }
43 43
 
44
-
45 44
 type State = {
46 45
 
47 46
     /**
@@ -55,14 +54,14 @@ type State = {
55 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,14 +216,16 @@ class StartRecordingDialog extends Component<Props, State> {
217 216
  * @param {Object} state - The Redux state.
218 217
  * @private
219 218
  * @returns {{
220
- *     _conference: JitsiConference
219
+ *     _clientId: string,
220
+ *     _conference: JitsiConference,
221
+ *     _token: string
221 222
  * }}
222 223
  */
223 224
 function mapStateToProps(state: Object) {
224 225
     return {
226
+        _clientId: state['features/base/config'].dropbox.clientId,
225 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 Voir le fichier

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

+ 0
- 38
react/features/recording/functions.js Voir le fichier

@@ -1,11 +1,7 @@
1 1
 // @flow
2 2
 
3
-import { Dropbox } from 'dropbox';
4
-
5 3
 import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
6 4
 
7
-const logger = require('jitsi-meet-logger').getLogger(__filename);
8
-
9 5
 /**
10 6
  * Searches in the passed in redux state for an active recording session of the
11 7
  * passed in mode.
@@ -35,37 +31,3 @@ export function getSessionById(state: Object, id: string) {
35 31
     return state['features/recording'].sessionDatas.find(
36 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 Voir le fichier

@@ -6,30 +6,22 @@
6 6
     <!--#include virtual="/base.html" -->
7 7
     <!--#include virtual="/title.html" -->
8 8
     <script>
9
-        function getParentWindowCallback() {
9
+        (function() {
10 10
             var windowName = window.name;
11 11
             var parentWindow = window.opener;
12 12
             if (parentWindow
13 13
                 && parentWindow.JitsiMeetJS
14 14
                 && parentWindow.JitsiMeetJS.app) {
15 15
                 var globalNS = parentWindow.JitsiMeetJS.app;
16
-                if( globalNS.oauthCallbacks
16
+                if (globalNS.oauthCallbacks
17 17
                     && typeof globalNS.oauthCallbacks[windowName]
18 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 23
     </script>
33 24
 </head>
34
-<body />
25
+<body>
26
+</body>
35 27
 </html>

Chargement…
Annuler
Enregistrer