Skip to content

feat(events-v2) Add rough sketch of event modal #13415

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 6 commits into from
May 30, 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
35 changes: 4 additions & 31 deletions src/sentry/static/sentry/app/components/eventOrGroupHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ProjectLink from 'app/components/projectLink';
import {Metadata} from 'app/sentryTypes';
import EventOrGroupTitle from 'app/components/eventOrGroupTitle';
import Tooltip from 'app/components/tooltip';
import {isNativePlatform} from 'app/utils/platform';
import {getMessage, getLocation} from 'app/utils/events';

/**
* Displays an event or group/issue title (i.e. in Stream)
Expand Down Expand Up @@ -44,33 +44,6 @@ class EventOrGroupHeader extends React.Component {
includeLink: true,
};

getMessage() {
const {data} = this.props;
const {metadata, type, culprit} = data || {};

switch (type) {
case 'error':
return metadata.value;
case 'csp':
return metadata.message;
case 'expectct':
case 'expectstaple':
case 'hpkp':
return '';
default:
return culprit || '';
}
}

getLocation() {
const {data} = this.props;
if (data.type === 'error' && isNativePlatform(data.platform)) {
const {metadata} = data || {};
return metadata.filename || null;
}
return null;
}

getTitle() {
const {hideIcons, hideLevel, includeLink, data, params} = this.props;
const {orgId, projectId} = params;
Expand Down Expand Up @@ -126,10 +99,10 @@ class EventOrGroupHeader extends React.Component {
}

render() {
const {className} = this.props;
const {className, data} = this.props;
const cx = classNames('event-issue-header', className);
const message = this.getMessage();
const location = this.getLocation();
const location = getLocation(data);
const message = getMessage(data);

return (
<div className={cx}>
Expand Down
25 changes: 3 additions & 22 deletions src/sentry/static/sentry/app/components/eventOrGroupTitle.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import {Metadata} from 'app/sentryTypes';
import {getTitle} from 'app/utils/events';

class EventOrGroupTitle extends React.Component {
static propTypes = {
Expand All @@ -17,31 +18,11 @@ class EventOrGroupTitle extends React.Component {
metadata: Metadata.isRequired,
culprit: PropTypes.string,
}),
style: PropTypes.object,
};

render() {
const {data} = this.props;
const {metadata, type, culprit} = data;
let {title} = data;
let subtitle = null;

if (type == 'error') {
subtitle = culprit;
if (metadata.type) {
title = metadata.type;
} else {
title = metadata.function || '<unknown>';
}
} else if (type == 'csp') {
title = metadata.directive;
subtitle = metadata.uri;
} else if (type === 'expectct' || type === 'expectstaple' || type === 'hpkp') {
title = metadata.message;
subtitle = metadata.origin;
} else if (type == 'default') {
title = metadata.title;
}

const {title, subtitle} = getTitle(this.props.data);
if (subtitle) {
return (
<span style={this.props.style}>
Expand Down
57 changes: 57 additions & 0 deletions src/sentry/static/sentry/app/utils/events.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {isNativePlatform} from 'app/utils/platform';

/**
* Extract the display message from an event.
*/
export function getMessage(event) {
const {metadata, type, culprit} = event;

switch (type) {
case 'error':
return metadata.value;
case 'csp':
return metadata.message;
case 'expectct':
case 'expectstaple':
case 'hpkp':
return '';
default:
return culprit || '';
}
}

/**
* Get the location from an event.
*/
export function getLocation(event) {
if (event.type === 'error' && isNativePlatform(event.platform)) {
const {metadata} = event || {};
return metadata.filename || null;
}
return null;
}

export function getTitle(event) {
const {metadata, type, culprit} = event;
let {title} = event;
let subtitle = null;

if (type == 'error') {
subtitle = culprit;
if (metadata.type) {
title = metadata.type;
} else {
title = metadata.function || '<unknown>';
}
} else if (type == 'csp') {
title = metadata.directive;
subtitle = metadata.uri;
} else if (type === 'expectct' || type === 'expectstaple' || type === 'hpkp') {
title = metadata.message;
subtitle = metadata.origin;
} else if (type == 'default') {
title = metadata.title;
}

return {title, subtitle};
}
30 changes: 18 additions & 12 deletions src/sentry/static/sentry/app/views/organizationEventsV2/data.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import styled from 'react-emotion';
import qs from 'query-string';

import {deepFreeze} from 'app/utils';
import DynamicWrapper from 'app/components/dynamicWrapper';
Expand Down Expand Up @@ -69,18 +70,23 @@ export const ALL_VIEWS = deepFreeze([
export const SPECIAL_FIELDS = {
event: {
fields: ['title', 'id', 'project.name'],
renderFunc: (data, {organization}) => (
<Container>
<Link
css={overflowEllipsis}
to={`/organizations/${organization.slug}/projects/${
data['project.name']
}/events/${data.id}/`}
>
{data.title}
</Link>
</Container>
),
renderFunc: (data, {organization, location}) => {
const newQuery = qs.stringify({
...location.query,
eventSlug: `${data['project.name']}:${data.id}`,
});
return (
<Container>
<Link
css={overflowEllipsis}
to={`/organizations/${organization.slug}/events/?${newQuery}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making our own query string, we could pass to an object with pathname and query keys.

data-test-id="event-title"
>
{data.title}
</Link>
</Container>
);
},
},
project: {
fields: ['project.name'],
Expand Down
Loading