@@ -4,7 +4,6 @@ import type {Theme} from '@emotion/react';
4
4
import { withTheme } from '@emotion/react' ;
5
5
import styled from '@emotion/styled' ;
6
6
import type { LegendComponentOption } from 'echarts' ;
7
- import type { Location } from 'history' ;
8
7
import isEqual from 'lodash/isEqual' ;
9
8
import omit from 'lodash/omit' ;
10
9
@@ -31,6 +30,7 @@ import type {
31
30
EChartEventHandler ,
32
31
ReactEchartsRef ,
33
32
} from 'sentry/types/echarts' ;
33
+ import type { InjectedRouter , WithRouterProps } from 'sentry/types/legacyReactRouter' ;
34
34
import type { Confidence , Organization } from 'sentry/types/organization' ;
35
35
import { defined } from 'sentry/utils' ;
36
36
import {
@@ -58,19 +58,22 @@ import {
58
58
import getDynamicText from 'sentry/utils/getDynamicText' ;
59
59
import { decodeSorts } from 'sentry/utils/queryString' ;
60
60
import { getDatasetConfig } from 'sentry/views/dashboards/datasetConfig/base' ;
61
- import type { Widget } from 'sentry/views/dashboards/types' ;
61
+ import type { DashboardFilters , Widget } from 'sentry/views/dashboards/types' ;
62
62
import { DisplayType , WidgetType } from 'sentry/views/dashboards/types' ;
63
63
import { eventViewFromWidget } from 'sentry/views/dashboards/utils' ;
64
64
import { getBucketSize } from 'sentry/views/dashboards/utils/getBucketSize' ;
65
+ import { getWidgetTableRowExploreUrlFunction } from 'sentry/views/dashboards/utils/getWidgetExploreUrl' ;
65
66
import WidgetLegendNameEncoderDecoder from 'sentry/views/dashboards/widgetLegendNameEncoderDecoder' ;
66
67
import type WidgetLegendSelectionState from 'sentry/views/dashboards/widgetLegendSelectionState' ;
67
68
import { BigNumberWidgetVisualization } from 'sentry/views/dashboards/widgets/bigNumberWidget/bigNumberWidgetVisualization' ;
69
+ import { ALLOWED_CELL_ACTIONS } from 'sentry/views/dashboards/widgets/common/settings' ;
68
70
import type { TabularColumn } from 'sentry/views/dashboards/widgets/common/types' ;
69
71
import { TableWidgetVisualization } from 'sentry/views/dashboards/widgets/tableWidget/tableWidgetVisualization' ;
70
72
import {
71
73
convertTableDataToTabularData ,
72
74
decodeColumnAliases ,
73
75
} from 'sentry/views/dashboards/widgets/tableWidget/utils' ;
76
+ import { Actions } from 'sentry/views/discover/table/cellAction' ;
74
77
import { decodeColumnOrder } from 'sentry/views/discover/utils' ;
75
78
import { ConfidenceFooter } from 'sentry/views/explore/spans/charts/confidenceFooter' ;
76
79
@@ -87,38 +90,40 @@ type TableResultProps = Pick<
87
90
type WidgetCardChartProps = Pick <
88
91
GenericWidgetQueriesChildrenProps ,
89
92
'timeseriesResults' | 'tableResults' | 'errorMessage' | 'loading'
90
- > & {
91
- location : Location ;
92
- organization : Organization ;
93
- selection : PageFilters ;
94
- theme : Theme ;
95
- widget : Widget ;
96
- widgetLegendState : WidgetLegendSelectionState ;
97
- chartGroup ?: string ;
98
- confidence ?: Confidence ;
99
- disableTableActions ?: boolean ;
100
- disableZoom ?: boolean ;
101
- expandNumbers ?: boolean ;
102
- isMobile ?: boolean ;
103
- isSampled ?: boolean | null ;
104
- legendOptions ?: LegendComponentOption ;
105
- minTableColumnWidth ?: number ;
106
- noPadding ?: boolean ;
107
- onLegendSelectChanged ?: EChartEventHandler < {
108
- name : string ;
109
- selected : Record < string , boolean > ;
110
- type : 'legendselectchanged' ;
111
- } > ;
112
- onWidgetTableResizeColumn ?: ( columns : TabularColumn [ ] ) => void ;
113
- onWidgetTableSort ?: ( sort : Sort ) => void ;
114
- onZoom ?: EChartDataZoomHandler ;
115
- sampleCount ?: number ;
116
- shouldResize ?: boolean ;
117
- showConfidenceWarning ?: boolean ;
118
- showLoadingText ?: boolean ;
119
- timeseriesResultsTypes ?: Record < string , AggregationOutputType > ;
120
- windowWidth ?: number ;
121
- } ;
93
+ > &
94
+ WithRouterProps & {
95
+ organization : Organization ;
96
+ selection : PageFilters ;
97
+ theme : Theme ;
98
+ widget : Widget ;
99
+ widgetLegendState : WidgetLegendSelectionState ;
100
+ chartGroup ?: string ;
101
+ confidence ?: Confidence ;
102
+ dashboardFilters ?: DashboardFilters ;
103
+ disableTableActions ?: boolean ;
104
+ disableZoom ?: boolean ;
105
+ expandNumbers ?: boolean ;
106
+ isMobile ?: boolean ;
107
+ isSampled ?: boolean | null ;
108
+ legendOptions ?: LegendComponentOption ;
109
+ minTableColumnWidth ?: number ;
110
+ noPadding ?: boolean ;
111
+ onLegendSelectChanged ?: EChartEventHandler < {
112
+ name : string ;
113
+ selected : Record < string , boolean > ;
114
+ type : 'legendselectchanged' ;
115
+ } > ;
116
+ onWidgetTableResizeColumn ?: ( columns : TabularColumn [ ] ) => void ;
117
+ onWidgetTableSort ?: ( sort : Sort ) => void ;
118
+ onZoom ?: EChartDataZoomHandler ;
119
+ router ?: InjectedRouter ;
120
+ sampleCount ?: number ;
121
+ shouldResize ?: boolean ;
122
+ showConfidenceWarning ?: boolean ;
123
+ showLoadingText ?: boolean ;
124
+ timeseriesResultsTypes ?: Record < string , AggregationOutputType > ;
125
+ windowWidth ?: number ;
126
+ } ;
122
127
123
128
class WidgetCardChart extends Component < WidgetCardChartProps > {
124
129
shouldComponentUpdate ( nextProps : WidgetCardChartProps ) : boolean {
@@ -162,6 +167,8 @@ class WidgetCardChart extends Component<WidgetCardChartProps> {
162
167
onWidgetTableSort,
163
168
onWidgetTableResizeColumn,
164
169
disableTableActions,
170
+ dashboardFilters,
171
+ router,
165
172
} = this . props ;
166
173
if ( loading || ! tableResults ?. [ 0 ] ) {
167
174
// Align height to other charts.
@@ -208,6 +215,13 @@ class WidgetCardChart extends Component<WidgetCardChartProps> {
208
215
}
209
216
210
217
const useCellActionsV2 = organization . features . includes ( 'discover-cell-actions-v2' ) ;
218
+ let cellActions = ALLOWED_CELL_ACTIONS ;
219
+ if ( disableTableActions || ! useCellActionsV2 ) {
220
+ cellActions = [ ] ;
221
+ } else if ( widget . widgetType === WidgetType . SPANS ) {
222
+ cellActions = [ ...ALLOWED_CELL_ACTIONS , Actions . OPEN_ROW_IN_EXPLORE ] ;
223
+ }
224
+
211
225
return (
212
226
< TableWrapper key = { `table:${ result . title } ` } >
213
227
{ organization . features . includes ( 'dashboards-use-widget-table-visualization' ) ? (
@@ -242,9 +256,18 @@ class WidgetCardChart extends Component<WidgetCardChartProps> {
242
256
} satisfies RenderFunctionBaggage ;
243
257
} }
244
258
onResizeColumn = { onWidgetTableResizeColumn }
245
- allowedCellActions = {
246
- disableTableActions || ! useCellActionsV2 ? [ ] : undefined
247
- }
259
+ allowedCellActions = { cellActions }
260
+ onTriggerCellAction = { ( action , _value , dataRow ) => {
261
+ if ( action === Actions . OPEN_ROW_IN_EXPLORE ) {
262
+ const getExploreUrl = getWidgetTableRowExploreUrlFunction (
263
+ selection ,
264
+ widget ,
265
+ organization ,
266
+ dashboardFilters
267
+ ) ;
268
+ router . push ( getExploreUrl ( dataRow ) ) ;
269
+ }
270
+ } }
248
271
/>
249
272
) : (
250
273
< StyledSimpleTableChart
0 commit comments