From 78231b1b4afe332ea250c873b0b9e6e81486a928 Mon Sep 17 00:00:00 2001 From: edwardgou-sentry <83961295+edwardgou-sentry@users.noreply.github.com> Date: Tue, 5 Oct 2021 11:44:58 -0400 Subject: [PATCH] fix(discover): fixed cell actions dropping multi y axis (#29051) Cell Actions only redirect with a single Y-Axis even when multiple Y-Axis are selected, due to using EventView to construct new target. Updated to pull Y-Axis from location when creating new target. --- static/app/views/eventsV2/table/tableView.tsx | 7 +++++-- .../spec/views/eventsV2/table/tableView.spec.jsx | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/static/app/views/eventsV2/table/tableView.tsx b/static/app/views/eventsV2/table/tableView.tsx index 74f6a53715b900..6479d52d07fbad 100644 --- a/static/app/views/eventsV2/table/tableView.tsx +++ b/static/app/views/eventsV2/table/tableView.tsx @@ -359,7 +359,7 @@ class TableView extends React.Component { handleCellAction = (dataRow: TableDataRow, column: TableColumn) => { return (action: Actions, value: React.ReactText) => { - const {eventView, organization, projects} = this.props; + const {eventView, organization, projects, location} = this.props; const query = new MutableSearch(eventView.query); @@ -431,7 +431,10 @@ class TableView extends React.Component { } nextView.query = query.formatString(); - browserHistory.push(nextView.getResultsViewUrlTarget(organization.slug)); + const target = nextView.getResultsViewUrlTarget(organization.slug); + // Get yAxis from location + target.query.yAxis = decodeList(location.query.yAxis); + browserHistory.push(target); }; }; diff --git a/tests/js/spec/views/eventsV2/table/tableView.spec.jsx b/tests/js/spec/views/eventsV2/table/tableView.spec.jsx index 0e6531de2b566c..8019e50f8e9099 100644 --- a/tests/js/spec/views/eventsV2/table/tableView.spec.jsx +++ b/tests/js/spec/views/eventsV2/table/tableView.spec.jsx @@ -138,6 +138,21 @@ describe('TableView > CellActions', function () { }); }); + it('handles add cell action with multiple y axis', function () { + location.query.yAxis = ['count()', 'failure_count()']; + const wrapper = makeWrapper(initialData, rows, eventView); + const menu = openContextMenu(wrapper, 0); + menu.find('button[data-test-id="add-to-filter"]').simulate('click'); + + expect(browserHistory.push).toHaveBeenCalledWith({ + pathname: location.pathname, + query: expect.objectContaining({ + query: 'title:"some title"', + yAxis: ['count()', 'failure_count()'], + }), + }); + }); + it('handles exclude cell action on string value', function () { const wrapper = makeWrapper(initialData, rows, eventView); const menu = openContextMenu(wrapper, 0);