|
@@ -1,10 +1,13 @@
|
1
|
|
-// @flow
|
2
|
|
-
|
3
|
1
|
import Spinner from '@atlaskit/spinner';
|
|
2
|
+import { Theme } from '@mui/material';
|
|
3
|
+import { withStyles } from '@mui/styles';
|
4
|
4
|
import React, { Component } from 'react';
|
|
5
|
+import { WithTranslation } from 'react-i18next';
|
|
6
|
+import { connect } from 'react-redux';
|
5
|
7
|
|
6
|
|
-import { translate } from '../../../base/i18n';
|
7
|
|
-import { connect } from '../../../base/redux';
|
|
8
|
+import { IReduxState } from '../../../app/types';
|
|
9
|
+import { translate } from '../../../base/i18n/functions';
|
|
10
|
+import { withPixelLineHeight } from '../../../base/styles/functions.web';
|
8
|
11
|
import Button from '../../../base/ui/components/web/Button';
|
9
|
12
|
import {
|
10
|
13
|
CALENDAR_TYPE,
|
|
@@ -13,62 +16,84 @@ import {
|
13
|
16
|
clearCalendarIntegration,
|
14
|
17
|
isCalendarEnabled,
|
15
|
18
|
signIn
|
|
19
|
+
|
|
20
|
+ // @ts-ignore
|
16
|
21
|
} from '../../../calendar-sync';
|
|
22
|
+// eslint-disable-next-line lines-around-comment
|
|
23
|
+// @ts-ignore
|
17
|
24
|
import { GoogleSignInButton } from '../../../google-api';
|
18
|
25
|
import logger from '../../logger';
|
19
|
26
|
|
20
|
|
-declare var interfaceConfig: Object;
|
21
|
|
-
|
22
|
27
|
/**
|
23
|
28
|
* The type of the React {@code Component} props of {@link CalendarTab}.
|
24
|
29
|
*/
|
25
|
|
-type Props = {
|
|
30
|
+interface IProps extends WithTranslation {
|
26
|
31
|
|
27
|
32
|
/**
|
28
|
33
|
* The name given to this Jitsi Application.
|
29
|
34
|
*/
|
30
|
|
- _appName: string,
|
|
35
|
+ _appName: string;
|
31
|
36
|
|
32
|
37
|
/**
|
33
|
38
|
* Whether or not to display a button to sign in to Google.
|
34
|
39
|
*/
|
35
|
|
- _enableGoogleIntegration: boolean,
|
|
40
|
+ _enableGoogleIntegration: boolean;
|
36
|
41
|
|
37
|
42
|
/**
|
38
|
43
|
* Whether or not to display a button to sign in to Microsoft.
|
39
|
44
|
*/
|
40
|
|
- _enableMicrosoftIntegration: boolean,
|
|
45
|
+ _enableMicrosoftIntegration: boolean;
|
41
|
46
|
|
42
|
47
|
/**
|
43
|
48
|
* The current calendar integration in use, if any.
|
44
|
49
|
*/
|
45
|
|
- _isConnectedToCalendar: boolean,
|
|
50
|
+ _isConnectedToCalendar: boolean;
|
46
|
51
|
|
47
|
52
|
/**
|
48
|
53
|
* The email address associated with the calendar integration in use.
|
49
|
54
|
*/
|
50
|
|
- _profileEmail: string,
|
|
55
|
+ _profileEmail?: string;
|
51
|
56
|
|
52
|
57
|
/**
|
53
|
|
- * Invoked to change the configured calendar integration.
|
|
58
|
+ * CSS classes object.
|
54
|
59
|
*/
|
55
|
|
- dispatch: Function,
|
|
60
|
+ classes: any;
|
56
|
61
|
|
57
|
62
|
/**
|
58
|
|
- * Invoked to obtain translated strings.
|
|
63
|
+ * Invoked to change the configured calendar integration.
|
59
|
64
|
*/
|
60
|
|
- t: Function
|
61
|
|
-};
|
|
65
|
+ dispatch: Function;
|
|
66
|
+}
|
62
|
67
|
|
63
|
68
|
/**
|
64
|
69
|
* The type of the React {@code Component} state of {@link CalendarTab}.
|
65
|
70
|
*/
|
66
|
|
-type State = {
|
|
71
|
+interface IState {
|
67
|
72
|
|
68
|
73
|
/**
|
69
|
74
|
* Whether or not any third party APIs are being loaded.
|
70
|
75
|
*/
|
71
|
|
- loading: boolean
|
|
76
|
+ loading: boolean;
|
|
77
|
+}
|
|
78
|
+
|
|
79
|
+const styles = (theme: Theme) => {
|
|
80
|
+ return {
|
|
81
|
+ container: {
|
|
82
|
+ width: '100%',
|
|
83
|
+ display: 'flex',
|
|
84
|
+ flexDirection: 'column' as const,
|
|
85
|
+ alignItems: 'center',
|
|
86
|
+ justifyContent: 'center',
|
|
87
|
+ textAlign: 'center',
|
|
88
|
+ minHeight: '100px',
|
|
89
|
+ color: theme.palette.text01,
|
|
90
|
+ ...withPixelLineHeight(theme.typography.bodyShortRegular)
|
|
91
|
+ },
|
|
92
|
+
|
|
93
|
+ button: {
|
|
94
|
+ marginTop: theme.spacing(4)
|
|
95
|
+ }
|
|
96
|
+ };
|
72
|
97
|
};
|
73
|
98
|
|
74
|
99
|
/**
|
|
@@ -76,13 +101,13 @@ type State = {
|
76
|
101
|
*
|
77
|
102
|
* @augments Component
|
78
|
103
|
*/
|
79
|
|
-class CalendarTab extends Component<Props, State> {
|
|
104
|
+class CalendarTab extends Component<IProps, IState> {
|
80
|
105
|
/**
|
81
|
106
|
* Initializes a new {@code CalendarTab} instance.
|
82
|
107
|
*
|
83
|
108
|
* @inheritdoc
|
84
|
109
|
*/
|
85
|
|
- constructor(props: Props) {
|
|
110
|
+ constructor(props: IProps) {
|
86
|
111
|
super(props);
|
87
|
112
|
|
88
|
113
|
this.state = {
|
|
@@ -103,7 +128,7 @@ class CalendarTab extends Component<Props, State> {
|
103
|
128
|
*/
|
104
|
129
|
componentDidMount() {
|
105
|
130
|
this.props.dispatch(bootstrapCalendarIntegration())
|
106
|
|
- .catch(err => logger.error('CalendarTab bootstrap failed', err))
|
|
131
|
+ .catch((err: any) => logger.error('CalendarTab bootstrap failed', err))
|
107
|
132
|
.then(() => this.setState({ loading: false }));
|
108
|
133
|
}
|
109
|
134
|
|
|
@@ -114,6 +139,7 @@ class CalendarTab extends Component<Props, State> {
|
114
|
139
|
* @returns {ReactElement}
|
115
|
140
|
*/
|
116
|
141
|
render() {
|
|
142
|
+ const { classes } = this.props;
|
117
|
143
|
let view;
|
118
|
144
|
|
119
|
145
|
if (this.state.loading) {
|
|
@@ -125,7 +151,7 @@ class CalendarTab extends Component<Props, State> {
|
125
|
151
|
}
|
126
|
152
|
|
127
|
153
|
return (
|
128
|
|
- <div className = 'calendar-tab'>
|
|
154
|
+ <div className = { classes.container }>
|
129
|
155
|
{ view }
|
130
|
156
|
</div>
|
131
|
157
|
);
|
|
@@ -139,12 +165,10 @@ class CalendarTab extends Component<Props, State> {
|
139
|
165
|
* @private
|
140
|
166
|
* @returns {void}
|
141
|
167
|
*/
|
142
|
|
- _attemptSignIn(type) {
|
|
168
|
+ _attemptSignIn(type: string) {
|
143
|
169
|
this.props.dispatch(signIn(type));
|
144
|
170
|
}
|
145
|
171
|
|
146
|
|
- _onClickDisconnect: (Object) => void;
|
147
|
|
-
|
148
|
172
|
/**
|
149
|
173
|
* Dispatches an action to sign out of the currently connected third party
|
150
|
174
|
* used for calendar integration.
|
|
@@ -161,8 +185,6 @@ class CalendarTab extends Component<Props, State> {
|
161
|
185
|
this.props.dispatch(clearCalendarIntegration());
|
162
|
186
|
}
|
163
|
187
|
|
164
|
|
- _onClickGoogle: () => void;
|
165
|
|
-
|
166
|
188
|
/**
|
167
|
189
|
* Starts the sign in flow for Google calendar integration.
|
168
|
190
|
*
|
|
@@ -173,8 +195,6 @@ class CalendarTab extends Component<Props, State> {
|
173
|
195
|
this._attemptSignIn(CALENDAR_TYPE.GOOGLE);
|
174
|
196
|
}
|
175
|
197
|
|
176
|
|
- _onClickMicrosoft: () => void;
|
177
|
|
-
|
178
|
198
|
/**
|
179
|
199
|
* Starts the sign in flow for Microsoft calendar integration.
|
180
|
200
|
*
|
|
@@ -194,6 +214,8 @@ class CalendarTab extends Component<Props, State> {
|
194
|
214
|
_renderLoadingState() {
|
195
|
215
|
return (
|
196
|
216
|
<Spinner
|
|
217
|
+
|
|
218
|
+ // @ts-ignore
|
197
|
219
|
isCompleting = { false }
|
198
|
220
|
size = 'medium' />
|
199
|
221
|
);
|
|
@@ -211,28 +233,29 @@ class CalendarTab extends Component<Props, State> {
|
211
|
233
|
_appName,
|
212
|
234
|
_enableGoogleIntegration,
|
213
|
235
|
_enableMicrosoftIntegration,
|
|
236
|
+ classes,
|
214
|
237
|
t
|
215
|
238
|
} = this.props;
|
216
|
239
|
|
217
|
240
|
return (
|
218
|
|
- <div>
|
|
241
|
+ <>
|
219
|
242
|
<p>
|
220
|
243
|
{ t('settings.calendar.about',
|
221
|
244
|
{ appName: _appName || '' }) }
|
222
|
245
|
</p>
|
223
|
246
|
{ _enableGoogleIntegration
|
224
|
|
- && <div className = 'calendar-tab-sign-in'>
|
|
247
|
+ && <div className = { classes.button }>
|
225
|
248
|
<GoogleSignInButton
|
226
|
249
|
onClick = { this._onClickGoogle }
|
227
|
250
|
text = { t('liveStreaming.signIn') } />
|
228
|
251
|
</div> }
|
229
|
252
|
{ _enableMicrosoftIntegration
|
230
|
|
- && <div className = 'calendar-tab-sign-in'>
|
|
253
|
+ && <div className = { classes.button }>
|
231
|
254
|
<MicrosoftSignInButton
|
232
|
255
|
onClick = { this._onClickMicrosoft }
|
233
|
256
|
text = { t('settings.calendar.microsoftSignIn') } />
|
234
|
257
|
</div> }
|
235
|
|
- </div>
|
|
258
|
+ </>
|
236
|
259
|
);
|
237
|
260
|
}
|
238
|
261
|
|
|
@@ -244,21 +267,18 @@ class CalendarTab extends Component<Props, State> {
|
244
|
267
|
* @returns {ReactElement}
|
245
|
268
|
*/
|
246
|
269
|
_renderSignOutState() {
|
247
|
|
- const { _profileEmail, t } = this.props;
|
|
270
|
+ const { _profileEmail, classes, t } = this.props;
|
248
|
271
|
|
249
|
272
|
return (
|
250
|
|
- <div>
|
251
|
|
- <div className = 'sign-out-cta'>
|
252
|
|
- { t('settings.calendar.signedIn',
|
|
273
|
+ <>
|
|
274
|
+ { t('settings.calendar.signedIn',
|
253
|
275
|
{ email: _profileEmail }) }
|
254
|
|
- </div>
|
255
|
|
- <div className = 'sign-out-cta-button'>
|
256
|
|
- <Button
|
257
|
|
- id = 'calendar_logout'
|
258
|
|
- label = { t('settings.calendar.disconnect') }
|
259
|
|
- onClick = { this._onClickDisconnect } />
|
260
|
|
- </div>
|
261
|
|
- </div>
|
|
276
|
+ <Button
|
|
277
|
+ className = { classes.button }
|
|
278
|
+ id = 'calendar_logout'
|
|
279
|
+ label = { t('settings.calendar.disconnect') }
|
|
280
|
+ onClick = { this._onClickDisconnect } />
|
|
281
|
+ </>
|
262
|
282
|
);
|
263
|
283
|
}
|
264
|
284
|
}
|
|
@@ -277,7 +297,7 @@ class CalendarTab extends Component<Props, State> {
|
277
|
297
|
* _profileEmail: string
|
278
|
298
|
* }}
|
279
|
299
|
*/
|
280
|
|
-function _mapStateToProps(state) {
|
|
300
|
+function _mapStateToProps(state: IReduxState) {
|
281
|
301
|
const calendarState = state['features/calendar-sync'] || {};
|
282
|
302
|
const {
|
283
|
303
|
googleApiApplicationClientID,
|
|
@@ -296,4 +316,4 @@ function _mapStateToProps(state) {
|
296
|
316
|
};
|
297
|
317
|
}
|
298
|
318
|
|
299
|
|
-export default translate(connect(_mapStateToProps)(CalendarTab));
|
|
319
|
+export default withStyles(styles)(translate(connect(_mapStateToProps)(CalendarTab)));
|