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 ConfigStore from 'sentry/stores/configStore'; import type {Group, GroupActivity, User} from 'sentry/types'; import type {NoteType} from 'sentry/types/alerts'; import {GroupActivityType} from 'sentry/types/group'; import {uniqueId} from 'sentry/utils/guid'; import useOrganization from 'sentry/utils/useOrganization'; 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 = ConfigStore.get('user'); const projectSlugs = group?.project ? [group.project.slug] : []; const noteProps = { minHeight: 140, group, projectSlugs, placeholder: placeholderText, }; return ( { onCreate(n, me); setInputId(uniqueId()); }} {...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} /> ); } if ( item.type === GroupActivityType.SET_PRIORITY && !organization.features.includes('issue-priority-ui') ) { return null; } return ( {authorName}} activity={item} organization={organization} projectId={group.project.id} group={group} /> } /> ); })} ); } export default ActivitySection;