-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(events-v2) Add pagination controls to event modal #13610
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/sentry/static/sentry/app/views/organizationEventsV2/modalPagination.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'react-emotion'; | ||
import {omit} from 'lodash'; | ||
|
||
import {t} from 'app/locale'; | ||
import Link from 'app/components/links/link'; | ||
import SentryTypes from 'app/sentryTypes'; | ||
import InlineSvg from 'app/components/inlineSvg'; | ||
import space from 'app/styles/space'; | ||
|
||
const ModalPagination = props => { | ||
const {location, event} = props; | ||
|
||
// Remove the groupId and eventSlug keys as we need to create new ones | ||
const query = omit(location.query, ['groupId', 'eventSlug', 'oldest']); | ||
const previousEventUrl = event.previousEventID | ||
? { | ||
pathname: location.pathname, | ||
query: { | ||
...query, | ||
eventSlug: `${event.projectSlug}:${event.previousEventID}`, | ||
}, | ||
} | ||
: null; | ||
const nextEventUrl = event.nextEventID | ||
? { | ||
pathname: location.pathname, | ||
query: { | ||
...query, | ||
eventSlug: `${event.projectSlug}:${event.nextEventID}`, | ||
}, | ||
} | ||
: null; | ||
const newestUrl = { | ||
pathname: location.pathname, | ||
query: { | ||
...query, | ||
groupId: event.groupID, | ||
}, | ||
}; | ||
const oldestUrl = { | ||
pathname: location.pathname, | ||
query: { | ||
...query, | ||
oldest: 1, | ||
groupId: event.groupID, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Wrapper> | ||
<Container> | ||
<StyledLink to={oldestUrl}> | ||
<InlineSvg src="icon-prev" size="14px" /> | ||
</StyledLink> | ||
<StyledLink to={previousEventUrl} disabled={previousEventUrl === null}> | ||
{t('Older Event')} | ||
</StyledLink> | ||
<StyledLink to={nextEventUrl} disabled={nextEventUrl === null}> | ||
{t('Newer Event')} | ||
</StyledLink> | ||
<StyledLink to={newestUrl} last> | ||
<InlineSvg src="icon-next" size="14px" /> | ||
</StyledLink> | ||
</Container> | ||
</Wrapper> | ||
); | ||
}; | ||
ModalPagination.propTypes = { | ||
location: PropTypes.object.isRequired, | ||
event: SentryTypes.Event.isRequired, | ||
}; | ||
|
||
const StyledLink = styled(Link)` | ||
color: ${p => (p.disabled ? p.theme.disabled : p.theme.gray3)}; | ||
font-size: ${p => p.fontSizeMedium}; | ||
padding: ${space(0.5)} ${space(1.5)}; | ||
${p => (p.last ? '' : `border-right: 1px solid ${p.theme.borderDark};`)} | ||
${p => (p.disabled ? 'pointer-events: none;' : '')} | ||
`; | ||
|
||
const Wrapper = styled('div')` | ||
display: flex; | ||
`; | ||
|
||
const Container = styled('div')` | ||
display: flex; | ||
background: ${p => p.theme.offWhite}; | ||
border: 1px solid ${p => p.theme.borderDark}; | ||
border-radius: ${p => p.theme.borderRadius}; | ||
margin-bottom: ${space(3)}; | ||
box-shadow: 3px 3px 0 ${p => p.theme.offWhite}, 3px 3px 0 1px ${p => p.theme.borderDark}, | ||
7px 7px ${p => p.theme.offWhite}, 7px 7px 0 1px ${p => p.theme.borderDark}; | ||
`; | ||
|
||
export default ModalPagination; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could "oldest" and "latest" just be handled as special cases of eventSlug values? This is similar how it's handled in the issue details views where "oldest" and "latest" are just special eventIds that are handled a bit differently. I think the nice thing about it is that we avoid two additional URL params.
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.
Sure. I like that idea. 👍