import {Fragment} from 'react'; import sumBy from 'lodash/sumBy'; import ExternalLink from 'sentry/components/links/externalLink'; import {t, tct} from 'sentry/locale'; import useOrganization from 'sentry/utils/useOrganization'; import usePageFilters from 'sentry/utils/usePageFilters'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; import {useIneligibleProjects} from 'sentry/views/performance/database/useIneligibleProjects'; import {useProjectSpanMetricCounts} from 'sentry/views/starfish/queries/useProjectSpanMetricsCounts'; interface Props { Wrapper?: React.ComponentType; } function DivWrapper(props) { return
; } export function NoDataMessage({Wrapper = DivWrapper}: Props) { const {selection, isReady: pageFilterIsReady} = usePageFilters(); const selectedProjectIds = selection.projects.map(projectId => projectId.toString()); const {data: projectSpanMetricsCounts} = useProjectSpanMetricCounts({ query: 'span.module:db', statsPeriod: SAMPLE_STATS_PERIOD, enabled: pageFilterIsReady, projectId: selectedProjectIds, }); const doesAnySelectedProjectHaveMetrics = sumBy(projectSpanMetricsCounts, 'count()') > 0; const {ineligibleProjects} = useIneligibleProjects({ projectId: selectedProjectIds, enabled: pageFilterIsReady && !doesAnySelectedProjectHaveMetrics, }); const organization = useOrganization(); const hasMoreIneligibleProjectsThanVisible = ineligibleProjects.length > MAX_LISTED_PROJECTS; if (!projectSpanMetricsCounts) { return null; } if (doesAnySelectedProjectHaveMetrics) { return null; } const firstIneligibleProjects = ineligibleProjects.slice(0, MAX_LISTED_PROJECTS + 1); return (