import Button from '@app/components/Common/Button'; import { Permission, useUser } from '@app/hooks/useUser'; import globalMessages from '@app/i18n/globalMessages'; import { Menu, Transition } from '@headlessui/react'; import { DotsVerticalIcon } from '@heroicons/react/solid'; import { Field, Form, Formik } from 'formik'; import { useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import ReactMarkdown from 'react-markdown'; const messages = defineMessages({ description: 'Description', edit: 'Edit Description', deleteissue: 'Delete Issue', }); interface IssueDescriptionProps { description: string; belongsToUser: boolean; commentCount: number; onEdit: (newDescription: string) => void; onDelete: () => void; } const IssueDescription = ({ description, belongsToUser, commentCount, onEdit, onDelete, }: IssueDescriptionProps) => { const intl = useIntl(); const { hasPermission } = useUser(); const [isEditing, setIsEditing] = useState(false); return (
{intl.formatMessage(messages.description)}
{(hasPermission(Permission.MANAGE_ISSUES) || belongsToUser) && ( {({ open }) => ( <>
Open options
{belongsToUser && ( {({ active }) => ( )} )} {(hasPermission(Permission.MANAGE_ISSUES) || !commentCount) && ( {({ active }) => ( )} )}
)}
)}
{isEditing ? ( { onEdit(values.newMessage); setIsEditing(false); }} > {() => { return (
); }}
) : (
{description}
)}
); }; export default IssueDescription;