|
@@ -4,21 +4,22 @@ import classnames from 'classnames'
|
4
|
4
|
|
5
|
5
|
require('./Timeline.styl')
|
6
|
6
|
|
7
|
|
-const Message = props => (
|
8
|
|
- <li className={classnames(
|
9
|
|
- `${props.customClass}__messagelist__item`,
|
10
|
|
- 'timeline__messagelist__item',
|
11
|
|
- {
|
12
|
|
- 'sended': props.fromMe,
|
13
|
|
- 'received': !props.fromMe
|
14
|
|
- }
|
15
|
|
- )}>
|
|
7
|
+const Comment = props => (
|
|
8
|
+ <li
|
|
9
|
+ className={classnames(
|
|
10
|
+ `${props.customClass}__messagelist__item`,
|
|
11
|
+ 'timeline__messagelist__item', {
|
|
12
|
+ 'sended': props.fromMe,
|
|
13
|
+ 'received': !props.fromMe
|
|
14
|
+ }
|
|
15
|
+ )}
|
|
16
|
+ >
|
16
|
17
|
<div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
17
|
|
- <img src={props.avatar} alt='avatar' />
|
|
18
|
+ {props.avatar ? <img src={props.avatar} /> : ''}
|
18
|
19
|
</div>
|
19
|
20
|
<div
|
20
|
21
|
className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
21
|
|
- {props.createdAt.day} à {props.createdAt.hour}
|
|
22
|
+ {props.createdAt}
|
22
|
23
|
</div>
|
23
|
24
|
<div
|
24
|
25
|
className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
|
@@ -27,19 +28,24 @@ const Message = props => (
|
27
|
28
|
</li>
|
28
|
29
|
)
|
29
|
30
|
|
30
|
|
-const Version = props => (
|
31
|
|
- <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__messagelist__version')}>
|
|
31
|
+const Revision = props => (
|
|
32
|
+ <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__messagelist__version')} >
|
32
|
33
|
<div className={classnames(`${props.customClass}__messagelist__version__btn`, 'timeline__messagelist__version__btn btn')}>
|
33
|
34
|
<i className='fa fa-code-fork' />
|
34
|
35
|
version {props.number}
|
35
|
36
|
</div>
|
36
|
37
|
<div className={classnames(`${props.customClass}__messagelist__version__date`, 'timeline__messagelist__version__date')}>
|
37
|
|
- Créer le {props.createdAt.day}
|
|
38
|
+ Créer le {props.createdAt}
|
38
|
39
|
</div>
|
39
|
40
|
</li>
|
40
|
41
|
)
|
41
|
42
|
|
42
|
43
|
const Timeline = props => {
|
|
44
|
+ if (!Array.isArray(props.timelineData)) {
|
|
45
|
+ console.log('Error in Timeline.jsx, props.timelineData is not an array. timelineData: ', props.timelineData)
|
|
46
|
+ return null
|
|
47
|
+ }
|
|
48
|
+
|
43
|
49
|
return (
|
44
|
50
|
<div className='timeline'>
|
45
|
51
|
<div className={classnames(`${props.customClass}__header`, 'timeline__header')}>
|
|
@@ -48,23 +54,23 @@ const Timeline = props => {
|
48
|
54
|
|
49
|
55
|
<ul className={classnames(`${props.customClass}__messagelist`, 'timeline__messagelist')}>
|
50
|
56
|
{ props.timelineData.map(content => {
|
51
|
|
- switch (content.type) {
|
52
|
|
- case 'message':
|
53
|
|
- return <Message
|
|
57
|
+ switch (content.timelineType) {
|
|
58
|
+ case 'comment':
|
|
59
|
+ return <Comment
|
54
|
60
|
customClass={props.customClass}
|
55
|
|
- avatar={content.author.avatar}
|
56
|
|
- createdAt={content.createdAt}
|
57
|
|
- text={content.text}
|
58
|
|
- fromMe={props.loggedUser.id === content.author.id}
|
59
|
|
- key={content.id}
|
|
61
|
+ avatar={content.author.avatar_url}
|
|
62
|
+ createdAt={content.created}
|
|
63
|
+ text={content.raw_content}
|
|
64
|
+ fromMe={props.loggedUser.user_id === content.author.user_id}
|
|
65
|
+ key={`comment_${content.content_id}`}
|
60
|
66
|
/>
|
61
|
67
|
|
62
|
|
- case 'version':
|
63
|
|
- return <Version
|
|
68
|
+ case 'revision':
|
|
69
|
+ return <Revision
|
64
|
70
|
customClass={props.customClass}
|
65
|
|
- createdAt={content.createdAt}
|
66
|
|
- number={content.number}
|
67
|
|
- key={content.id}
|
|
71
|
+ createdAt={content.created}
|
|
72
|
+ number={content.revision_id}
|
|
73
|
+ key={`revision_${content.revision_id}`}
|
68
|
74
|
/>
|
69
|
75
|
}
|
70
|
76
|
})}
|
|
@@ -73,7 +79,11 @@ const Timeline = props => {
|
73
|
79
|
<form className={classnames(`${props.customClass}__texteditor`, 'timeline__texteditor d-flex align-items-center justify-content-between flex-wrap')}>
|
74
|
80
|
|
75
|
81
|
<div className={classnames(`${props.customClass}__texteditor__textinput`, 'timeline__texteditor__textinput')}>
|
76
|
|
- <textarea placeholder='Taper votre message ici' />
|
|
82
|
+ <textarea
|
|
83
|
+ placeholder='Taper votre message ici'
|
|
84
|
+ value={props.newComment}
|
|
85
|
+ onChange={props.onChangeNewComment}
|
|
86
|
+ />
|
77
|
87
|
</div>
|
78
|
88
|
|
79
|
89
|
<div className={classnames(`${props.customClass}__texteditor__wrapper`, 'timeline__texteditor__wrapper')}>
|
|
@@ -86,8 +96,9 @@ const Timeline = props => {
|
86
|
96
|
|
87
|
97
|
<div className={classnames(`${props.customClass}__texteditor__submit`, 'timeline__texteditor__submit mb-2')}>
|
88
|
98
|
<button
|
89
|
|
- type='submit'
|
|
99
|
+ type='button'
|
90
|
100
|
className={classnames(`${props.customClass}__texteditor__submit__btn`, 'timeline__texteditor__submit__btn btn')}
|
|
101
|
+ onClick={props.onClickValidateNewCommentBtn}
|
91
|
102
|
>
|
92
|
103
|
Envoyer
|
93
|
104
|
<div className={classnames(`${props.customClass}__texteditor__submit__btn__icon`, 'timeline__texteditor__submit__btn__icon')}>
|
|
@@ -105,9 +116,12 @@ const Timeline = props => {
|
105
|
116
|
export default Timeline
|
106
|
117
|
|
107
|
118
|
Timeline.propTypes = {
|
|
119
|
+ timelineData: PropTypes.array.isRequired,
|
|
120
|
+ newComment: PropTypes.string.isRequired,
|
|
121
|
+ onChangeNewComment: PropTypes.func.isRequired,
|
|
122
|
+ onClickValidateNewCommentBtn: PropTypes.func.isRequired,
|
108
|
123
|
customClass: PropTypes.string,
|
109
|
|
- loggedUser: PropTypes.object,
|
110
|
|
- timelineData: PropTypes.array
|
|
124
|
+ loggedUser: PropTypes.object
|
111
|
125
|
}
|
112
|
126
|
|
113
|
127
|
Timeline.defaultProps = {
|