import {Fragment} from 'react'; import styled from '@emotion/styled'; import Feature from 'sentry/components/acl/feature'; import IntervalSelector from 'sentry/components/charts/intervalSelector'; import OptionSelector from 'sentry/components/charts/optionSelector'; import { ChartControls, InlineContainer, SectionHeading, SectionValue, } from 'sentry/components/charts/styles'; import FeatureBadge from 'sentry/components/featureBadge'; import ExternalLink from 'sentry/components/links/externalLink'; import QuestionTooltip from 'sentry/components/questionTooltip'; import Switch from 'sentry/components/switchButton'; import {t, tct} from 'sentry/locale'; import {Organization, SelectValue} from 'sentry/types'; import {defined} from 'sentry/utils'; import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent'; import EventView from 'sentry/utils/discover/eventView'; import {TOP_EVENT_MODES} from 'sentry/utils/discover/types'; import {formatAbbreviatedNumber} from 'sentry/utils/formatters'; import localStorage from 'sentry/utils/localStorage'; export const PROCESSED_BASELINE_TOGGLE_KEY = 'show-processed-baseline'; type Props = { displayMode: string; displayOptions: SelectValue[]; eventView: EventView; onAxisChange: (value: string[]) => void; onDisplayChange: (value: string) => void; onIntervalChange: (value: string | undefined) => void; onTopEventsChange: (value: string) => void; organization: Organization; setShowBaseline: (value: boolean) => void; showBaseline: boolean; topEvents: string; total: number | null; yAxisOptions: SelectValue[]; yAxisValue: string[]; disableProcessedBaselineToggle?: boolean; loadingProcessedTotals?: boolean; processedTotal?: number; }; export default function ChartFooter({ total, yAxisValue, yAxisOptions, onAxisChange, displayMode, displayOptions, onDisplayChange, onTopEventsChange, onIntervalChange, topEvents, setShowBaseline, showBaseline, organization, disableProcessedBaselineToggle, eventView, processedTotal, loadingProcessedTotals, }: Props) { const elements: React.ReactNode[] = []; elements.push({t('Total Events')}); elements.push( total === null || loadingProcessedTotals === true ? ( ) : defined(processedTotal) ? ( {tct('[indexedTotal] of [processedTotal]', { indexedTotal: formatAbbreviatedNumber(total), processedTotal: formatAbbreviatedNumber(processedTotal), })} ) : ( {total.toLocaleString()} ) ); const topEventOptions: SelectValue[] = []; for (let i = 1; i <= 10; i++) { topEventOptions.push({value: i.toString(), label: i.toString()}); } return ( {elements} {t('Processed events')} { const value = !showBaseline; localStorage.setItem( PROCESSED_BASELINE_TOGGLE_KEY, value === true ? '1' : '0' ); trackAdvancedAnalyticsEvent( 'discover_v2.processed_baseline_toggle.clicked', { organization, toggled: value === true ? 'on' : 'off', } ); setShowBaseline(value); }} /> ), processedEventsLink: ( ), break: (

), } )} />
{TOP_EVENT_MODES.includes(displayMode) && ( )} {TOP_EVENT_MODES.includes(displayMode) ? ( onAxisChange([yAxis])} /> ) : ( 3 ? t('Select up to 3 options') : t('Y-axis') } title={t('Y-Axis')} selected={yAxisValue} options={yAxisOptions} onChange={onAxisChange} /> )}
); } const SwitchLabel = styled('div')` padding-right: 4px; font-weight: bold; `;