import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import Radium from 'radium'
import color from 'color'
import Comment from './Comment.jsx'
import Revision from './Revision.jsx'
import { translate } from 'react-i18next'
require('./Timeline.styl')
class Timeline extends React.Component {
componentDidMount () {
this.scrollToBottom()
}
componentDidUpdate () {
this.props.shouldScrollToBottom && 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 (
{props.showHeader &&
{this.props.t('Timeline')}
}
{props.isArchived &&
{this.props.t('This content is archived.')}
}
{props.isDeleted &&
{this.props.t('This content is deleted.')}
}
{props.timelineData.map(content => {
switch (content.timelineType) {
case 'comment':
return
case 'revision':
return props.onClickRevisionBtn(content)}
/>
}
})}
- { this.timelineBottom = el }} />
{props.loggedUser.idRoleUserWorkspace >= 2 &&
}
)
}
}
export default Radium(translate()(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,
customColor: PropTypes.string,
loggedUser: PropTypes.object,
wysiwyg: PropTypes.bool,
onClickWysiwygBtn: PropTypes.func,
onClickRevisionBtn: PropTypes.func,
shouldScrollToBottom: PropTypes.bool,
showHeader: PropTypes.bool,
rightPartOpen: PropTypes.bool, // irrelevant if showHeader is false
isArchived: PropTypes.bool,
onClickRestoreArchived: PropTypes.func,
isDeleted: PropTypes.bool,
onClickRestoreDeleted: PropTypes.func
}
Timeline.defaultProps = {
disableComment: false,
customClass: '',
customColor: '',
loggedUser: {
id: '',
name: '',
avatar: '',
idRoleUserWorkspace: 1
},
timelineData: [],
wysiwyg: false,
onClickWysiwygBtn: () => {},
shouldScrollToBottom: true,
showHeader: true,
rightPartOpen: false,
isArchived: false,
isDeleted: false
}