focalboard/webapp/src/components/comment.tsx

59 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-10-24 20:37:09 +02:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {FC} from 'react'
2020-11-13 03:48:59 +01:00
import {injectIntl, IntlShape} from 'react-intl'
2020-10-24 20:37:09 +02:00
import {IBlock} from '../blocks/block'
2020-11-13 03:48:59 +01:00
import mutator from '../mutator'
import {Utils} from '../utils'
import IconButton from '../widgets/buttons/iconButton'
2020-10-30 18:31:40 +01:00
import DeleteIcon from '../widgets/icons/delete'
import OptionsIcon from '../widgets/icons/options'
2020-11-13 03:48:59 +01:00
import Menu from '../widgets/menu'
import MenuWrapper from '../widgets/menuWrapper'
2020-10-24 20:37:09 +02:00
import './comment.scss'
type Props = {
comment: IBlock
username: string
userImageUrl: string
intl: IntlShape
}
const Comment: FC<Props> = (props: Props) => {
const {comment, username, userImageUrl, intl} = props
2020-10-28 00:59:40 +01:00
const html = Utils.htmlFromMarkdown(comment.title)
2020-10-24 20:37:09 +02:00
return (
<div
key={comment.id}
className='Comment comment'
>
<div className='comment-header'>
<img
className='comment-avatar'
src={userImageUrl}
/>
<div className='comment-username'>{username}</div>
<div className='comment-date'>{(new Date(comment.createAt)).toLocaleTimeString()}</div>
<MenuWrapper>
<IconButton icon={<OptionsIcon/>}/>
2020-10-30 18:31:40 +01:00
<Menu position='left'>
2020-10-24 20:37:09 +02:00
<Menu.Text
2020-10-30 18:31:40 +01:00
icon={<DeleteIcon/>}
2020-10-24 20:37:09 +02:00
id='delete'
name={intl.formatMessage({id: 'Comment.delete', defaultMessage: 'Delete'})}
onClick={() => mutator.deleteBlock(comment)}
/>
</Menu>
</MenuWrapper>
</div>
2020-10-28 00:59:40 +01:00
<div
className='comment-text'
dangerouslySetInnerHTML={{__html: html}}
/>
2020-10-24 20:37:09 +02:00
</div>
)
}
export default injectIntl(Comment)