@@ -2,13 +2,11 @@ import type {Dispatch, SetStateAction} from 'react';
2
2
import { Fragment , useCallback , useEffect , useMemo } from 'react' ;
3
3
import styled from '@emotion/styled' ;
4
4
5
- import Feature from 'sentry/components/acl/feature' ;
6
5
import { getInterval } from 'sentry/components/charts/utils' ;
7
6
import { CompactSelect } from 'sentry/components/compactSelect' ;
8
- import { DropdownMenu } from 'sentry/components/dropdownMenu' ;
9
7
import { Tooltip } from 'sentry/components/tooltip' ;
10
8
import { CHART_PALETTE } from 'sentry/constants/chartPalette' ;
11
- import { IconClock , IconGraph , IconSubscribed } from 'sentry/icons' ;
9
+ import { IconClock , IconGraph } from 'sentry/icons' ;
12
10
import { t } from 'sentry/locale' ;
13
11
import { space } from 'sentry/styles/space' ;
14
12
import { dedupeArray } from 'sentry/utils/dedupeArray' ;
@@ -18,12 +16,9 @@ import {
18
16
prettifyParsedFunction ,
19
17
} from 'sentry/utils/discover/fields' ;
20
18
import { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
21
- import useOrganization from 'sentry/utils/useOrganization' ;
22
19
import usePageFilters from 'sentry/utils/usePageFilters' ;
23
- import useProjects from 'sentry/utils/useProjects' ;
24
20
import { formatVersion } from 'sentry/utils/versions/formatVersion' ;
25
- import { Dataset } from 'sentry/views/alerts/rules/metric/types' ;
26
- import { AddToDashboardButton } from 'sentry/views/explore/components/addToDashboardButton' ;
21
+ import ChartContextMenu from 'sentry/views/explore/components/chartContextMenu' ;
27
22
import { useChartInterval } from 'sentry/views/explore/hooks/useChartInterval' ;
28
23
import { useDataset } from 'sentry/views/explore/hooks/useDataset' ;
29
24
import { useVisualizes } from 'sentry/views/explore/hooks/useVisualizes' ;
@@ -33,7 +28,6 @@ import Chart, {
33
28
} from 'sentry/views/insights/common/components/chart' ;
34
29
import ChartPanel from 'sentry/views/insights/common/components/chartPanel' ;
35
30
import { useSortedTimeSeries } from 'sentry/views/insights/common/queries/useSortedTimeSeries' ;
36
- import { getAlertsUrl } from 'sentry/views/insights/common/utils/getAlertsUrl' ;
37
31
import { CHART_HEIGHT } from 'sentry/views/insights/database/settings' ;
38
32
39
33
import { useGroupBys } from '../hooks/useGroupBys' ;
@@ -67,9 +61,6 @@ export const EXPLORE_CHART_GROUP = 'explore-charts_group';
67
61
// TODO: Update to support aggregate mode and multiple queries / visualizations
68
62
export function ExploreCharts ( { query, setError} : ExploreChartsProps ) {
69
63
const pageFilters = usePageFilters ( ) ;
70
- const organization = useOrganization ( ) ;
71
- const { projects} = useProjects ( ) ;
72
-
73
64
const [ dataset ] = useDataset ( ) ;
74
65
const [ visualizes , setVisualizes ] = useVisualizes ( ) ;
75
66
const [ interval , setInterval , intervalOptions ] = useChartInterval ( ) ;
@@ -184,29 +175,6 @@ export function ExploreCharts({query, setError}: ExploreChartsProps) {
184
175
? 'area'
185
176
: 'bar' ;
186
177
187
- const project =
188
- projects . length === 1
189
- ? projects [ 0 ]
190
- : projects . find ( p => p . id === `${ pageFilters . selection . projects [ 0 ] } ` ) ;
191
- const singleProject =
192
- ( pageFilters . selection . projects . length === 1 || projects . length === 1 ) &&
193
- project ;
194
- const alertsUrls = singleProject
195
- ? visualizeYAxes . map ( yAxis => ( {
196
- key : yAxis ,
197
- label : yAxis ,
198
- to : getAlertsUrl ( {
199
- project,
200
- query,
201
- pageFilters : pageFilters . selection ,
202
- aggregate : yAxis ,
203
- orgSlug : organization . slug ,
204
- dataset : Dataset . EVENTS_ANALYTICS_PLATFORM ,
205
- interval,
206
- } ) ,
207
- } ) )
208
- : undefined ;
209
-
210
178
const data = getSeries ( dedupedYAxes , formattedYAxes ) ;
211
179
212
180
const outputTypes = new Set (
@@ -251,32 +219,12 @@ export function ExploreCharts({query, setError}: ExploreChartsProps) {
251
219
options = { intervalOptions }
252
220
/>
253
221
</ Tooltip >
254
- < Feature features = "organizations:alerts-eap" >
255
- < Tooltip
256
- title = {
257
- singleProject
258
- ? t ( 'Create an alert for this chart' )
259
- : t ( 'Cannot create an alert when multiple projects are selected' )
260
- }
261
- >
262
- < DropdownMenu
263
- triggerProps = { {
264
- 'aria-label' : t ( 'Create Alert' ) ,
265
- size : 'sm' ,
266
- borderless : true ,
267
- showChevron : false ,
268
- icon : < IconSubscribed /> ,
269
- } }
270
- position = "bottom-end"
271
- items = { alertsUrls ?? [ ] }
272
- menuTitle = { t ( 'Create an alert for' ) }
273
- isDisabled = { ! alertsUrls || alertsUrls . length === 0 }
274
- />
275
- </ Tooltip >
276
- </ Feature >
277
- < Feature features = "organizations:dashboards-eap" >
278
- < AddToDashboardButton visualizeIndex = { index } />
279
- </ Feature >
222
+ < ChartContextMenu
223
+ visualizeYAxes = { visualizeYAxes }
224
+ query = { query }
225
+ interval = { interval }
226
+ visualizeIndex = { index }
227
+ />
280
228
</ ChartHeader >
281
229
< Chart
282
230
height = { CHART_HEIGHT }
0 commit comments