import {useEffect} from 'react'; import styled from '@emotion/styled'; import ActorAvatar from 'sentry/components/avatar/actorAvatar'; import Count from 'sentry/components/count'; import {QuickContextCommitRow} from 'sentry/components/discover/quickContextCommitRow'; import {EventCause, StyledPanel} from 'sentry/components/events/eventCause'; import {CauseHeader, DataSection} from 'sentry/components/events/styles'; import {getAssignedToDisplayName} from 'sentry/components/group/assignedTo'; import Panel from 'sentry/components/panels/panel'; import {IconWrapper} from 'sentry/components/sidebarSection'; import * as SidebarSection from 'sentry/components/sidebarSection'; import {Tooltip} from 'sentry/components/tooltip'; import {IconCheckmark, IconMute, IconNot, IconUser} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {Event, Group} from 'sentry/types'; import {trackAnalytics} from 'sentry/utils/analytics'; import {useApiQuery} from 'sentry/utils/queryClient'; import {NoContext} from './quickContextWrapper'; import { ContextBody, ContextContainer, ContextHeader, ContextRow, ContextTitle, Wrapper, } from './styles'; import {BaseContextProps, ContextType, tenSecondInMs} from './utils'; function IssueContext(props: BaseContextProps) { const {dataRow, organization} = props; useEffect(() => { trackAnalytics('discover_v2.quick_context_hover_contexts', { organization, contextType: ContextType.ISSUE, }); }, [organization]); const { isLoading: issueLoading, isError: issueError, data: issue, } = useApiQuery( [ `/issues/${dataRow['issue.id']}/`, { query: { collapse: 'release', expand: 'inbox', }, }, ], { staleTime: tenSecondInMs, } ); // NOTE: Suspect commits are generated from the first event of an issue. // Therefore, all events for an issue have the same suspect commits. const { isLoading: eventLoading, isError: eventError, data: event, } = useApiQuery([`/issues/${dataRow['issue.id']}/events/oldest/`], { staleTime: tenSecondInMs, }); const title = issue?.title; const renderTitle = () => issue && ( {t('Title')} {title} ); const renderStatusAndCounts = () => issue && (
{t('Events')}
{t('Users')}
{t('Issue Status')} {issue.status === 'ignored' ? ( ) : issue.status === 'resolved' ? ( ) : ( )} {issue.status}
); const renderAssignee = () => issue && ( {t('Assigned To')} {issue.assignedTo ? ( ) : ( )} {getAssignedToDisplayName(issue)} ); const renderSuspectCommits = () => event && event.eventID && issue && ( ); const isLoading = issueLoading || eventLoading; const isError = issueError || eventError; if (isLoading || isError) { return ; } return ( {renderTitle()} {renderStatusAndCounts()} {renderAssignee()} {renderSuspectCommits()} ); } const SuspectCommitsContainer = styled(ContextContainer)` ${SidebarSection.Wrap}, ${Panel}, h6 { margin: 0; } ${StyledPanel} { border: none; box-shadow: none; } ${DataSection} { padding: 0; } ${CauseHeader} { margin: ${space(2)} 0 ${space(0.75)}; } `; const IssueTitleBody = styled(ContextBody)` margin: 0; max-width: 300px; ${p => p.theme.overflowEllipsis} `; const IssueContextContainer = styled(ContextContainer)` & + & { margin-top: ${space(2)}; } `; const StatusText = styled('span')` margin-left: ${space(0.5)}; text-transform: capitalize; `; const AssignedToBody = styled(ContextBody)` gap: ${space(1)}; `; const StyledIconWrapper = styled(IconWrapper)` margin: 0; `; export default IssueContext;