import {Fragment, useState} from 'react'; import {ActivityAuthor} from 'sentry/components/activity/author'; import {ActivityItem} from 'sentry/components/activity/item'; import {Note} from 'sentry/components/activity/note'; import {NoteInputWithStorage} from 'sentry/components/activity/note/inputWithStorage'; import ErrorBoundary from 'sentry/components/errorBoundary'; import type {NoteType} from 'sentry/types/alerts'; import type {Group, GroupActivity} from 'sentry/types/group'; import {GroupActivityType} from 'sentry/types/group'; import type {User} from 'sentry/types/user'; import {uniqueId} from 'sentry/utils/guid'; import useOrganization from 'sentry/utils/useOrganization'; import {useUser} from 'sentry/utils/useUser'; import GroupActivityItem from 'sentry/views/issueDetails/groupActivityItem'; type Props = { group: Group; onCreate: (n: NoteType, me: User) => void; onDelete: (item: GroupActivity) => void; onUpdate: (item: GroupActivity, n: NoteType) => void; placeholderText: string; }; function ActivitySection(props: Props) { const {group, placeholderText, onCreate, onDelete, onUpdate} = props; const organization = useOrganization(); const [inputId, setInputId] = useState(uniqueId()); const me = useUser(); const projectSlugs = group?.project ? [group.project.slug] : []; const noteProps = { minHeight: 140, group, projectSlugs, placeholder: placeholderText, }; return ( { onCreate(n, me); setInputId(uniqueId()); }} source="activity" {...noteProps} /> {group.activity.map(item => { const authorName = item.user ? item.user.name : 'Sentry'; if (item.type === GroupActivityType.NOTE) { return ( onDelete(item)} onUpdate={n => { item.data.text = n.text; onUpdate(item, n); }} {...noteProps} /> ); } return ( {authorName}} activity={item} organization={organization} projectId={group.project.id} group={group} /> } /> ); })} ); } export default ActivitySection;