diff --git a/webapp/src/components/cardDetail.tsx b/webapp/src/components/cardDetail.tsx index 0dc410ae1..c356c9aba 100644 --- a/webapp/src/components/cardDetail.tsx +++ b/webapp/src/components/cardDetail.tsx @@ -16,9 +16,12 @@ import {OctoUtils} from '../octoUtils' import {PropertyMenu} from '../propertyMenu' import {Utils} from '../utils' +import Menu from '../widgets/menu' +import MenuWrapper from '../widgets/menuWrapper' import Button from './button' import {Editable} from './editable' import {MarkdownEditor} from './markdownEditor' +import Comment from './comment' type Props = { boardTree: BoardTree @@ -262,52 +265,14 @@ export default class CardDetail extends React.Component {
- {comments.map((comment) => { - const optionsButtonRef = React.createRef() - const showCommentMenu = (e: React.MouseEvent, activeComment: IBlock) => { - OldMenu.shared.options = [ - {id: 'delete', name: 'Delete'}, - ] - OldMenu.shared.onMenuClicked = (id) => { - switch (id) { - case 'delete': { - mutator.deleteBlock(activeComment) - break - } - } - } - OldMenu.shared.showAtElement(e.target as HTMLElement) - } - - return (
( + { - optionsButtonRef.current.style.display = null - }} - onMouseLeave={() => { - optionsButtonRef.current.style.display = 'none' - }} - > -
- -
{username}
-
{(new Date(comment.createAt)).toLocaleTimeString()}
-
{ - showCommentMenu(e, comment) - }} - >...
-
-
{comment.title}
-
) - })} + comment={comment} + userImageUrl={userImageUrl} + username={username} + /> + ))} {/* New comment */} diff --git a/webapp/src/components/comment.scss b/webapp/src/components/comment.scss new file mode 100644 index 000000000..7689e6738 --- /dev/null +++ b/webapp/src/components/comment.scss @@ -0,0 +1,12 @@ +.Comment { + .MenuWrapper { + display: none; + position: absolute; + right: 0; + } + &:hover { + .MenuWrapper { + display: block; + } + } +} diff --git a/webapp/src/components/comment.tsx b/webapp/src/components/comment.tsx new file mode 100644 index 000000000..649eda969 --- /dev/null +++ b/webapp/src/components/comment.tsx @@ -0,0 +1,51 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. +import React, {FC} from 'react' +import {IntlShape, injectIntl} from 'react-intl' + +import mutator from '../mutator' +import {IBlock} from '../blocks/block' + +import Menu from '../widgets/menu' +import MenuWrapper from '../widgets/menuWrapper' + +import './comment.scss' + +type Props = { + comment: IBlock + username: string + userImageUrl: string + intl: IntlShape +} + +const Comment: FC = (props: Props) => { + const {comment, username, userImageUrl, intl} = props + return ( +
+
+ +
{username}
+
{(new Date(comment.createAt)).toLocaleTimeString()}
+ +
{'...'}
+ + mutator.deleteBlock(comment)} + /> + +
+
+
{comment.title}
+
+ ) +} + +export default injectIntl(Comment)