Browse Source

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

Skylsmoi 5 years ago
parent
commit
9f00d1ec15
4 changed files with 14 additions and 3 deletions
  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 View File

@@ -78,7 +78,12 @@
78 78
 
79 79
         switch (type) {
80 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 87
             break
83 88
         }
84 89
       }

+ 1 - 1
src/appFactory.js View File

@@ -28,7 +28,7 @@ export function appFactory (WrappedComponent) {
28 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 33
     render () {
34 34
       return (

+ 4 - 0
src/container/WorkspaceContent.jsx View File

@@ -123,6 +123,10 @@ class WorkspaceContent extends React.Component {
123 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 130
   handleClickContentItem = content => {
127 131
     console.log('content clicked', content)
128 132
     this.props.history.push(`/workspaces/${content.idWorkspace}/${content.type}/${content.id}`)

+ 3 - 1
src/reducer/workspaceList.js View File

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