Bläddra i källkod

added handling for router from api (with /#) + added unmount app call when workspacecontent.jsx unmount

Skylsmoi 5 år sedan
förälder
incheckning
9f00d1ec15
4 ändrade filer med 14 tillägg och 3 borttagningar
  1. 6 1
      dist/index.html
  2. 1 1
      src/appFactory.js
  3. 4 0
      src/container/WorkspaceContent.jsx
  4. 3 1
      src/reducer/workspaceList.js

+ 6 - 1
dist/index.html Visa fil

78
 
78
 
79
         switch (type) {
79
         switch (type) {
80
           case 'hide_popupCreateContent':
80
           case 'hide_popupCreateContent':
81
-            getSelectedApp(data.name).hideApp('popupCreateContentContainer')
81
+            getSelectedApp(data.name).unmountApp('popupCreateContentContainer')
82
+            break
83
+          case 'unmount_app':
84
+            prevSelectedApp.unmountApp('appContainer')
85
+            prevSelectedApp.unmountApp('popupCreateContentContainer')
86
+            prevSelectedApp.isRendered = false
82
             break
87
             break
83
         }
88
         }
84
       }
89
       }

+ 1 - 1
src/appFactory.js Visa fil

28
       idFolder
28
       idFolder
29
     })
29
     })
30
 
30
 
31
-    emitEventApp = (type, data) => GLOBAL_dispatchEvent(type, data)
31
+    emitEventApp = (type, data) => GLOBAL_dispatchEvent({ type, data })
32
 
32
 
33
     render () {
33
     render () {
34
       return (
34
       return (

+ 4 - 0
src/container/WorkspaceContent.jsx Visa fil

123
     // if (user.user_id !== -1 && prevProps.user.id !== user.id) dispatch(getWorkspaceList(user.user_id, idWorkspace))
123
     // if (user.user_id !== -1 && prevProps.user.id !== user.id) dispatch(getWorkspaceList(user.user_id, idWorkspace))
124
   }
124
   }
125
 
125
 
126
+  componentWillUnmount () {
127
+    this.props.emitEventApp('unmount_app')
128
+  }
129
+
126
   handleClickContentItem = content => {
130
   handleClickContentItem = content => {
127
     console.log('content clicked', content)
131
     console.log('content clicked', content)
128
     this.props.history.push(`/workspaces/${content.idWorkspace}/${content.type}/${content.id}`)
132
     this.props.history.push(`/workspaces/${content.idWorkspace}/${content.type}/${content.id}`)

+ 3 - 1
src/reducer/workspaceList.js Visa fil

3
   USER_ROLE
3
   USER_ROLE
4
 } from '../action-creator.sync.js'
4
 } from '../action-creator.sync.js'
5
 
5
 
6
+const handleRouteFromApi = route => route.startsWith('/#') ? route.slice(2) : route
7
+
6
 export function workspaceList (state = [], action) {
8
 export function workspaceList (state = [], action) {
7
   switch (action.type) {
9
   switch (action.type) {
8
     case `Update/${WORKSPACE_LIST}`:
10
     case `Update/${WORKSPACE_LIST}`:
13
         description: ws.description,
15
         description: ws.description,
14
         sidebarEntry: ws.sidebar_entries.map(sbe => ({
16
         sidebarEntry: ws.sidebar_entries.map(sbe => ({
15
           slug: sbe.slug,
17
           slug: sbe.slug,
16
-          route: sbe.route,
18
+          route: handleRouteFromApi(sbe.route),
17
           faIcon: sbe.fa_icon,
19
           faIcon: sbe.fa_icon,
18
           hexcolor: sbe.hexcolor,
20
           hexcolor: sbe.hexcolor,
19
           label: sbe.label
21
           label: sbe.label