import type React from 'react'; import styled from '@emotion/styled'; import type {Location} from 'history'; import {openDashboardWidgetQuerySelectorModal} from 'sentry/actionCreators/modal'; import Tag from 'sentry/components/badge/tag'; import {Button} from 'sentry/components/button'; import {openConfirmModal} from 'sentry/components/confirm'; import type {MenuItemProps} from 'sentry/components/dropdownMenu'; import {DropdownMenu} from 'sentry/components/dropdownMenu'; import {isWidgetViewerPath} from 'sentry/components/modals/widgetViewerModal/utils'; import {Tooltip} from 'sentry/components/tooltip'; import {IconEllipsis, IconExpand, IconInfo} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {PageFilters} from 'sentry/types/core'; import type {Series} from 'sentry/types/echarts'; import type {InjectedRouter} from 'sentry/types/legacyReactRouter'; import type {Organization} from 'sentry/types/organization'; import {trackAnalytics} from 'sentry/utils/analytics'; import type {TableDataWithTitle} from 'sentry/utils/discover/discoverQuery'; import type {AggregationOutputType} from 'sentry/utils/discover/fields'; import { MEPState, useMEPSettingContext, } from 'sentry/utils/performance/contexts/metricsEnhancedSetting'; import useOrganization from 'sentry/utils/useOrganization'; import { getWidgetDiscoverUrl, getWidgetIssueUrl, getWidgetMetricsUrl, hasDatasetSelector, isUsingPerformanceScore, performanceScoreTooltip, } from 'sentry/views/dashboards/utils'; import type {Widget} from '../types'; import {WidgetType} from '../types'; import {WidgetViewerContext} from '../widgetViewer/widgetViewerContext'; import {useDashboardsMEPContext} from './dashboardsMEPContext'; type Props = { location: Location; organization: Organization; router: InjectedRouter; selection: PageFilters; widget: Widget; widgetLimitReached: boolean; description?: string; index?: string; isPreview?: boolean; onDelete?: () => void; onDuplicate?: () => void; onEdit?: () => void; pageLinks?: string; seriesData?: Series[]; seriesResultsType?: Record; showContextMenu?: boolean; tableData?: TableDataWithTitle[]; title?: string | React.ReactNode; totalIssuesCount?: string; }; export const useIndexedEventsWarning = (): string | null => { const {isMetricsData} = useDashboardsMEPContext(); const organization = useOrganization(); const metricSettingContext = useMEPSettingContext(); return !organization.features.includes('performance-mep-bannerless-ui') && isMetricsData === false && metricSettingContext && metricSettingContext.metricSettingState !== MEPState.TRANSACTIONS_ONLY ? t('Indexed') : null; }; function WidgetCardContextMenu({ organization, selection, widget, widgetLimitReached, onDelete, onDuplicate, onEdit, showContextMenu, isPreview, router, location, index, seriesData, tableData, pageLinks, totalIssuesCount, seriesResultsType, description, title, }: Props) { const indexedEventsWarning = useIndexedEventsWarning(); const {isMetricsData} = useDashboardsMEPContext(); if (!showContextMenu) { return null; } const openWidgetViewerPath = (id: string | undefined) => { if (!isWidgetViewerPath(location.pathname)) { router.push({ pathname: `${location.pathname}${ location.pathname.endsWith('/') ? '' : '/' }widget/${id}/`, query: location.query, }); } }; if (isPreview) { return ( {({setData}) => ( {indexedEventsWarning ? ( {t('Indexed')} ) : null} {title && ( {title} {description && ( {description} )} } containerDisplayMode="grid" isHoverable > } /> )} , }} position="bottom-end" />