@@ -3,7 +3,7 @@ import styled from '@emotion/styled';
33import { browserHistory } from 'react-router' ;
44import { Location , LocationDescriptorObject } from 'history' ;
55
6- import { Organization , OrganizationSummary , Project } from 'app/types' ;
6+ import { Organization , Project } from 'app/types' ;
77import { trackAnalyticsEvent } from 'app/utils/analytics' ;
88import GridEditable , {
99 COL_WIDTH_UNDEFINED ,
@@ -195,38 +195,13 @@ class TableView extends React.Component<TableViewProps> {
195195 column : TableColumn < keyof TableDataRow > ,
196196 dataRow : TableDataRow
197197 ) : React . ReactNode => {
198- const { location, organization, tableData, eventView } = this . props ;
198+ const { location, organization, tableData} = this . props ;
199199
200200 if ( ! tableData || ! tableData . meta ) {
201201 return dataRow [ column . key ] ;
202202 }
203203 const fieldRenderer = getFieldRenderer ( String ( column . key ) , tableData . meta ) ;
204- const aggregation =
205- column . column . kind === 'function' ? column . column . function [ 0 ] : undefined ;
206204
207- // Aggregation columns offer drilldown behavior
208- if ( aggregation ) {
209- return (
210- < ExpandAggregateRow
211- organization = { organization }
212- eventView = { eventView }
213- column = { column }
214- dataRow = { dataRow }
215- location = { location }
216- tableMeta = { tableData . meta }
217- >
218- < CellAction
219- column = { column }
220- dataRow = { dataRow }
221- handleCellAction = { this . handleCellAction ( dataRow , column , tableData . meta ) }
222- >
223- { fieldRenderer ( dataRow , { organization, location} ) }
224- </ CellAction >
225- </ ExpandAggregateRow >
226- ) ;
227- }
228-
229- // Scalar fields offer cell actions to build queries.
230205 return (
231206 < CellAction
232207 column = { column }
@@ -345,6 +320,25 @@ class TableView extends React.Component<TableViewProps> {
345320
346321 return ;
347322 }
323+ case Actions . DRILLDOWN : {
324+ // count_unique(column) drilldown
325+
326+ trackAnalyticsEvent ( {
327+ eventKey : 'discover_v2.results.drilldown' ,
328+ eventName : 'Discoverv2: Click aggregate drilldown' ,
329+ organization_id : parseInt ( organization . id , 10 ) ,
330+ } ) ;
331+
332+ // Drilldown into each distinct value and get a count() for each value.
333+ nextView = getExpandedResults ( nextView , { } , dataRow ) . withNewColumn ( {
334+ kind : 'function' ,
335+ function : [ 'count' , '' , undefined ] ,
336+ } ) ;
337+
338+ browserHistory . push ( nextView . getResultsViewUrlTarget ( organization . slug ) ) ;
339+
340+ return ;
341+ }
348342 default :
349343 throw new Error ( `Unknown action type. ${ action } ` ) ;
350344 }
@@ -428,50 +422,6 @@ class TableView extends React.Component<TableViewProps> {
428422 }
429423}
430424
431- function ExpandAggregateRow ( props : {
432- organization : OrganizationSummary ;
433- children : React . ReactNode ;
434- eventView : EventView ;
435- column : TableColumn < keyof TableDataRow > ;
436- dataRow : TableDataRow ;
437- location : Location ;
438- tableMeta : MetaType ;
439- } ) {
440- const { children, column, dataRow, eventView, location, organization} = props ;
441- const aggregation =
442- column . column . kind === 'function' ? column . column . function [ 0 ] : undefined ;
443-
444- function handleClick ( ) {
445- trackAnalyticsEvent ( {
446- eventKey : 'discover_v2.results.drilldown' ,
447- eventName : 'Discoverv2: Click aggregate drilldown' ,
448- organization_id : parseInt ( organization . id , 10 ) ,
449- } ) ;
450- }
451-
452- // count_unique(column) drilldown
453- if ( aggregation === 'count_unique' ) {
454- // Drilldown into each distinct value and get a count() for each value.
455- const nextView = getExpandedResults ( eventView , { } , dataRow ) . withNewColumn ( {
456- kind : 'function' ,
457- function : [ 'count' , '' , undefined ] ,
458- } ) ;
459-
460- const target = {
461- pathname : location . pathname ,
462- query : nextView . generateQueryStringObject ( ) ,
463- } ;
464-
465- return (
466- < Link data-test-id = "expand-count-unique" to = { target } onClick = { handleClick } >
467- { children }
468- </ Link >
469- ) ;
470- }
471-
472- return < React . Fragment > { children } </ React . Fragment > ;
473- }
474-
475425const PrependHeader = styled ( 'span' ) `
476426 color: ${ p => p . theme . gray600 } ;
477427` ;
0 commit comments