import {useState} from 'react'; import styled from '@emotion/styled'; import {TabList, TabPanels, Tabs} from 'sentry/components/tabs'; import {Tooltip} from 'sentry/components/tooltip'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {isCustomMetric} from 'sentry/utils/metrics'; import type {MetricWidgetQueryParams} from 'sentry/utils/metrics/types'; import {CodeLocations} from 'sentry/views/ddm/codeLocations'; import {useDDMContext} from 'sentry/views/ddm/context'; import {SampleTable} from 'sentry/views/ddm/sampleTable'; enum Tab { SAMPLES = 'samples', CODE_LOCATIONS = 'codeLocations', } const constructQueryString = (queryObject: Record) => { return Object.entries(queryObject) .map(([key, value]) => `${key}:"${value}"`) .join(' '); }; export function WidgetDetails() { const { selectedWidgetIndex, widgets, focusArea, highlightedSampleId, setHighlightedSampleId, } = useDDMContext(); const [selectedTab, setSelectedTab] = useState(Tab.SAMPLES); // the tray is minimized when the main content is maximized const selectedWidget = widgets[selectedWidgetIndex] as | MetricWidgetQueryParams | undefined; const isCodeLocationsDisabled = selectedWidget?.mri && !isCustomMetric({mri: selectedWidget.mri}); if (isCodeLocationsDisabled && selectedTab === Tab.CODE_LOCATIONS) { setSelectedTab(Tab.SAMPLES); } const handleSampleRowHover = (sampleId?: string) => { setHighlightedSampleId(sampleId); }; return ( {t('Samples')} {t('Code Location')} ); } const TrayWrapper = styled('div')` padding-top: ${space(4)}; display: grid; grid-template-rows: auto auto 1fr; `; const ContentWrapper = styled('div')` position: relative; padding: ${space(2)} 0; `;