Browse Source

app api is now more generic

Skylsmoi 7 years ago
parent
commit
131b8b4b7c
3 changed files with 29 additions and 21 deletions
  1. 26 18
      src/container/PageHtml.jsx
  2. 1 1
      src/css/index.styl
  3. 2 2
      src/index.js

+ 26 - 18
src/container/PageHtml.jsx View File

13
 import i18n from '../i18n.js'
13
 import i18n from '../i18n.js'
14
 
14
 
15
 const debug = {
15
 const debug = {
16
-  workspace: {
17
-    id: -1,
18
-    title: 'Test debug workspace'
19
-  },
20
-  appConfig: {
16
+  config: {
21
     name: 'PageHtml',
17
     name: 'PageHtml',
18
+    label: {
19
+      fr: 'Page Html',
20
+      en: 'Html page'
21
+    },
22
+    componentLeft: 'PageHtml',
23
+    componentRight: 'Timeline',
22
     customClass: 'wsContentPageHtml',
24
     customClass: 'wsContentPageHtml',
23
     icon: 'fa fa-file-word-o',
25
     icon: 'fa fa-file-word-o',
26
+    color: '#65c7f2',
27
+    domContainer: 'appContainer',
24
     apiUrl: 'http://localhost:3001'
28
     apiUrl: 'http://localhost:3001'
25
   },
29
   },
26
   loggedUser: {
30
   loggedUser: {
37
     title: 'Test debug pageHtml',
41
     title: 'Test debug pageHtml',
38
     status: 'validated',
42
     status: 'validated',
39
     version: '-1',
43
     version: '-1',
40
-    text: 'This is the default pageHtml content for debug purpose'
44
+    text: 'This is the default pageHtml content for debug purpose',
45
+    workspace: {
46
+      id: -1,
47
+      title: 'Test debug workspace',
48
+      ownerId: 5
49
+    }
41
   },
50
   },
42
   timeline: timelineDebugData
51
   timeline: timelineDebugData
43
 }
52
 }
48
     this.state = {
57
     this.state = {
49
       appName: 'PageHtml',
58
       appName: 'PageHtml',
50
       isVisible: true,
59
       isVisible: true,
51
-      workspace: props.data ? props.data.workspace : debug.workspace,
52
-      appConfig: props.data ? props.data.appConfig : debug.appConfig,
60
+      config: props.data ? props.data.config : debug.config,
53
       loggedUser: props.data ? props.data.loggedUser : debug.loggedUser,
61
       loggedUser: props.data ? props.data.loggedUser : debug.loggedUser,
54
       content: props.data ? props.data.content : debug.content,
62
       content: props.data ? props.data.content : debug.content,
55
       timeline: props.data ? [] : debug.timeline
63
       timeline: props.data ? [] : debug.timeline
70
   }
78
   }
71
 
79
 
72
   async componentDidMount () {
80
   async componentDidMount () {
73
-    const { workspace, content, appConfig } = this.state
81
+    const { content, config } = this.state
74
     if (content.id === '-1') return // debug case
82
     if (content.id === '-1') return // debug case
75
 
83
 
76
-    const fetchResultPageHtml = await fetch(`${appConfig.apiUrl}/workspace/${workspace.id}/content/${content.id}`, {
84
+    const fetchResultPageHtml = await fetch(`${config.apiUrl}/workspace/${content.workspace.id}/content/${content.id}`, {
77
       ...FETCH_CONFIG,
85
       ...FETCH_CONFIG,
78
       method: 'GET'
86
       method: 'GET'
79
     })
87
     })
80
-    const fetchResultTimeline = await fetch(`${appConfig.apiUrl}/workspace/${workspace.id}/content/${content.id}/timeline`, {
88
+    const fetchResultTimeline = await fetch(`${config.apiUrl}/workspace/${content.workspace.id}/content/${content.id}/timeline`, {
81
       ...FETCH_CONFIG,
89
       ...FETCH_CONFIG,
82
       method: 'GET'
90
       method: 'GET'
83
     })
91
     })
96
   }
104
   }
97
 
105
 
98
   render () {
106
   render () {
99
-    const { isVisible, loggedUser, content, timeline, appConfig } = this.state
107
+    const { isVisible, loggedUser, content, timeline, config } = this.state
100
 
108
 
101
     if (!isVisible) return null
109
     if (!isVisible) return null
102
 
110
 
103
     return (
111
     return (
104
-      <PopinFixed customClass={`${appConfig.customClass}`}>
112
+      <PopinFixed customClass={`${config.customClass}`}>
105
         <PopinFixedHeader
113
         <PopinFixedHeader
106
-          customClass={`${appConfig.customClass}`}
107
-          icon={appConfig.icon}
114
+          customClass={`${config.customClass}`}
115
+          icon={config.icon}
108
           name={content.title}
116
           name={content.title}
109
           onClickCloseBtn={this.handleClickBtnCloseApp}
117
           onClickCloseBtn={this.handleClickBtnCloseApp}
110
         />
118
         />
111
 
119
 
112
-        <PopinFixedOption customClass={`${appConfig.customClass}`} i18n={i18n} />
120
+        <PopinFixedOption customClass={`${config.customClass}`} i18n={i18n} />
113
 
121
 
114
-        <PopinFixedContent customClass={`${appConfig.customClass}__contentpage`}>
122
+        <PopinFixedContent customClass={`${config.customClass}__contentpage`}>
115
           <PageHtmlComponent
123
           <PageHtmlComponent
116
             version={content.version}
124
             version={content.version}
117
             text={content.text}
125
             text={content.text}
119
           />
127
           />
120
 
128
 
121
           <Timeline
129
           <Timeline
122
-            customClass={`${appConfig.customClass}__contentpage`}
130
+            customClass={`${config.customClass}__contentpage`}
123
             loggedUser={loggedUser}
131
             loggedUser={loggedUser}
124
             timelineData={timeline}
132
             timelineData={timeline}
125
           />
133
           />

+ 1 - 1
src/css/index.styl View File

23
       &__edition
23
       &__edition
24
         display none
24
         display none
25
     &__messagelist
25
     &__messagelist
26
-      min-height 300px
26
+      // min-height 300px
27
       &__item
27
       &__item
28
         &__content
28
         &__content
29
           color darkGrey
29
           color darkGrey

+ 2 - 2
src/index.js View File

7
 const appInterface = {
7
 const appInterface = {
8
   name: 'PageHtml',
8
   name: 'PageHtml',
9
   isRendered: false,
9
   isRendered: false,
10
-  renderApp: (domId, data) => {
10
+  renderApp: data => {
11
     return ReactDOM.render(
11
     return ReactDOM.render(
12
       <PageHtml data={data} />
12
       <PageHtml data={data} />
13
-      , document.getElementById(domId)
13
+      , document.getElementById(data.config.domContainer)
14
     )
14
     )
15
   },
15
   },
16
   hideApp: domId => {
16
   hideApp: domId => {