Browse Source

app openning now waits until workspace content has loader to avoid openning app with default 'reader' rights

Skylsmoi 6 years ago
parent
commit
e9338543a1
1 changed files with 22 additions and 14 deletions
  1. 22 14
      frontend/src/container/WorkspaceContent.jsx

+ 22 - 14
frontend/src/container/WorkspaceContent.jsx View File

36
     super(props)
36
     super(props)
37
     this.state = {
37
     this.state = {
38
       workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null, // this is used to avoid handling the parseInt every time
38
       workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null, // this is used to avoid handling the parseInt every time
39
-      appOpenedType: false
39
+      appOpenedType: false,
40
+      contentLoaded: false
40
     }
41
     }
41
 
42
 
42
     document.addEventListener('appCustomEvent', this.customEventReducer)
43
     document.addEventListener('appCustomEvent', this.customEventReducer)
108
     const wsContent = await dispatch(getWorkspaceContentList(user, idWorkspace, 0))
109
     const wsContent = await dispatch(getWorkspaceContentList(user, idWorkspace, 0))
109
     const wsMember = await dispatch(getWorkspaceMemberList(user, idWorkspace))
110
     const wsMember = await dispatch(getWorkspaceMemberList(user, idWorkspace))
110
 
111
 
111
-    if (await wsContent.status === 200) dispatch(setWorkspaceContentList(wsContent.json))
112
+    if (wsContent.status === 200) dispatch(setWorkspaceContentList(wsContent.json))
112
     else dispatch(newFlashMessage('Error while loading workspace', 'danger'))
113
     else dispatch(newFlashMessage('Error while loading workspace', 'danger'))
113
 
114
 
114
-    if (await wsMember.status === 200) dispatch(setWorkspaceMemberList(wsMember.json))
115
+    if (wsMember.status === 200) dispatch(setWorkspaceMemberList(wsMember.json))
115
     else dispatch(newFlashMessage('Error while loading members list', 'warning'))
116
     else dispatch(newFlashMessage('Error while loading members list', 'warning'))
117
+
118
+    this.setState({contentLoaded: true})
116
   }
119
   }
117
 
120
 
118
   handleClickContentItem = content => {
121
   handleClickContentItem = content => {
178
 
181
 
179
   render () {
182
   render () {
180
     const { user, currentWorkspace, workspaceContentList, contentType } = this.props
183
     const { user, currentWorkspace, workspaceContentList, contentType } = this.props
184
+    const { state } = this
181
 
185
 
182
     const filterWorkspaceContent = (contentList, filter) => {
186
     const filterWorkspaceContent = (contentList, filter) => {
183
       return filter.length === 0
187
       return filter.length === 0
198
 
202
 
199
     return (
203
     return (
200
       <div className='WorkspaceContent' style={{width: '100%'}}>
204
       <div className='WorkspaceContent' style={{width: '100%'}}>
201
-        <OpenContentApp
202
-          // automatically open the app for the idContent in url
203
-          idWorkspace={this.state.workspaceIdInUrl}
204
-          appOpenedType={this.state.appOpenedType}
205
-          updateAppOpenedType={this.handleUpdateAppOpenedType}
206
-        />
207
-
208
-        <Route path={PAGE.WORKSPACE.NEW(':idws', ':type')} component={() =>
209
-          <OpenCreateContentApp
210
-            // automatically open the popup create content of the app in url
205
+        {state.contentLoaded &&
206
+          <OpenContentApp
207
+            // automatically open the app for the idContent in url
211
             idWorkspace={this.state.workspaceIdInUrl}
208
             idWorkspace={this.state.workspaceIdInUrl}
212
             appOpenedType={this.state.appOpenedType}
209
             appOpenedType={this.state.appOpenedType}
210
+            updateAppOpenedType={this.handleUpdateAppOpenedType}
213
           />
211
           />
214
-        } />
212
+        }
213
+
214
+        {state.contentLoaded &&
215
+          <Route path={PAGE.WORKSPACE.NEW(':idws', ':type')} component={() =>
216
+            <OpenCreateContentApp
217
+              // automatically open the popup create content of the app in url
218
+              idWorkspace={this.state.workspaceIdInUrl}
219
+              appOpenedType={this.state.appOpenedType}
220
+            />
221
+          } />
222
+        }
215
 
223
 
216
         <PageWrapper customeClass='workspace'>
224
         <PageWrapper customeClass='workspace'>
217
           <PageTitle
225
           <PageTitle