import {useEffect} from 'react'; import styled from '@emotion/styled'; import ActorAvatar from 'sentry/components/avatar/actorAvatar'; import Count from 'sentry/components/count'; import {getAssignedToDisplayName} from 'sentry/components/group/assignedTo'; import {IconWrapper} 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 type {Group} from 'sentry/types/group'; import {trackAnalytics} from 'sentry/utils/analytics'; import {useApiQuery} from 'sentry/utils/queryClient'; import {makeFetchGroupQueryKey} from 'sentry/views/issueDetails/useGroup'; import {NoContext} from './quickContextWrapper'; import { ContextBody, ContextContainer, ContextHeader, ContextRow, ContextTitle, Wrapper, } from './styles'; import type {BaseContextProps} from './utils'; import {ContextType} from './utils'; function IssueContext(props: BaseContextProps) { const {dataRow, organization} = props; useEffect(() => { trackAnalytics('discover_v2.quick_context_hover_contexts', { organization, contextType: ContextType.ISSUE, }); }, [organization]); const { isPending: issueLoading, isError: issueError, data: issue, } = useApiQuery( makeFetchGroupQueryKey({ groupId: dataRow['issue.id'], organizationSlug: organization.slug, // The link to issue details doesn't seem to currently pass selected environments environments: [], }), { staleTime: 30_000, } ); 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) ?? t('No one')} ); if (issueLoading || issueError) { return ; } return ( {renderTitle()} {renderStatusAndCounts()} {renderAssignee()} ); } 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;