Skip to content

feat(events-v2): Pass props to avoid withRouter #13525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import {withRouter} from 'react-router';
import styled from 'react-emotion';
import {omit, isEqual} from 'lodash';
import SentryTypes from 'app/sentryTypes';
Expand All @@ -23,7 +22,7 @@ const CHART_AXIS_OPTIONS = [
{label: 'Users', value: 'user_count'},
];

class Events extends AsyncComponent {
export default class Events extends AsyncComponent {
static propTypes = {
router: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
Expand Down Expand Up @@ -132,5 +131,3 @@ const Container = styled('div')`
const StyledSearchBar = styled(SearchBar)`
margin-bottom: ${space(2)};
`;

export default withRouter(Events);
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class OrganizationEventsV2 extends React.Component {
static propTypes = {
organization: SentryTypes.Organization.isRequired,
location: PropTypes.object.isRequired,
router: PropTypes.object.isRequired,
};

renderTabs() {
Expand All @@ -46,7 +47,7 @@ export default class OrganizationEventsV2 extends React.Component {
}

render() {
const {organization, location} = this.props;
const {organization, location, router} = this.props;
const {eventSlug} = location.query;

return (
Expand All @@ -64,6 +65,8 @@ export default class OrganizationEventsV2 extends React.Component {
<Events
organization={organization}
view={getCurrentView(location.query.view)}
location={location}
router={router}
/>
</NoProjectMessage>
{eventSlug && (
Expand Down
8 changes: 7 additions & 1 deletion tests/js/spec/views/organizationEventsV2/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('OrganizationEventsV2', function() {
<OrganizationEventsV2
organization={TestStubs.Organization({projects: [TestStubs.Project()]})}
location={{query: {}}}
router={{}}
/>,
TestStubs.routerContext()
);
Expand All @@ -56,6 +57,7 @@ describe('OrganizationEventsV2', function() {
<OrganizationEventsV2
organization={TestStubs.Organization()}
location={{query: {}}}
router={{}}
/>,
TestStubs.routerContext()
);
Expand All @@ -69,6 +71,7 @@ describe('OrganizationEventsV2', function() {
<OrganizationEventsV2
organization={TestStubs.Organization({projects: [TestStubs.Project()]})}
location={{query: {}}}
router={{}}
/>,
TestStubs.routerContext()
);
Expand All @@ -82,8 +85,9 @@ describe('OrganizationEventsV2', function() {
const wrapper = mount(
<OrganizationEventsV2
organization={organization}
location={{query: {eventSlug: 'project-slug:deadbeef'}}}
params={{orgId: organization.slug}}
location={{query: {eventSlug: 'project-slug:deadbeef'}}}
router={{}}
/>,
TestStubs.routerContext()
);
Expand All @@ -109,6 +113,7 @@ describe('OrganizationEventsV2', function() {
organization={organization}
params={{orgId: organization.slug}}
location={routerContext.context.location}
router={{}}
/>,
routerContext
);
Expand Down Expand Up @@ -144,6 +149,7 @@ describe('OrganizationEventsV2', function() {
organization={organization}
params={{orgId: organization.slug}}
location={routerContext.context.location}
router={{}}
/>,
routerContext
);
Expand Down