Skip to content

Commit d49dc7d

Browse files
authored
ref(events-v2) Use an object target instead building URLs (#13471)
Use `Link` feature to generate a URL from `pathname` and `query` instead of cooking up string URLs. Refs SEN-648
1 parent a480d1c commit d49dc7d

File tree

2 files changed

+6
-11
lines changed
  • src/sentry/static/sentry/app/views/organizationEventsV2
  • tests/js/spec/views/organizationEventsV2

2 files changed

+6
-11
lines changed

src/sentry/static/sentry/app/views/organizationEventsV2/data.jsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import styled from 'react-emotion';
3-
import qs from 'query-string';
43

54
import {deepFreeze} from 'app/utils';
65
import DynamicWrapper from 'app/components/dynamicWrapper';
@@ -71,17 +70,13 @@ export const SPECIAL_FIELDS = {
7170
event: {
7271
fields: ['title', 'id', 'project.name'],
7372
renderFunc: (data, {organization, location}) => {
74-
const newQuery = qs.stringify({
75-
...location.query,
76-
eventSlug: `${data['project.name']}:${data.id}`,
77-
});
73+
const target = {
74+
pathname: `/organizations/${organization.slug}/events/`,
75+
query: {...location.query, eventSlug: `${data['project.name']}:${data.id}`},
76+
};
7877
return (
7978
<Container>
80-
<Link
81-
css={overflowEllipsis}
82-
to={`/organizations/${organization.slug}/events/?${newQuery}`}
83-
data-test-id="event-title"
84-
>
79+
<Link css={overflowEllipsis} to={target} data-test-id="event-title">
8580
{data.title}
8681
</Link>
8782
</Container>

tests/js/spec/views/organizationEventsV2/index.spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('OrganizationEventsV2', function() {
6464
);
6565

6666
const link = wrapper.find('Table Link[data-test-id="event-title"]').first();
67-
expect(link.props().to).toEqual(expect.stringContaining('eventSlug=project-slug'));
67+
expect(link.props().to.query).toEqual({eventSlug: 'project-slug:deadbeef'});
6868
});
6969

7070
it('opens a modal when eventSlug is present', async function() {

0 commit comments

Comments
 (0)