import React from 'react'; import moment from 'moment'; import {TextWithMentions} from 'apps/users/components'; import CommentTextArea from './CommentTextArea'; import PropTypes from 'prop-types'; import {UserAvatarFromUserId} from 'apps/users/components/UserAvatarFromUserId'; import {EditorHighlightsHeader} from 'core/editor3/editorPopup/EditorHighlightsHeader'; import {FluidRows} from '../../fluid-flex-rows/fluid-rows'; import {FluidRow} from '../../fluid-flex-rows/fluid-row'; import {gettext} from 'core/utils'; /** * @ngdoc React * @module superdesk.core.editor3 * @name Comment * @description Comment is a component that displays the author information along with the timestamp * and the body of that comment. It is also used for displaying replies and can take an * additional class. */ export class Comment extends React.Component { static propTypes: any; static defaultProps: any; constructor(props) { super(props); this.state = { actionsDropdownOpen: false, editMode: false, editModeValue: this.props.data.msg, }; } cancelEditing(event?) { this.setState({ editMode: false, editModeValue: this.props.data.msg, }); } toggleActionsDropdown() { this.setState({ actionsDropdownOpen: !this.state.actionsDropdownOpen, }); } render() { const {onRemove, isAuthor, isReply} = this.props; const {author, authorId, date} = this.props.data; const absoluteDateString = moment(date).format('MMMM Do YYYY, h:mm:ss a'); const relativeDateString = moment(date).calendar(); const isRoot = this.props.isReply === false; const availableActions = isAuthor !== true ? [] : [ { text: gettext('Edit'), icon: 'icon-pencil', onClick: () => this.setState({editMode: true}), }, { text: gettext('Delete'), icon: 'icon-trash', onClick: onRemove, }, ]; return (

{author}

{ isReply !== false ? null : (
{gettext('Comment')} {this.props.inlineActions || null}
) }
{ this.state.editMode === true ? (
this.setState({editModeValue: value})} singleLine={false} maxHeight={isRoot === true ? 300 : undefined} />
) : ( {this.props.data.msg} ) }
{ this.props.scrollableContent == null ? null : ( {this.props.scrollableContent} ) } { this.props.stickyFooter == null ? null : (
{this.props.stickyFooter}
) }
); } } Comment.propTypes = { data: PropTypes.shape({ author: PropTypes.string, date: PropTypes.any, avatar: PropTypes.string, msg: PropTypes.string, }), onClick: PropTypes.func, inlineActions: PropTypes.object, replies: PropTypes.object, className: PropTypes.string, updateComment: PropTypes.func.isRequired, onRemove: PropTypes.func, isAuthor: PropTypes.bool.isRequired, isReply: PropTypes.bool.isRequired, position: PropTypes.func, editorNode: PropTypes.object, scrollableContent: PropTypes.object, stickyFooter: PropTypes.object, };