|
@@ -1,4 +1,5 @@
|
1
|
|
-/* eslint-disable lines-around-comment */
|
|
1
|
+import { Theme } from '@mui/material';
|
|
2
|
+import { withStyles } from '@mui/styles';
|
2
|
3
|
import React from 'react';
|
3
|
4
|
import { WithTranslation } from 'react-i18next';
|
4
|
5
|
|
|
@@ -6,20 +7,22 @@ import { WithTranslation } from 'react-i18next';
|
6
|
7
|
import UIEvents from '../../../../../service/UI/UIEvents';
|
7
|
8
|
import { createProfilePanelButtonEvent } from '../../../analytics/AnalyticsEvents';
|
8
|
9
|
import { sendAnalytics } from '../../../analytics/functions';
|
|
10
|
+// eslint-disable-next-line lines-around-comment
|
9
|
11
|
// @ts-ignore
|
10
|
|
-import { AbstractDialogTab } from '../../../base/dialog';
|
11
|
|
-// @ts-ignore
|
12
|
|
-import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
|
|
12
|
+import Avatar from '../../../base/avatar/components/Avatar';
|
|
13
|
+import AbstractDialogTab, {
|
|
14
|
+ IProps as AbstractDialogTabProps } from '../../../base/dialog/components/web/AbstractDialogTab';
|
13
|
15
|
import { translate } from '../../../base/i18n/functions';
|
14
|
16
|
import Button from '../../../base/ui/components/web/Button';
|
|
17
|
+import Checkbox from '../../../base/ui/components/web/Checkbox';
|
15
|
18
|
import Input from '../../../base/ui/components/web/Input';
|
|
19
|
+import Select from '../../../base/ui/components/web/Select';
|
16
|
20
|
import { openLogoutDialog } from '../../actions';
|
17
|
|
-/* eslint-enable lines-around-comment */
|
18
|
21
|
|
19
|
22
|
/**
|
20
|
23
|
* The type of the React {@code Component} props of {@link ProfileTab}.
|
21
|
24
|
*/
|
22
|
|
-export type Props = AbstractDialogTabProps & WithTranslation & {
|
|
25
|
+export interface IProps extends AbstractDialogTabProps, WithTranslation {
|
23
|
26
|
|
24
|
27
|
/**
|
25
|
28
|
* Whether or not server-side authentication is available.
|
|
@@ -31,6 +34,22 @@ export type Props = AbstractDialogTabProps & WithTranslation & {
|
31
|
34
|
*/
|
32
|
35
|
authLogin: string;
|
33
|
36
|
|
|
37
|
+ /**
|
|
38
|
+ * CSS classes object.
|
|
39
|
+ */
|
|
40
|
+ classes: any;
|
|
41
|
+
|
|
42
|
+ /**
|
|
43
|
+ * The currently selected language to display in the language select
|
|
44
|
+ * dropdown.
|
|
45
|
+ */
|
|
46
|
+ currentLanguage: string;
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * Whether to show hide self view setting.
|
|
50
|
+ */
|
|
51
|
+ disableHideSelfView: boolean;
|
|
52
|
+
|
34
|
53
|
/**
|
35
|
54
|
* The display name to display for the local participant.
|
36
|
55
|
*/
|
|
@@ -46,15 +65,52 @@ export type Props = AbstractDialogTabProps & WithTranslation & {
|
46
|
65
|
*/
|
47
|
66
|
hideEmailInSettings?: boolean;
|
48
|
67
|
|
|
68
|
+ /**
|
|
69
|
+ * Whether or not to hide self-view screen.
|
|
70
|
+ */
|
|
71
|
+ hideSelfView: boolean;
|
|
72
|
+
|
|
73
|
+ /**
|
|
74
|
+ * The id of the local participant.
|
|
75
|
+ */
|
|
76
|
+ id: string;
|
|
77
|
+
|
|
78
|
+ /**
|
|
79
|
+ * All available languages to display in the language select dropdown.
|
|
80
|
+ */
|
|
81
|
+ languages: Array<string>;
|
|
82
|
+
|
49
|
83
|
/**
|
50
|
84
|
* If the display name is read only.
|
51
|
85
|
*/
|
52
|
86
|
readOnlyName: boolean;
|
53
|
87
|
|
54
|
88
|
/**
|
55
|
|
- * Invoked to obtain translated strings.
|
|
89
|
+ * Whether or not to display the language select dropdown.
|
56
|
90
|
*/
|
57
|
|
- t: Function;
|
|
91
|
+ showLanguageSettings: boolean;
|
|
92
|
+}
|
|
93
|
+
|
|
94
|
+const styles = (theme: Theme) => {
|
|
95
|
+ return {
|
|
96
|
+ container: {
|
|
97
|
+ display: 'flex',
|
|
98
|
+ flexDirection: 'column' as const,
|
|
99
|
+ width: '100%',
|
|
100
|
+ padding: '0 2px'
|
|
101
|
+ },
|
|
102
|
+
|
|
103
|
+ avatarContainer: {
|
|
104
|
+ display: 'flex',
|
|
105
|
+ width: '100%',
|
|
106
|
+ justifyContent: 'center',
|
|
107
|
+ marginBottom: theme.spacing(4)
|
|
108
|
+ },
|
|
109
|
+
|
|
110
|
+ bottomMargin: {
|
|
111
|
+ marginBottom: theme.spacing(4)
|
|
112
|
+ }
|
|
113
|
+ };
|
58
|
114
|
};
|
59
|
115
|
|
60
|
116
|
/**
|
|
@@ -62,7 +118,7 @@ export type Props = AbstractDialogTabProps & WithTranslation & {
|
62
|
118
|
*
|
63
|
119
|
* @augments Component
|
64
|
120
|
*/
|
65
|
|
-class ProfileTab extends AbstractDialogTab<Props> {
|
|
121
|
+class ProfileTab extends AbstractDialogTab<IProps, any> {
|
66
|
122
|
static defaultProps = {
|
67
|
123
|
displayName: '',
|
68
|
124
|
email: ''
|
|
@@ -71,16 +127,18 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
71
|
127
|
/**
|
72
|
128
|
* Initializes a new {@code ConnectedSettingsDialog} instance.
|
73
|
129
|
*
|
74
|
|
- * @param {Props} props - The React {@code Component} props to initialize
|
|
130
|
+ * @param {IProps} props - The React {@code Component} props to initialize
|
75
|
131
|
* the new {@code ConnectedSettingsDialog} instance with.
|
76
|
132
|
*/
|
77
|
|
- constructor(props: Props) {
|
|
133
|
+ constructor(props: IProps) {
|
78
|
134
|
super(props);
|
79
|
135
|
|
80
|
136
|
// Bind event handlers so they are only bound once for every instance.
|
81
|
137
|
this._onAuthToggle = this._onAuthToggle.bind(this);
|
82
|
138
|
this._onDisplayNameChange = this._onDisplayNameChange.bind(this);
|
83
|
139
|
this._onEmailChange = this._onEmailChange.bind(this);
|
|
140
|
+ this._onHideSelfViewChanged = this._onHideSelfViewChanged.bind(this);
|
|
141
|
+ this._onLanguageItemSelect = this._onLanguageItemSelect.bind(this);
|
84
|
142
|
}
|
85
|
143
|
|
86
|
144
|
/**
|
|
@@ -105,6 +163,62 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
105
|
163
|
super._onChange({ email: value });
|
106
|
164
|
}
|
107
|
165
|
|
|
166
|
+ /**
|
|
167
|
+ * Callback invoked to select if hide self view should be enabled.
|
|
168
|
+ *
|
|
169
|
+ * @param {Object} e - The key event to handle.
|
|
170
|
+ *
|
|
171
|
+ * @returns {void}
|
|
172
|
+ */
|
|
173
|
+ _onHideSelfViewChanged({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
|
|
174
|
+ super._onChange({ hideSelfView: checked });
|
|
175
|
+ }
|
|
176
|
+
|
|
177
|
+ /**
|
|
178
|
+ * Callback invoked to select a language from select dropdown.
|
|
179
|
+ *
|
|
180
|
+ * @param {Object} e - The key event to handle.
|
|
181
|
+ *
|
|
182
|
+ * @returns {void}
|
|
183
|
+ */
|
|
184
|
+ _onLanguageItemSelect(e: React.ChangeEvent<HTMLSelectElement>) {
|
|
185
|
+ const language = e.target.value;
|
|
186
|
+
|
|
187
|
+ super._onChange({ currentLanguage: language });
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ /**
|
|
191
|
+ * Returns the menu item for changing displayed language.
|
|
192
|
+ *
|
|
193
|
+ * @private
|
|
194
|
+ * @returns {ReactElement}
|
|
195
|
+ */
|
|
196
|
+ _renderLanguageSelect() {
|
|
197
|
+ const {
|
|
198
|
+ classes,
|
|
199
|
+ currentLanguage,
|
|
200
|
+ languages,
|
|
201
|
+ t
|
|
202
|
+ } = this.props;
|
|
203
|
+
|
|
204
|
+ const languageItems
|
|
205
|
+ = languages.map((language: string) => {
|
|
206
|
+ return {
|
|
207
|
+ value: language,
|
|
208
|
+ label: t(`languages:${language}`)
|
|
209
|
+ };
|
|
210
|
+ });
|
|
211
|
+
|
|
212
|
+ return (
|
|
213
|
+ <Select
|
|
214
|
+ className = { classes.bottomMargin }
|
|
215
|
+ label = { t('settings.language') }
|
|
216
|
+ onChange = { this._onLanguageItemSelect }
|
|
217
|
+ options = { languageItems }
|
|
218
|
+ value = { currentLanguage } />
|
|
219
|
+ );
|
|
220
|
+ }
|
|
221
|
+
|
108
|
222
|
/**
|
109
|
223
|
* Implements React's {@link Component#render()}.
|
110
|
224
|
*
|
|
@@ -114,38 +228,55 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
114
|
228
|
render() {
|
115
|
229
|
const {
|
116
|
230
|
authEnabled,
|
|
231
|
+ classes,
|
|
232
|
+ disableHideSelfView,
|
117
|
233
|
displayName,
|
118
|
234
|
email,
|
119
|
235
|
hideEmailInSettings,
|
|
236
|
+ hideSelfView,
|
|
237
|
+ id,
|
120
|
238
|
readOnlyName,
|
121
|
|
- t // @ts-ignore
|
|
239
|
+ showLanguageSettings,
|
|
240
|
+ t
|
122
|
241
|
} = this.props;
|
123
|
242
|
|
124
|
243
|
return (
|
125
|
|
- <div>
|
126
|
|
- <div className = 'profile-edit'>
|
127
|
|
- <div className = 'profile-edit-field'>
|
128
|
|
- <Input
|
129
|
|
- disabled = { readOnlyName }
|
130
|
|
- id = 'setDisplayName'
|
131
|
|
- label = { t('profile.setDisplayNameLabel') }
|
132
|
|
- name = 'name'
|
133
|
|
- onChange = { this._onDisplayNameChange }
|
134
|
|
- placeholder = { t('settings.name') }
|
135
|
|
- type = 'text'
|
136
|
|
- value = { displayName } />
|
137
|
|
- </div>
|
138
|
|
- {!hideEmailInSettings && <div className = 'profile-edit-field'>
|
139
|
|
- <Input
|
140
|
|
- id = 'setEmail'
|
141
|
|
- label = { t('profile.setEmailLabel') }
|
142
|
|
- name = 'email'
|
143
|
|
- onChange = { this._onEmailChange }
|
144
|
|
- placeholder = { t('profile.setEmailInput') }
|
145
|
|
- type = 'text'
|
146
|
|
- value = { email } />
|
147
|
|
- </div>}
|
|
244
|
+ <div className = { classes.container } >
|
|
245
|
+ <div className = { classes.avatarContainer }>
|
|
246
|
+ <Avatar
|
|
247
|
+ participantId = { id }
|
|
248
|
+ size = { 60 } />
|
148
|
249
|
</div>
|
|
250
|
+ <Input
|
|
251
|
+ className = { classes.bottomMargin }
|
|
252
|
+ disabled = { readOnlyName }
|
|
253
|
+ id = 'setDisplayName'
|
|
254
|
+ label = { t('profile.setDisplayNameLabel') }
|
|
255
|
+ name = 'name'
|
|
256
|
+ onChange = { this._onDisplayNameChange }
|
|
257
|
+ placeholder = { t('settings.name') }
|
|
258
|
+ type = 'text'
|
|
259
|
+ value = { displayName } />
|
|
260
|
+ {!hideEmailInSettings && <div className = 'profile-edit-field'>
|
|
261
|
+ <Input
|
|
262
|
+ className = { classes.bottomMargin }
|
|
263
|
+ id = 'setEmail'
|
|
264
|
+ label = { t('profile.setEmailLabel') }
|
|
265
|
+ name = 'email'
|
|
266
|
+ onChange = { this._onEmailChange }
|
|
267
|
+ placeholder = { t('profile.setEmailInput') }
|
|
268
|
+ type = 'text'
|
|
269
|
+ value = { email } />
|
|
270
|
+ </div>}
|
|
271
|
+ {!disableHideSelfView && (
|
|
272
|
+ <Checkbox
|
|
273
|
+ checked = { hideSelfView }
|
|
274
|
+ className = { classes.bottomMargin }
|
|
275
|
+ label = { t('videothumbnail.hideSelfView') }
|
|
276
|
+ name = 'hide-self-view'
|
|
277
|
+ onChange = { this._onHideSelfViewChanged } />
|
|
278
|
+ )}
|
|
279
|
+ {showLanguageSettings && this._renderLanguageSelect()}
|
149
|
280
|
{ authEnabled && this._renderAuth() }
|
150
|
281
|
</div>
|
151
|
282
|
);
|
|
@@ -159,7 +290,6 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
159
|
290
|
* @returns {void}
|
160
|
291
|
*/
|
161
|
292
|
_onAuthToggle() {
|
162
|
|
- // @ts-ignore
|
163
|
293
|
if (this.props.authLogin) {
|
164
|
294
|
sendAnalytics(createProfilePanelButtonEvent('logout.button'));
|
165
|
295
|
|
|
@@ -183,8 +313,6 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
183
|
313
|
const {
|
184
|
314
|
authLogin,
|
185
|
315
|
t
|
186
|
|
-
|
187
|
|
- // @ts-ignore
|
188
|
316
|
} = this.props;
|
189
|
317
|
|
190
|
318
|
return (
|
|
@@ -206,5 +334,4 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
206
|
334
|
}
|
207
|
335
|
}
|
208
|
336
|
|
209
|
|
-// @ts-ignore
|
210
|
|
-export default translate(ProfileTab);
|
|
337
|
+export default withStyles(styles)(translate(ProfileTab));
|