import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import Comment from './Comment.jsx'
import Revision from './Revision.jsx'
require('./Timeline.styl')
class Timeline extends React.Component {
componentDidMount () {
this.scrollToBottom()
}
componentDidUpdate () {
this.scrollToBottom()
}
scrollToBottom = () => this.timelineBottom.scrollIntoView({behavior: 'instant'})
render () {
const { props } = this
if (!Array.isArray(props.timelineData)) {
console.log('Error in Timeline.jsx, props.timelineData is not an array. timelineData: ', props.timelineData)
return null
}
return (
Timeline
{props.timelineData.map(content => {
switch (content.timelineType) {
case 'comment':
return
case 'revision':
return props.onClickRevisionBtn(content)}
/>
}
})}
- { this.timelineBottom = el }} />
)
}
}
export default Timeline
Timeline.propTypes = {
timelineData: PropTypes.array.isRequired,
newComment: PropTypes.string.isRequired,
onChangeNewComment: PropTypes.func.isRequired,
onClickValidateNewCommentBtn: PropTypes.func.isRequired,
disableComment: PropTypes.bool,
customClass: PropTypes.string,
loggedUser: PropTypes.object,
wysiwyg: PropTypes.bool,
onClickWysiwygBtn: PropTypes.func,
onClickRevisionBtn: PropTypes.func
}
Timeline.defaultProps = {
disableComment: false,
customClass: '',
loggedUser: {
id: '',
name: '',
avatar: ''
},
timelineData: [],
wysiwyg: false,
onClickWysiwygBtn: () => {}
}