import {useMemo} from 'react'; import styled from '@emotion/styled'; import {CompactSelect, type SelectOption} from 'sentry/components/compactSelect'; import {t} from 'sentry/locale'; import {parseFunction} from 'sentry/utils/discover/fields'; import type {SpanIndexedField} from 'sentry/views/insights/types'; import { ALLOWED_VISUALIZE_AGGREGATES, ALLOWED_VISUALIZE_FIELDS, } from '../hooks/useVisualize'; import {ToolbarHeading, ToolbarSection} from './styles'; interface ToolbarVisualizeProps { setVisualize: (visualize: string) => void; visualize: string; } export function ToolbarVisualize({visualize, setVisualize}: ToolbarVisualizeProps) { const parsedVisualize = useMemo(() => { return parseFunction(visualize); }, [visualize]); const fieldOptions: SelectOption[] = ALLOWED_VISUALIZE_FIELDS.map( field => { return { label: field, value: field, }; } ); const aggregateOptions: SelectOption[] = ALLOWED_VISUALIZE_AGGREGATES.map( aggregate => { return { label: aggregate, value: aggregate, }; } ); return ( {t('Visualize')} setVisualize(`${parsedVisualize?.name}(${newField.value})`) } /> setVisualize(`${newAggregate.value}(${parsedVisualize?.arguments[0]})`) } /> ); } const ToolbarContent = styled('div')` display: flex; `;