import type {InjectedRouter} from 'react-router'; import styled from '@emotion/styled'; import type {Location} from 'history'; import {openDashboardWidgetQuerySelectorModal} from 'sentry/actionCreators/modal'; 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 {Tag} from 'sentry/components/tag'; import {IconEdit, IconEllipsis, IconExpand} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization, PageFilters} from 'sentry/types'; import type {Series} from 'sentry/types/echarts'; import {trackAnalytics} from 'sentry/utils/analytics'; import type {TableDataWithTitle} from 'sentry/utils/discover/discoverQuery'; import type {AggregationOutputType} from 'sentry/utils/discover/fields'; import {hasMetricsExperimentalFeature} from 'sentry/utils/metrics/features'; import { MEPConsumer, MEPState, } from 'sentry/utils/performance/contexts/metricsEnhancedSetting'; import { getWidgetDDMUrl, getWidgetDiscoverUrl, getWidgetIssueUrl, } 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; index?: string; isPreview?: boolean; onDelete?: () => void; onDuplicate?: () => void; onEdit?: () => void; pageLinks?: string; seriesData?: Series[]; seriesResultsType?: Record; showContextMenu?: boolean; tableData?: TableDataWithTitle[]; totalIssuesCount?: string; }; function WidgetCardContextMenu({ organization, selection, widget, widgetLimitReached, onDelete, onDuplicate, onEdit, showContextMenu, isPreview, router, location, index, seriesData, tableData, pageLinks, totalIssuesCount, seriesResultsType, }: Props) { const {isMetricsData} = useDashboardsMEPContext(); if (!showContextMenu) { return null; } const menuOptions: MenuItemProps[] = []; const disabledKeys: string[] = []; const openWidgetViewerPath = (id: string | undefined) => { if (!isWidgetViewerPath(location.pathname)) { router.push({ pathname: `${location.pathname}${ location.pathname.endsWith('/') ? '' : '/' }widget/${id}/`, query: location.query, }); } }; const openWidgetViewerIcon = hasMetricsExperimentalFeature(organization) && widget.widgetType === WidgetType.METRICS ? ( ) : ( ); if (isPreview) { return ( {({setData}) => ( {metricSettingContext => ( {!organization.features.includes('performance-mep-bannerless-ui') && isMetricsData === false && metricSettingContext && metricSettingContext.metricSettingState !== MEPState.TRANSACTIONS_ONLY && ( {t('Indexed')} )} , }} position="bottom-end" disabledKeys={[...disabledKeys, 'preview']} />