|
@@ -15,7 +15,7 @@ import {
|
15
|
15
|
getAppList,
|
16
|
16
|
getContentTypeList,
|
17
|
17
|
getWorkspaceContentList,
|
18
|
|
- getWorkspaceContent,
|
|
18
|
+ // getWorkspaceContent,
|
19
|
19
|
getFolderContent,
|
20
|
20
|
getWorkspaceList
|
21
|
21
|
} from '../action-creator.async.js'
|
|
@@ -39,7 +39,8 @@ class WorkspaceContent extends React.Component {
|
39
|
39
|
type: undefined,
|
40
|
40
|
folder: undefined
|
41
|
41
|
},
|
42
|
|
- workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null
|
|
42
|
+ workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null,
|
|
43
|
+ workspaceOpened: false
|
43
|
44
|
}
|
44
|
45
|
|
45
|
46
|
document.addEventListener('appCustomEvent', this.customEventReducer)
|
|
@@ -52,6 +53,7 @@ class WorkspaceContent extends React.Component {
|
52
|
53
|
break
|
53
|
54
|
case 'appClosed':
|
54
|
55
|
this.props.history.push(PAGE.WORKSPACE.CONTENT(this.props.workspace.id, ''))
|
|
56
|
+ this.setState({workspaceOpened: false})
|
55
|
57
|
break
|
56
|
58
|
}
|
57
|
59
|
}
|
|
@@ -72,7 +74,6 @@ class WorkspaceContent extends React.Component {
|
72
|
74
|
if (fetchGetContentTypeList.status === 200) dispatch(setContentTypeList(fetchGetContentTypeList.json))
|
73
|
75
|
}
|
74
|
76
|
|
75
|
|
-
|
76
|
77
|
let wsToLoad = null
|
77
|
78
|
if (match.params.idws !== undefined) wsToLoad = match.params.idws
|
78
|
79
|
|
|
@@ -98,7 +99,7 @@ class WorkspaceContent extends React.Component {
|
98
|
99
|
}
|
99
|
100
|
|
100
|
101
|
componentDidUpdate (prevProps, prevState) {
|
101
|
|
- const { contentType, workspace, user, renderApp, match } = this.props
|
|
102
|
+ const { contentType, workspaceContent, user, renderApp, match } = this.props
|
102
|
103
|
|
103
|
104
|
console.log('componentDidUpdate')
|
104
|
105
|
|
|
@@ -109,9 +110,9 @@ class WorkspaceContent extends React.Component {
|
109
|
110
|
|
110
|
111
|
// if (user.user_id !== -1 && prevProps.user.id !== user.id) dispatch(getWorkspaceList(user.user_id, idWorkspace))
|
111
|
112
|
|
112
|
|
- if (match.params.idcts && workspace.id !== -1) { // if a content id is in url, open it
|
|
113
|
+ if (match.params.idcts && workspaceContent.id !== -1 && !workspaceOpened && workspaceContent.length) { // if a content id is in url, open it
|
113
|
114
|
const idContentToOpen = parseInt(match.params.idcts)
|
114
|
|
- const contentToOpen = workspace.find(wsc => wsc.id === idContentToOpen) // || await dispatch(getWorkspaceContent(idWorkspace, idContentToOpen))
|
|
115
|
+ const contentToOpen = workspaceContent.find(wsc => wsc.id === idContentToOpen) // || await dispatch(getWorkspaceContent(idWorkspace, idContentToOpen))
|
115
|
116
|
|
116
|
117
|
// @FIXME : for alpha, we do not handle subfolder. commented code bellow should load a component that is not in the workspace root
|
117
|
118
|
// if (contentToOpen === undefined) { // content is not is ws root
|
|
@@ -119,17 +120,20 @@ class WorkspaceContent extends React.Component {
|
119
|
120
|
// console.log(fetchContent)
|
120
|
121
|
// }
|
121
|
122
|
|
|
123
|
+ console.log('contentToOpen', contentToOpen)
|
|
124
|
+
|
122
|
125
|
renderApp(
|
123
|
126
|
contentType.find(ct => ct.type === contentToOpen.type),
|
124
|
127
|
user,
|
125
|
|
- {...contentToOpen, workspace: workspace}
|
|
128
|
+ {...contentToOpen, workspaceContent: workspaceContent}
|
126
|
129
|
)
|
|
130
|
+ this.setState({workspaceOpened: true})
|
127
|
131
|
}
|
128
|
132
|
}
|
129
|
133
|
|
130
|
134
|
handleClickContentItem = content => {
|
131
|
135
|
console.log('content clicked', content)
|
132
|
|
- this.props.history.push(`${PAGE.WORKSPACE.CONTENT(content.workspace_id, content.id)}${this.props.location.search}`)
|
|
136
|
+ this.props.history.push(`${PAGE.WORKSPACE.CONTENT(content.workspaceId, content.id)}${this.props.location.search}`)
|
133
|
137
|
}
|
134
|
138
|
|
135
|
139
|
handleClickEditContentItem = (e, content) => {
|
|
@@ -166,22 +170,22 @@ class WorkspaceContent extends React.Component {
|
166
|
170
|
}
|
167
|
171
|
|
168
|
172
|
render () {
|
169
|
|
- const { workspace, app, contentType } = this.props
|
|
173
|
+ const { workspaceContent, app, contentType } = this.props
|
170
|
174
|
|
171
|
175
|
const filterWorkspaceContent = (contentList, filter) => {
|
172
|
176
|
console.log(contentList, filter)
|
173
|
177
|
return filter.length === 0
|
174
|
178
|
? contentList
|
175
|
179
|
: contentList.filter(c => c.type === 'folder' || filter.includes(c.type)) // keep unfiltered files and folders
|
176
|
|
- // @FIXME we need to filter subfolder too, but right now, we dont handle subfolder
|
177
|
|
- // .map(c => c.type !== 'folder' ? c : {...c, content: filterWorkspaceContent(c.content, filter)}) // recursively filter folder content
|
|
180
|
+ // @FIXME we need to filter subfolder too, but right now, we dont handle subfolder
|
|
181
|
+ // .map(c => c.type !== 'folder' ? c : {...c, content: filterWorkspaceContent(c.content, filter)}) // recursively filter folder content
|
178
|
182
|
}
|
179
|
183
|
// .filter(c => c.type !== 'folder' || c.content.length > 0) // remove empty folder => 2018/05/21 - since we load only one lvl of content, don't remove empty
|
180
|
184
|
|
181
|
185
|
const urlFilter = qs.parse(this.props.location.search).type
|
182
|
186
|
|
183
|
|
- const filteredWorkspaceContent = workspace.length > 0
|
184
|
|
- ? filterWorkspaceContent(workspace, urlFilter ? [urlFilter] : [])
|
|
187
|
+ const filteredWorkspaceContent = workspaceContent.length > 0
|
|
188
|
+ ? filterWorkspaceContent(workspaceContent, urlFilter ? [urlFilter] : [])
|
185
|
189
|
: []
|
186
|
190
|
console.log('workspaceContent => filteredWorkspaceContent', filteredWorkspaceContent)
|
187
|
191
|
|
|
@@ -193,7 +197,7 @@ class WorkspaceContent extends React.Component {
|
193
|
197
|
<PageTitle
|
194
|
198
|
parentClass='workspace__header'
|
195
|
199
|
customClass='justify-content-between'
|
196
|
|
- title={workspace.label ? workspace.label : ''}
|
|
200
|
+ title={workspaceContent.label ? workspaceContent.label : ''}
|
197
|
201
|
>
|
198
|
202
|
<DropdownCreateButton parentClass='workspace__header__btnaddworkspace' />
|
199
|
203
|
</PageTitle>
|
|
@@ -256,5 +260,5 @@ class WorkspaceContent extends React.Component {
|
256
|
260
|
}
|
257
|
261
|
}
|
258
|
262
|
|
259
|
|
-const mapStateToProps = ({ user, workspace, workspaceList, app, contentType }) => ({ user, workspace, workspaceList, app, contentType })
|
|
263
|
+const mapStateToProps = ({ user, workspaceContent, workspaceList, app, contentType }) => ({ user, workspaceContent, workspaceList, app, contentType })
|
260
|
264
|
export default withRouter(connect(mapStateToProps)(appFactory(WorkspaceContent)))
|