// XXX: A lot of the UI for this file will be changed once we use IssueListActions // We're using GroupList to help us iterate quickly import type {RouteComponentProps} from 'react-router'; import styled from '@emotion/styled'; import Feature from 'sentry/components/acl/feature'; import {LinkButton} from 'sentry/components/button'; import GroupList from 'sentry/components/issues/groupList'; import * as Layout from 'sentry/components/layouts/thirds'; import Link from 'sentry/components/links/link'; import LoadingError from 'sentry/components/loadingError'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {useApiQuery} from 'sentry/utils/queryClient'; import useOrganization from 'sentry/utils/useOrganization'; type RouteParams = { groupId: string; }; type Props = RouteComponentProps; type RelatedIssuesResponse = { data: [ { data: number[]; meta: { event_id: string; trace_id: string; }; type: string; }, ]; }; function GroupRelatedIssues({params}: Props) { const {groupId} = params; const organization = useOrganization(); const orgSlug = organization.slug; // Fetch the list of related issues const { isLoading, isError, data: relatedIssues, refetch, } = useApiQuery([`/issues/${groupId}/related-issues/`], { staleTime: 0, }); let traceMeta = { trace_id: '', event_id: '', }; const { same_root_cause: sameRootCauseIssues = [], trace_connected: traceConnectedIssues = [], } = (relatedIssues?.data ?? []).reduce( (mapping, item) => { if (item.type === 'trace_connected') { traceMeta = {...item.meta}; } const issuesList = item.data; mapping[item.type] = issuesList; return mapping; }, {same_root_cause: [], trace_connected: []} ); return ( {t( 'Related Issues are issues that are related in some way and can be acted on together.' )} {isLoading ? ( ) : isError ? ( ) : (
{t('Issues caused by the same root cause')} {sameRootCauseIssues.length > 0 ? (
{t('Open in Issues')}
) : ( {t('No same-root-cause related issues were found.')} )}
{t('Trace connected issues')} {traceConnectedIssues.length > 0 ? (
{t('These are the issues belonging to ')} {t('this trace')} {t('Open in Issues')}
) : ( {t('No trace-connected related issues were found.')} )}
)} ); } function GroupRelatedIssuesWrapper(props: Props) { return ( ); } // Export the component without feature flag controls export {GroupRelatedIssues}; export default GroupRelatedIssuesWrapper; const Title = styled('h4')` margin-bottom: ${space(0.75)}; `; const HeaderWrapper = styled('div')` margin-bottom: ${space(2)}; small { color: ${p => p.theme.subText}; } `; const TextButtonWrapper = styled('div')` display: flex; justify-content: space-between; margin-bottom: ${space(1)}; `;