|
@@ -20,7 +20,7 @@ import {
|
20
|
20
|
setWorkspaceDetail,
|
21
|
21
|
setWorkspaceMemberList,
|
22
|
22
|
setWorkspaceRecentActivityList,
|
23
|
|
- setWorkspaceRecentActivityForUserList,
|
|
23
|
+ appendWorkspaceRecentActivityList,
|
24
|
24
|
setWorkspaceReadStatusList
|
25
|
25
|
} from '../action-creator.sync.js'
|
26
|
26
|
import { ROLE, PAGE } from '../helper.js'
|
|
@@ -34,7 +34,7 @@ class Dashboard extends React.Component {
|
34
|
34
|
constructor (props) {
|
35
|
35
|
super(props)
|
36
|
36
|
this.state = {
|
37
|
|
- workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null, // this is used to avoid handling the parseInt everytime
|
|
37
|
+ workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null, // this is used to avoid handling the parseInt every time
|
38
|
38
|
newMember: {
|
39
|
39
|
id: '',
|
40
|
40
|
avatarUrl: '',
|
|
@@ -51,6 +51,26 @@ class Dashboard extends React.Component {
|
51
|
51
|
}
|
52
|
52
|
|
53
|
53
|
async componentDidMount () {
|
|
54
|
+ this.loadWorkspaceDetail()
|
|
55
|
+ this.loadMemberList()
|
|
56
|
+ this.loadRecentActivity()
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ componentDidUpdate (prevProps, prevState) {
|
|
60
|
+ const { props, state } = this
|
|
61
|
+
|
|
62
|
+ if (prevProps.match.params.idws !== props.match.params.idws) {
|
|
63
|
+ this.setState({workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null})
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ if (prevState.workspaceIdInUrl !== state.workspaceIdInUrl) {
|
|
67
|
+ this.loadWorkspaceDetail()
|
|
68
|
+ this.loadMemberList()
|
|
69
|
+ this.loadRecentActivity()
|
|
70
|
+ }
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ loadWorkspaceDetail = async () => {
|
54
|
74
|
const { props, state } = this
|
55
|
75
|
|
56
|
76
|
const fetchWorkspaceDetail = await props.dispatch(getWorkspaceDetail(props.user, state.workspaceIdInUrl))
|
|
@@ -58,8 +78,6 @@ class Dashboard extends React.Component {
|
58
|
78
|
case 200: props.dispatch(setWorkspaceDetail(fetchWorkspaceDetail.json)); break
|
59
|
79
|
default: props.dispatch(newFlashMessage(`${props.t('An error has happened while fetching')} ${props.t('workspace detail')}`, 'warning')); break
|
60
|
80
|
}
|
61
|
|
- this.loadMemberList()
|
62
|
|
- this.loadRecentActivity()
|
63
|
81
|
}
|
64
|
82
|
|
65
|
83
|
loadMemberList = async () => {
|
|
@@ -87,11 +105,6 @@ class Dashboard extends React.Component {
|
87
|
105
|
case 200: props.dispatch(setWorkspaceReadStatusList(fetchWorkspaceReadStatusList.json)); break
|
88
|
106
|
default: props.dispatch(newFlashMessage(`${props.t('An error has happened while fetching')} ${props.t('read status list')}`, 'warning')); break
|
89
|
107
|
}
|
90
|
|
-
|
91
|
|
- const readStatusForUserList = fetchWorkspaceReadStatusList.json.filter(c => c.read_by_user).map(c => c.content_id)
|
92
|
|
- const recentActivityForUserList = fetchWorkspaceRecentActivityList.json.filter(content => !readStatusForUserList.includes(content.content_id))
|
93
|
|
-
|
94
|
|
- props.dispatch(setWorkspaceRecentActivityForUserList(recentActivityForUserList))
|
95
|
108
|
}
|
96
|
109
|
|
97
|
110
|
handleToggleNewMemberDashboard = () => this.setState(prevState => ({displayNewMemberDashboard: !prevState.displayNewMemberDashboard}))
|
|
@@ -114,7 +127,15 @@ class Dashboard extends React.Component {
|
114
|
127
|
}
|
115
|
128
|
|
116
|
129
|
handleClickSeeMore = async () => {
|
117
|
|
- console.log('nyi')
|
|
130
|
+ const { props, state } = this
|
|
131
|
+
|
|
132
|
+ const idLastRecentActivity = props.curWs.recentActivityList[props.curWs.recentActivityList.length - 1].id
|
|
133
|
+
|
|
134
|
+ const fetchWorkspaceRecentActivityList = await props.dispatch(getWorkspaceRecentActivityList(props.user, state.workspaceIdInUrl, idLastRecentActivity))
|
|
135
|
+ switch (fetchWorkspaceRecentActivityList.status) {
|
|
136
|
+ case 200: props.dispatch(appendWorkspaceRecentActivityList(fetchWorkspaceRecentActivityList.json)); break
|
|
137
|
+ default: props.dispatch(newFlashMessage(`${props.t('An error has happened while fetching')} ${props.t('recent activity list')}`, 'warning')); break
|
|
138
|
+ }
|
118
|
139
|
}
|
119
|
140
|
|
120
|
141
|
handleSearchUser = async userNameToSearch => {
|
|
@@ -223,6 +244,7 @@ class Dashboard extends React.Component {
|
223
|
244
|
label={ct.label}
|
224
|
245
|
faIcon={ct.faIcon}
|
225
|
246
|
creationLabel={ct.creationLabel}
|
|
247
|
+ onClickBtn={() => props.history.push(PAGE.WORKSPACE.NEW(props.curWs.id, ct.slug))}
|
226
|
248
|
key={ct.label}
|
227
|
249
|
/>
|
228
|
250
|
)}
|
|
@@ -231,7 +253,8 @@ class Dashboard extends React.Component {
|
231
|
253
|
<div className='dashboard__workspaceInfo'>
|
232
|
254
|
<RecentActivity
|
233
|
255
|
customClass='dashboard__activity'
|
234
|
|
- recentActivityFilteredForUser={props.curWs.recentActivityForUserList}
|
|
256
|
+ recentActivityList={props.curWs.recentActivityList}
|
|
257
|
+ readByUserList={props.curWs.contentReadStatusList}
|
235
|
258
|
contentTypeList={props.contentType}
|
236
|
259
|
onClickRecentContent={this.handleClickRecentContent}
|
237
|
260
|
onClickEverythingAsRead={this.handleClickMarkRecentActivityAsRead}
|