import {Fragment} from 'react'; import type {PageFilters} from 'sentry/types/core'; import type {Series} from 'sentry/types/echarts'; import type {TableDataWithTitle} from 'sentry/utils/discover/discoverQuery'; import type {AggregationOutputType} from 'sentry/utils/discover/fields'; import useApi from 'sentry/utils/useApi'; import useOrganization from 'sentry/utils/useOrganization'; import type {DashboardFilters, Widget} from '../types'; import {WidgetType} from '../types'; import IssueWidgetQueries from './issueWidgetQueries'; import ReleaseWidgetQueries from './releaseWidgetQueries'; import WidgetQueries from './widgetQueries'; type Results = { loading: boolean; errorMessage?: string; pageLinks?: string; tableResults?: TableDataWithTitle[]; timeseriesResults?: Series[]; timeseriesResultsTypes?: Record; totalIssuesCount?: string; }; type Props = { children: (props: Results) => React.ReactNode; selection: PageFilters; widget: Widget; dashboardFilters?: DashboardFilters; onDataFetched?: ( results: Pick< Results, | 'pageLinks' | 'tableResults' | 'timeseriesResults' | 'timeseriesResultsTypes' | 'totalIssuesCount' > ) => void; onWidgetSplitDecision?: (splitDecision: WidgetType) => void; tableItemLimit?: number; }; export function WidgetCardDataLoader({ children, widget, selection, dashboardFilters, tableItemLimit, onDataFetched, onWidgetSplitDecision, }: Props) { const api = useApi(); const organization = useOrganization(); if (widget.widgetType === WidgetType.ISSUE) { return ( {({tableResults, errorMessage, loading}) => ( {children({tableResults, errorMessage, loading})} )} ); } if (widget.widgetType === WidgetType.RELEASE) { return ( {({tableResults, timeseriesResults, errorMessage, loading}) => ( {children({tableResults, timeseriesResults, errorMessage, loading})} )} ); } return ( {({ tableResults, timeseriesResults, errorMessage, loading, timeseriesResultsTypes, }) => ( {children({ tableResults, timeseriesResults, errorMessage, loading, timeseriesResultsTypes, })} )} ); }