import {Fragment} from 'react'; // eslint-disable-next-line no-restricted-imports import {withRouter, WithRouterProps} from 'react-router'; import styled from '@emotion/styled'; import type {DataZoomComponentOption} from 'echarts'; import {LegendComponentOption} from 'echarts'; import {Client} from 'sentry/api'; import TransparentLoadingMask from 'sentry/components/charts/transparentLoadingMask'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import {Organization, PageFilters} from 'sentry/types'; import {EChartEventHandler, Series} from 'sentry/types/echarts'; import {TableDataWithTitle} from 'sentry/utils/discover/discoverQuery'; import {DashboardFilters, Widget, WidgetType} from '../types'; import WidgetCardChart, {AugmentedEChartDataZoomHandler} from './chart'; import {IssueWidgetCard} from './issueWidgetCard'; import IssueWidgetQueries from './issueWidgetQueries'; import ReleaseWidgetQueries from './releaseWidgetQueries'; import WidgetQueries from './widgetQueries'; type Props = WithRouterProps & { api: Client; organization: Organization; selection: PageFilters; widget: Widget; chartZoomOptions?: DataZoomComponentOption; dashboardFilters?: DashboardFilters; expandNumbers?: boolean; isMobile?: boolean; legendOptions?: LegendComponentOption; noPadding?: boolean; onDataFetched?: (results: { pageLinks?: string; tableResults?: TableDataWithTitle[]; timeseriesResults?: Series[]; totalIssuesCount?: string; }) => void; onLegendSelectChanged?: EChartEventHandler<{ name: string; selected: Record; type: 'legendselectchanged'; }>; onZoom?: AugmentedEChartDataZoomHandler; renderErrorMessage?: (errorMessage?: string) => React.ReactNode; showSlider?: boolean; tableItemLimit?: number; windowWidth?: number; }; export function WidgetCardChartContainer({ location, router, api, organization, selection, widget, dashboardFilters, isMobile, renderErrorMessage, tableItemLimit, windowWidth, onZoom, onLegendSelectChanged, legendOptions, expandNumbers, onDataFetched, showSlider, noPadding, chartZoomOptions, }: Props) { if (widget.widgetType === WidgetType.ISSUE) { return ( {({tableResults, errorMessage, loading}) => { return ( {typeof renderErrorMessage === 'function' ? renderErrorMessage(errorMessage) : null} ); }} ); } if (widget.widgetType === WidgetType.RELEASE) { return ( {({tableResults, timeseriesResults, errorMessage, loading}) => { return ( {typeof renderErrorMessage === 'function' ? renderErrorMessage(errorMessage) : null} ); }} ); } return ( {({tableResults, timeseriesResults, errorMessage, loading}) => { return ( {typeof renderErrorMessage === 'function' ? renderErrorMessage(errorMessage) : null} ); }} ); } export default withRouter(WidgetCardChartContainer); const StyledTransparentLoadingMask = styled(props => ( ))` display: flex; justify-content: center; align-items: center; `; const LoadingScreen = ({loading}: {loading: boolean}) => { if (!loading) { return null; } return ( ); };