@@ -17,7 +17,7 @@ import SyncAdvancedSwitch from './space/sync/SyncAdvancedSwitch';
17
17
import StudentModeSwitch from './common/StudentModeSwitch' ;
18
18
import ActionEnabledSwitch from './common/ActionEnabledSwitch' ;
19
19
import ActionAccessibilitySwitch from './common/ActionAccessibilitySwitch' ;
20
- import { USER_MODES } from '../config/constants' ;
20
+ import { USER_MODES , DEFAULT_USER_MODE } from '../config/constants' ;
21
21
22
22
const styles = theme => ( {
23
23
...Styles ( theme ) ,
@@ -43,10 +43,31 @@ export class Settings extends Component {
43
43
changeLanguage : PropTypes . func . isRequired ,
44
44
} ) . isRequired ,
45
45
userMode : PropTypes . oneOf ( Object . values ( USER_MODES ) ) . isRequired ,
46
+ authenticated : PropTypes . bool . isRequired ,
47
+ } ;
48
+
49
+ renderDeveloperModeSwitch = ( ) => {
50
+ const { userMode } = this . props ;
51
+ return userMode === USER_MODES . TEACHER ? < DeveloperSwitch /> : null ;
52
+ } ;
53
+
54
+ renderActionSettings = ( ) => {
55
+ const { t } = this . props ;
56
+ return (
57
+ < >
58
+ < Typography variant = "h5" color = "inherit" className = "mt-2" >
59
+ { t ( 'Actions' ) }
60
+ </ Typography >
61
+ < FormGroup >
62
+ < ActionEnabledSwitch />
63
+ < ActionAccessibilitySwitch />
64
+ </ FormGroup >
65
+ </ >
66
+ ) ;
46
67
} ;
47
68
48
69
render ( ) {
49
- const { classes, t, userMode } = this . props ;
70
+ const { classes, t, authenticated } = this . props ;
50
71
51
72
return (
52
73
< Main id = { SETTINGS_MAIN_ID } >
@@ -56,27 +77,28 @@ export class Settings extends Component {
56
77
</ Typography >
57
78
< FormGroup >
58
79
< LanguageSelect />
59
- < GeolocationControl />
60
- < SyncAdvancedSwitch />
61
- < StudentModeSwitch />
62
- { userMode === USER_MODES . TEACHER ? < DeveloperSwitch /> : null }
80
+ { authenticated && (
81
+ < >
82
+ < GeolocationControl />
83
+ < SyncAdvancedSwitch />
84
+ < StudentModeSwitch />
85
+ { this . renderDeveloperModeSwitch ( ) }
86
+ </ >
87
+ ) }
63
88
</ FormGroup >
64
89
< Divider variant = "middle" classes = { { root : classes . divider } } />
65
- < Typography variant = "h5" color = "inherit" className = "mt-2" >
66
- { t ( 'Actions' ) }
67
- </ Typography >
68
- < FormGroup >
69
- < ActionEnabledSwitch />
70
- < ActionAccessibilitySwitch />
71
- </ FormGroup >
90
+
91
+ { authenticated && this . renderActionSettings ( ) }
72
92
</ div >
73
93
</ Main >
74
94
) ;
75
95
}
76
96
}
77
97
78
98
const mapStateToProps = ( { authentication } ) => ( {
79
- userMode : authentication . getIn ( [ 'user' , 'settings' , 'userMode' ] ) ,
99
+ authenticated : authentication . getIn ( [ 'authenticated' ] ) ,
100
+ userMode :
101
+ authentication . getIn ( [ 'user' , 'settings' , 'userMode' ] ) || DEFAULT_USER_MODE ,
80
102
} ) ;
81
103
82
104
const ConnectedComponent = connect ( mapStateToProps , null ) ( Settings ) ;
0 commit comments