12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import OptionSelector from 'sentry/components/charts/optionSelector';
- import {
- ChartControls,
- InlineContainer,
- SectionHeading,
- SectionValue,
- } from 'sentry/components/charts/styles';
- import {t} from 'sentry/locale';
- import {Organization, SelectValue} from 'sentry/types';
- import {TOP_EVENT_MODES} from 'sentry/utils/discover/types';
- type Props = {
- displayMode: string;
- displayOptions: SelectValue<string>[];
- onAxisChange: (value: string[]) => void;
- onDisplayChange: (value: string) => void;
- onTopEventsChange: (value: string) => void;
- organization: Organization;
- topEvents: string;
- total: number | null;
- yAxisOptions: SelectValue<string>[];
- yAxisValue: string[];
- };
- export default function ChartFooter({
- total,
- yAxisValue,
- yAxisOptions,
- onAxisChange,
- displayMode,
- displayOptions,
- onDisplayChange,
- onTopEventsChange,
- topEvents,
- }: Props) {
- const elements: React.ReactNode[] = [];
- elements.push(<SectionHeading key="total-label">{t('Total Events')}</SectionHeading>);
- elements.push(
- total === null ? (
- <SectionValue data-test-id="loading-placeholder" key="total-value">
- —
- </SectionValue>
- ) : (
- <SectionValue key="total-value">{total.toLocaleString()}</SectionValue>
- )
- );
- const topEventOptions: SelectValue<string>[] = [];
- for (let i = 1; i <= 10; i++) {
- topEventOptions.push({value: i.toString(), label: i.toString()});
- }
- return (
- <ChartControls>
- <InlineContainer>{elements}</InlineContainer>
- <InlineContainer>
- <OptionSelector
- title={t('Display')}
- selected={displayMode}
- options={displayOptions}
- onChange={onDisplayChange}
- />
- {TOP_EVENT_MODES.includes(displayMode) && (
- <OptionSelector
- title={t('Limit')}
- selected={topEvents}
- options={topEventOptions}
- onChange={onTopEventsChange}
- />
- )}
- {TOP_EVENT_MODES.includes(displayMode) ? (
- <OptionSelector
- title={t('Y-Axis')}
- selected={yAxisValue[0]}
- options={yAxisOptions}
- onChange={yAxis => onAxisChange([yAxis])}
- />
- ) : (
- <OptionSelector
- multiple
- isClearable
- menuTitle={
- yAxisOptions.length > 3 ? t('Select up to 3 options') : t('Y-axis')
- }
- title={t('Y-Axis')}
- selected={yAxisValue}
- options={yAxisOptions}
- onChange={onAxisChange}
- />
- )}
- </InlineContainer>
- </ChartControls>
- );
- }
|