Skip to content

Commit

Permalink
fix(discover): fixed cell actions dropping multi y axis (#29051)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edwardgou-sentry authored Oct 5, 2021
1 parent d2ec4b0 commit 78231b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions static/app/views/eventsV2/table/tableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class TableView extends React.Component<TableViewProps> {

handleCellAction = (dataRow: TableDataRow, column: TableColumn<keyof TableDataRow>) => {
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);

Expand Down Expand Up @@ -431,7 +431,10 @@ class TableView extends React.Component<TableViewProps> {
}
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);
};
};

Expand Down
15 changes: 15 additions & 0 deletions tests/js/spec/views/eventsV2/table/tableView.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 78231b1

Please sign in to comment.