Skip to content
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

feat(events-v2): Add proper links to elements in event table #13660

Merged
merged 1 commit into from
Jun 12, 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
28 changes: 21 additions & 7 deletions src/sentry/static/sentry/app/views/organizationEventsV2/data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ export const SPECIAL_FIELDS = {
},
type: {
fields: ['event.type'],
renderFunc: (data, {onSearch}) => (
<QueryLink onClick={() => onSearch(`event.type:${data['event.type']}`)}>
{data['event.type']}
</QueryLink>
),
renderFunc: (data, {location, organization}) => {
const target = {
pathname: `/organizations/${organization.slug}/events/`,
query: {
...location.query,
query: `event.type:${data['event.type']}`,
},
};

return <QueryLink to={target}>{data['event.type']}</QueryLink>;
},
},
project: {
fields: ['project.name'],
Expand All @@ -104,7 +110,7 @@ export const SPECIAL_FIELDS = {
},
user: {
fields: ['user', 'user.name', 'user.email', 'user.ip'],
renderFunc: (data, {onSearch}) => {
renderFunc: (data, {organization, location}) => {
const userObj = {
name: data['user.name'],
email: data['user.email'],
Expand All @@ -117,7 +123,15 @@ export const SPECIAL_FIELDS = {
return <Container>{badge}</Container>;
}

return <QueryLink onClick={() => onSearch(`user:${data.user}`)}>{badge}</QueryLink>;
const target = {
pathname: `/organizations/${organization.slug}/events/`,
query: {
...location.query,
query: `user:${data.user}`,
},
};

return <QueryLink to={target}>{badge}</QueryLink>;
},
},
time: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export default class Events extends AsyncComponent {
organization={organization}
data={data}
isLoading={loading}
onSearch={this.handleSearch}
location={location}
/>
<Pagination pageLinks={dataPageLinks} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styled from 'react-emotion';
import space from 'app/styles/space';
import overflowEllipsis from 'app/styles/overflowEllipsis';
import Link from 'app/components/links/link';

export const QueryLink = styled('a')`
export const QueryLink = styled(Link)`
${overflowEllipsis};
color: ${p => p.theme.foreground};
padding: ${space(1)};
Expand Down
33 changes: 20 additions & 13 deletions src/sentry/static/sentry/app/views/organizationEventsV2/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ export default class Table extends React.Component {
data: PropTypes.arrayOf(PropTypes.object),
isLoading: PropTypes.bool,
organization: SentryTypes.Organization.isRequired,
onSearch: PropTypes.func.isRequired,
location: PropTypes.object,
};

renderBody() {
const {view, data, organization, onSearch, location} = this.props;
const {view, data, organization, location} = this.props;
const {fields} = view.data;

if (!data) {
Expand All @@ -41,17 +40,25 @@ export default class Table extends React.Component {

return data.map((row, idx) => (
<Row key={idx} className={getGridStyle(fields.length)}>
{fields.map(field => (
<Cell key={field}>
{SPECIAL_FIELDS.hasOwnProperty(field) ? (
SPECIAL_FIELDS[field].renderFunc(row, {organization, onSearch, location})
) : (
<QueryLink onClick={() => onSearch(`${field}:${row[field]}`)}>
{row[field]}
</QueryLink>
)}
</Cell>
))}
{fields.map(field => {
const target = {
pathname: `/organizations/${organization.slug}/events/`,
query: {
...location.query,
query: `${field}:${row[field]}`,
},
};

return (
<Cell key={field}>
{SPECIAL_FIELDS.hasOwnProperty(field) ? (
SPECIAL_FIELDS[field].renderFunc(row, {organization, location})
) : (
<QueryLink to={target}>{row[field]}</QueryLink>
)}
</Cell>
);
})}
</Row>
));
}
Expand Down