-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(ui): Adds related issues to Incidents sidebar [SEN-695] #13617
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from 'react-emotion'; | ||
|
||
import space from 'app/styles/space'; | ||
|
||
const Placeholder = styled('div')` | ||
background-color: ${p => p.theme.placeholderBackground}; | ||
padding: ${space(4)}; | ||
margin-bottom: ${space(1)}; | ||
`; | ||
|
||
export default Placeholder; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import styled from 'react-emotion'; | ||
|
||
import {Panel, PanelBody, PanelItem} from 'app/components/panels'; | ||
import {t} from 'app/locale'; | ||
import EventOrGroupExtraDetails from 'app/components/eventOrGroupExtraDetails'; | ||
import EventOrGroupHeader from 'app/components/eventOrGroupHeader'; | ||
import SentryTypes from 'app/sentryTypes'; | ||
import space from 'app/styles/space'; | ||
import withApi from 'app/utils/withApi'; | ||
import withOrganization from 'app/utils/withOrganization'; | ||
|
||
import IssuesFetcher from './issuesFetcher'; | ||
import Placeholder from '../placeholder'; | ||
import SideHeader from '../sideHeader'; | ||
|
||
const RelatedIssues = styled( | ||
class RelatedIssues extends React.Component { | ||
static propTypes = { | ||
api: PropTypes.object.isRequired, | ||
params: PropTypes.object.isRequired, | ||
incident: SentryTypes.Incident, | ||
loading: PropTypes.bool, | ||
}; | ||
|
||
render() { | ||
const {className, api, params, incident} = this.props; | ||
|
||
return ( | ||
<div className={className}> | ||
<IssuesFetcher api={api} issueIds={incident && incident.groups}> | ||
{({issues, loading, error}) => { | ||
// If loading is finished, and there are no issues, do not display anything | ||
if (!loading && issues && issues.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
<SideHeader loading={loading}> | ||
{t('Related Issues')} ({loading || !issues ? '-' : issues.length}) | ||
</SideHeader> | ||
{loading ? ( | ||
<Placeholder /> | ||
) : ( | ||
issues && | ||
issues.length > 0 && ( | ||
<Panel> | ||
<PanelBody> | ||
{issues.map(issue => ( | ||
<RelatedItem p={1} key={issue.id}> | ||
<EventOrGroupHeader | ||
params={params} | ||
size="small" | ||
hideLevel | ||
data={issue} | ||
/> | ||
<EventOrGroupExtraDetails params={params} {...issue} /> | ||
</RelatedItem> | ||
))} | ||
</PanelBody> | ||
</Panel> | ||
) | ||
)} | ||
</React.Fragment> | ||
); | ||
}} | ||
</IssuesFetcher> | ||
</div> | ||
); | ||
} | ||
} | ||
)` | ||
margin-top: ${space(1)}; | ||
`; | ||
|
||
export default withOrganization(withApi(RelatedIssues)); | ||
|
||
const RelatedItem = styled(PanelItem)` | ||
flex-direction: column; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
class IssuesFetcher extends React.PureComponent { | ||
static propTypes = { | ||
api: PropTypes.object, | ||
issueIds: PropTypes.arrayOf(PropTypes.string), | ||
}; | ||
|
||
state = { | ||
loading: true, | ||
issues: null, | ||
error: null, | ||
}; | ||
|
||
componentDidMount() { | ||
this.fetchData(); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if (prevProps.issueIds !== this.props.issueIds) { | ||
this.fetchData(); | ||
} | ||
} | ||
|
||
fetchData = async () => { | ||
const {api, issueIds} = this.props; | ||
|
||
if (!issueIds) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are no issues, how does this component leave its loading state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by moving where we set loading state: https://github.com/getsentry/sentry/pull/13617/files#diff-488f70254ef5984b677ed6927ad48ca9R33 |
||
return; | ||
} | ||
|
||
this.setState({loading: true}); | ||
|
||
try { | ||
const issues = await Promise.all( | ||
issueIds.map(issueId => findIssueById(api, issueId)) | ||
); | ||
this.setState({ | ||
loading: false, | ||
issues, | ||
}); | ||
} catch (error) { | ||
console.error(error); // eslint-disable-line no-console | ||
this.setState({loading: false, error}); | ||
} | ||
}; | ||
|
||
render() { | ||
return this.props.children(this.state); | ||
} | ||
} | ||
|
||
function findIssueById(api, issueId) { | ||
return api.requestPromise(`/issues/${issueId}/`); | ||
} | ||
|
||
export default IssuesFetcher; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should something show when there are 0 issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed to make sure entire block does not show (including header) - will follow up to see if this is what we want.