Browse Source

changed app api to properly separate config and data

Skylsmoi 6 years ago
parent
commit
a1ff330a97

+ 2 - 2
dist/index.html View File

@@ -44,7 +44,7 @@
44 44
       */
45 45
       GLOBAL_renderApp = app => {
46 46
         const selectedApp = (() => {
47
-          switch (app.appConfig.name) {
47
+          switch (app.config.name) {
48 48
             case 'PageHtml':
49 49
               return appPageHtml
50 50
             case 'Thread':
@@ -55,7 +55,7 @@
55 55
         if (selectedApp.isRendered) {
56 56
           GLOBAL_dispatchEvent(`${app.appConfig.name}_showApp`, app)
57 57
         } else {
58
-          selectedApp.renderApp('appContainer', app)
58
+          selectedApp.renderApp(app)
59 59
           selectedApp.isRendered = true
60 60
           prevSelectedApp.isRendered = false
61 61
           prevSelectedApp = selectedApp

+ 18 - 7
jsonserver/static_db.json View File

@@ -35,7 +35,8 @@
35 35
     "componentRight": "Timeline",
36 36
     "customClass": "wsContentPageHtml",
37 37
     "icon": "fa fa-fw fa-file-word-o",
38
-    "color": "#65c7f2"
38
+    "color": "#65c7f2",
39
+    "domContainer": "appContainer"
39 40
   }, {
40 41
     "name": "PageMarkdown",
41 42
     "label": {
@@ -46,7 +47,8 @@
46 47
     "componentRight": "undefined",
47 48
     "customClass": "wsContentPageMarkdown",
48 49
     "icon": "fa fa-fw fa-file-code-o",
49
-    "color": "#e0082b"
50
+    "color": "#e0082b",
51
+    "domContainer": "appContainer"
50 52
   }, {
51 53
     "name": "File",
52 54
     "label": {
@@ -57,7 +59,8 @@
57 59
     "componentRight": "undefined",
58 60
     "customClass": "wsContentFile",
59 61
     "icon": "fa fa-fw fa-file-text-o",
60
-    "color": "#263462"
62
+    "color": "#263462",
63
+    "domContainer": "appContainer"
61 64
   }, {
62 65
     "name": "Thread",
63 66
     "label": {
@@ -68,7 +71,8 @@
68 71
     "componentRight": "undefined",
69 72
     "customClass": "wsContentThread",
70 73
     "icon": "fa fa-fw fa-comments-o",
71
-    "color": "#2674d3"
74
+    "color": "#2674d3",
75
+    "domContainer": "appContainer"
72 76
   }, {
73 77
     "name": "Task",
74 78
     "label": {
@@ -79,7 +83,8 @@
79 83
     "componentRight": "undefined",
80 84
     "customClass": "wsContentTask",
81 85
     "icon": "fa fa-fw fa-list-ul",
82
-    "color": "#2d5a88"
86
+    "color": "#2d5a88",
87
+    "domContainer": "appContainer"
83 88
   }, {
84 89
     "name": "Issue",
85 90
     "label": {
@@ -90,7 +95,8 @@
90 95
     "componentRight": "undefined",
91 96
     "customClass": "wsContentIssue",
92 97
     "icon": "fa fa-fw fa-ticket",
93
-    "color": "#a4835e"
98
+    "color": "#a4835e",
99
+    "domContainer": "appContainer"
94 100
   }],
95 101
   "workspace_detail": {
96 102
     "id": 1,
@@ -257,7 +263,12 @@
257 263
     "title": "La programmation fonctionnelle",
258 264
     "status": "validated",
259 265
     "version": "3",
260
-    "text": "<h1>Mon titre nul</h1>Je suis le contenu de cette fameuse <b>page HTML</b><br /> sur la programmation fonctionnelle"
266
+    "text": "<h1>Mon titre nul</h1>Je suis le contenu de cette fameuse <b>page HTML</b><br /> sur la programmation fonctionnelle",
267
+    "workspace": {
268
+      "id": 1,
269
+      "title": "Mission interne - développement",
270
+      "owner_id": 5
271
+    }
261 272
   },
262 273
   "content_data_thread": {
263 274
     "id": 2,

+ 3 - 7
src/appFactory.js View File

@@ -3,14 +3,10 @@ import { FETCH_CONFIG } from './helper.js'
3 3
 
4 4
 export function appFactory (WrappedComponent) {
5 5
   return class AppFactory extends React.Component {
6
-    renderApp = (user, workspace, app, content) => GLOBAL_renderApp({
6
+    renderApp = (appConfig, user, content) => GLOBAL_renderApp({
7 7
       loggedUser: user.isLoggedIn ? user : {},
8
-      workspace: {
9
-        id: workspace.id,
10
-        title: workspace.title
11
-      },
12
-      appConfig: {
13
-        ...app[content.type],
8
+      config: {
9
+        ...appConfig,
14 10
         apiUrl: FETCH_CONFIG.apiUrl
15 11
       },
16 12
       content

+ 2 - 5
src/component/Account/PersonalData.jsx View File

@@ -13,18 +13,15 @@ export const PersonalData = props => {
13 13
 
14 14
       <div className='personaldata__form'>
15 15
         <div className='personaldata__form__title'>
16
-          Changer le mot de passe :
16
+          Mot de passe :
17 17
         </div>
18 18
         <input className='personaldata__form__txtinput form-control' type='password' placeholder='Ancien mot de passe' />
19 19
         <input className='personaldata__form__txtinput form-control' type='password' placeholder='Nouveau mot de passe' />
20
-        <div className='personaldata__form__button btn btn-primary'>
21
-          Envoyer
22
-        </div>
23 20
       </div>
24 21
 
25 22
       <div className='personaldata__form'>
26 23
         <div className='personaldata__form__title'>
27
-          Changer d'adresse mail :
24
+          Adresse mail :
28 25
         </div>
29 26
         <input className='personaldata__form__txtinput form-control' type='email' placeholder='Ancienne adresse mail' />
30 27
         <input className='personaldata__form__txtinput form-control' type='email' placeholder='Nouvelle adresse mail' />

+ 0 - 2
src/component/Workspace/Folder.jsx View File

@@ -4,8 +4,6 @@ import PropTypes from 'prop-types'
4 4
 import classnames from 'classnames'
5 5
 import FileItem from './FileItem.jsx'
6 6
 
7
-// @TODO set Folder as a component, state open will come from parent container (which will come from redux) // update: or not ?
8
-
9 7
 class Folder extends React.Component {
10 8
   constructor (props) {
11 9
     super(props)

+ 1 - 1
src/container/WorkspaceContent.jsx View File

@@ -38,7 +38,7 @@ class WorkspaceContent extends React.Component {
38 38
   }
39 39
 
40 40
   handleClickContentItem = content => {
41
-    this.props.renderApp(this.props.user, this.props.workspace, this.props.app, content)
41
+    this.props.renderApp(this.props.app[content.type], this.props.user, {...content, workspace: this.props.workspace})
42 42
     // Côme - 2018/03/08 - line bellow is useless because we cannot call the reducer again when hiding app since the call comes from the app
43 43
     // dispatch(setActiveFileContentActive(content))
44 44
   }

+ 3 - 3
src/css/Sidebar.styl View File

@@ -38,10 +38,10 @@ leftside()
38 38
       border-bottom-right-radius 0
39 39
   &__expand
40 40
     position absolute
41
-    top -1px
42
-    right -39px
41
+    top 1px
42
+    right -44px
43 43
     padding 5px 8px
44
-    border 1px solid white
44
+    border 3px solid transparent
45 45
     border-bottom-right-radius 15px
46 46
     cursor pointer
47 47
     background-color blue

+ 0 - 2
src/css/index.styl View File

@@ -18,12 +18,10 @@ html, body, #content
18 18
 @import 'FileItemHeader.styl'
19 19
 @import 'Folder.styl'
20 20
 
21
-@import 'Timeline.styl'
22 21
 @import 'File.styl'
23 22
 
24 23
 @import 'Dashboard.styl'
25 24
 @import 'AccountPage.styl'
26
-@import 'btnSwtich.styl'
27 25
 
28 26
 @import 'UploadPopup'
29 27
 @import 'ProgressBar'