Browse Source

added translation + fixed WorkspaceContent async call

Skylsmoi 6 years ago
parent
commit
e29f67cd4e

+ 1 - 1
jsonserver/server.js View File

@@ -1,7 +1,7 @@
1 1
 const jsonServer = require('json-server')
2 2
 const jsonDb = require('./static_db.json')
3 3
 const server = jsonServer.create()
4
-const router = jsonServer.router() // for persistance : jsonServer.router('static_db.json')
4
+const router = jsonServer.router() // for persistence : jsonServer.router('static_db.json')
5 5
 const middlewares = jsonServer.defaults()
6 6
 const GLOBAL_PORT = 3001
7 7
 

+ 2 - 2
src/action-creator.sync.js View File

@@ -13,8 +13,8 @@ export const updateWorkspaceListData = workspaceList => ({ type: `Update/${WORKS
13 13
 export const setWorkspaceListIsOpen = (workspaceId, isOpen) => ({ type: `Set/${WORKSPACE_LIST}/isOpen`, workspaceId, isOpen })
14 14
 
15 15
 export const FILE_CONTENT = 'FileContent'
16
-export const setActiveFileContent = file => ({ type: `Set/${FILE_CONTENT}/Active`, file })
17
-export const hideActiveFileContent = () => ({ type: `Set/${FILE_CONTENT}/Hide` })
16
+export const setActiveFileContentActive = file => ({ type: `Set/${FILE_CONTENT}/Active`, file })
17
+export const setActiveFileContentHide = () => ({ type: `Set/${FILE_CONTENT}/Hide` })
18 18
 
19 19
 export const APP_LIST = 'App/List'
20 20
 export const setAppList = appList => ({ type: `Set/${APP_LIST}`, appList })

+ 2 - 2
src/app/ContentType/PageHtml/PageHtmlContainer.jsx View File

@@ -12,12 +12,12 @@ import {
12 12
 } from 'tracim_lib'
13 13
 import PageHtmlComponent from './PageHtmlComponent.jsx'
14 14
 import Timeline from '../../../component/Timeline.jsx'
15
-import { hideActiveFileContent } from '../../../action-creator.sync.js'
15
+import { setActiveFileContentHide } from '../../../action-creator.sync.js'
16 16
 
17 17
 require('./PageHtml.styl')
18 18
 
19 19
 class PageHtmlContainer extends React.Component {
20
-  handleClickBtnClose = () => this.props.dispatch(hideActiveFileContent())
20
+  handleClickBtnClose = () => this.props.dispatch(setActiveFileContentHide())
21 21
 
22 22
   render () {
23 23
     const { activeFileContent, app: { PageHtml } } = this.props

+ 4 - 3
src/component/Footer.jsx View File

@@ -1,14 +1,15 @@
1 1
 import React from 'react'
2
+import { translate } from 'react-i18next'
2 3
 import logoFooter from '../img/logoFooter.svg'
3 4
 
4
-const Footer = props => {
5
+const Footer = ({ t }) => {
5 6
   return (
6 7
     <footer className='footer text-right'>
7 8
       <div className='footer__text'>
8
-        Créer votre propre espace de travail collaboratif sur trac.im - Copyright 2013 - 2017
9
+        {t('Footer.marketing_msg')} - {t('Footer.copyright')}
9 10
       </div>
10 11
       <img className='footer__logo' src={logoFooter} />
11 12
     </footer>
12 13
   )
13 14
 }
14
-export default Footer
15
+export default translate()(Footer)

+ 1 - 1
src/component/Workspace/FileItemHeader.jsx View File

@@ -6,7 +6,7 @@ const FileItemHeader = props => {
6 6
     <div className='file__header'>
7 7
       <div className='col-2 col-sm-2 col-md-2 col-lg-2 col-xl-1'>
8 8
         <div className='file__header__type'>
9
-          Type
9
+          {props.t('FileItemHeader.type')}
10 10
         </div>
11 11
       </div>
12 12
       <div className='col-8 col-sm-8 col-md-8 col-lg-8 col-xl-10'>

+ 1 - 1
src/component/Workspace/Folder.jsx View File

@@ -44,7 +44,7 @@ class Folder extends React.Component {
44 44
           </div>
45 45
           <div className='folder__header__contenttype'>
46 46
             <div className='folder__header__contenttype__text'>
47
-              Type de Contenu :
47
+              {t('Folder.content_type')} :
48 48
             </div>
49 49
             <div className='folder__header__contenttype__icon'>
50 50
               <i className='fa fa-list-ul' />

+ 12 - 6
src/container/WorkspaceContent.jsx View File

@@ -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)

+ 1 - 4
src/reducer/activeFileContent.js View File

@@ -8,10 +8,7 @@ export default function activeFileContent (state = {
8 8
 }, action) {
9 9
   switch (action.type) {
10 10
     case `Set/${FILE_CONTENT}/Active`:
11
-      return {
12
-        display: true,
13
-        ...action.file
14
-      }
11
+      return {...action.file, display: true}
15 12
 
16 13
     case `Set/${FILE_CONTENT}/Hide`:
17 14
       return {...state, display: false}

+ 1 - 1
src/reducer/workspace.js View File

@@ -8,7 +8,7 @@ const serializeWorkspace = data => ({
8 8
 })
9 9
 
10 10
 export default function user (state = {
11
-  id: 0,
11
+  id: -1,
12 12
   title: '',
13 13
   ownerId: '',
14 14
   content: []

+ 7 - 1
src/translate/en.js View File

@@ -3,12 +3,18 @@ const en = {
3 3
     Header: {
4 4
       Search: 'Search'
5 5
     },
6
+    Footer: {
7
+      marketing_msg: 'Create your own collaborative workspaces on trac.im',
8
+      copyright: 'Copyright 2013 - 2017'
9
+    },
6 10
     FileItemHeader: {
11
+      type: 'Type',
7 12
       document_name: "Document's name",
8 13
       status: 'Status'
9 14
     },
10 15
     Folder: {
11
-      create: 'Create'
16
+      create: 'Create',
17
+      content_type: 'Content type'
12 18
     }
13 19
   }
14 20
 }

+ 8 - 2
src/translate/fr.js View File

@@ -3,12 +3,18 @@ const fr = {
3 3
     Header: {
4 4
       Search: 'Rechercher'
5 5
     },
6
+    Footer: {
7
+      marketing_msg: 'Créer votre propre espace de travail collaboratif sur trac.im',
8
+      copyright: 'Copyright 2013 - 2017'
9
+    },
6 10
     FileItemHeader: {
11
+      type: 'Type',
7 12
       document_name: 'Nom du document',
8
-      status: 'Status'
13
+      status: 'Statut'
9 14
     },
10 15
     Folder: {
11
-      create: 'Créer'
16
+      create: 'Créer',
17
+      content_type: 'Type de contenu'
12 18
     }
13 19
   }
14 20
 }