| 
				
			 | 
			
			
				@@ -8,6 +8,7 @@ import PageTitle from '../component/common/layout/PageTitle.jsx' 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				 import PageContent from '../component/common/layout/PageContent.jsx' 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				 import DropdownCreateButton from '../component/common/Input/DropdownCreateButton.jsx' 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				 import { FETCH_CONFIG } from '../helper.js' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+import { setActiveFileContentActive } from '../action-creator.sync.js' 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				12
			 | 
			
			
				 import { 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				13
			 | 
			
			
				   getAppList, 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				14
			 | 
			
			
				   getWorkspaceContent 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -31,17 +32,20 @@ class WorkspaceContent extends React.Component { 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				32
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				33
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				33
			 | 
			
				34
			 | 
			
			
				   componentDidUpdate (prevProps) { 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-    const { workspaceList, match, dispatch } = this.props 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+    const { workspace, workspaceList, match, dispatch } = this.props 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				36
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-    if (prevProps.match.params.idws === match.params.idws) return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+    // if a workspace is already loaded and the idws in url hasn't changed, do nothing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+    if (workspace.id !== -1 && prevProps.match.params.idws === match.params.idws) return 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				39
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+    // if the idws in url has changed, load the new workspace 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				41
			 | 
			
			
				     if (match.params.idws !== undefined) dispatch(getWorkspaceContent(match.params.idws)) 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-    // else load first ws if none specified 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-    else if (match.params.idws === undefined && workspaceList.length > 0) dispatch(getWorkspaceContent(workspaceList[0].id)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+    // else bellow is for loading url PAGE_NAME.HOME (without an idws), when workspaceList is loaded, load the first workspace 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+    else if (match.params.idws === undefined && workspace.id === -1 && workspaceList.length > 0) dispatch(getWorkspaceContent(workspaceList[0].id)) 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				44
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				45
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				43
			 | 
			
				46
			 | 
			
			
				   handleClickContentItem = content => { 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-    const { user, workspace } = this.props 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+    const { user, workspace, dispatch } = this.props 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				49
			 | 
			
			
				     GLOBAL_renderApp({ 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				50
			 | 
			
			
				       workspace: { 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				51
			 | 
			
			
				         id: workspace.id, 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -54,6 +58,8 @@ class WorkspaceContent extends React.Component { 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				58
			 | 
			
			
				       loggedUser: user.isLoggedIn ? user : {}, 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				59
			 | 
			
			
				       content 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				60
			 | 
			
			
				     }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    dispatch(setActiveFileContentActive(content)) 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				63
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				64
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				59
			 | 
			
				65
			 | 
			
			
				   render () { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -99,5 +105,5 @@ class WorkspaceContent extends React.Component { 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				105
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				106
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				107
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-const mapStateToProps = ({ user, workspace, workspaceList, activeFileContent, app }) => ({ user, workspace, workspaceList, activeFileContent, app }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+const mapStateToProps = ({ user, workspace, workspaceList, app }) => ({ user, workspace, workspaceList, app }) 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				109
			 | 
			
			
				 export default connect(mapStateToProps)(WorkspaceContent) 
			 |