@@ -19,7 +19,7 @@ import ActionEditor from './ActionEditor';
19
19
import Loader from '../common/Loader' ;
20
20
import Main from '../common/Main' ;
21
21
import { getDatabase } from '../../actions' ;
22
- import { FILTER_ALL_SPACE_ID } from '../../config/constants' ;
22
+ import { FILTER_ALL_SPACE_ID , USER_MODES } from '../../config/constants' ;
23
23
import { DASHBOARD_MAIN_ID } from '../../config/selectors' ;
24
24
25
25
const styles = theme => ( {
@@ -72,6 +72,8 @@ export class Dashboard extends Component {
72
72
actions : PropTypes . arrayOf ( PropTypes . object ) ,
73
73
} ) ,
74
74
dispatchGetDatabase : PropTypes . func . isRequired ,
75
+ userMode : PropTypes . oneOf ( Object . values ( USER_MODES ) ) . isRequired ,
76
+ userId : PropTypes . string . isRequired ,
75
77
} ;
76
78
77
79
static defaultProps = {
@@ -115,10 +117,17 @@ export class Dashboard extends Component {
115
117
} ;
116
118
117
119
renderActionWidgets = ( ) => {
118
- const { database, t, classes } = this . props ;
120
+ const { database, t, classes, userMode , userId } = this . props ;
119
121
const { spaceId } = this . state ;
120
122
121
123
let filteredActions = database . actions ;
124
+
125
+ // filter action per user if userMode is student
126
+ if ( userMode === USER_MODES . STUDENT ) {
127
+ filteredActions = filteredActions . filter ( ( { user } ) => user === userId ) ;
128
+ }
129
+
130
+ // filter action per space
122
131
if ( spaceId !== FILTER_ALL_SPACE_ID ) {
123
132
filteredActions = filteredActions . filter (
124
133
( { spaceId : id } ) => id === spaceId
@@ -194,8 +203,10 @@ export class Dashboard extends Component {
194
203
}
195
204
}
196
205
197
- const mapStateToProps = ( { Developer } ) => ( {
206
+ const mapStateToProps = ( { Developer, authentication } ) => ( {
198
207
database : Developer . get ( 'database' ) ,
208
+ userId : authentication . getIn ( [ 'user' , 'id' ] ) ,
209
+ userMode : authentication . getIn ( [ 'user' , 'settings' , 'userMode' ] ) ,
199
210
} ) ;
200
211
201
212
const mapDispatchToProps = {
0 commit comments