index.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import {Component} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import {Client} from 'sentry/api';
  5. import NotFound from 'sentry/components/errors/notFound';
  6. import {BorderlessEventEntries} from 'sentry/components/events/eventEntries';
  7. import Footer from 'sentry/components/footer';
  8. import Link from 'sentry/components/links/link';
  9. import LoadingError from 'sentry/components/loadingError';
  10. import LoadingIndicator from 'sentry/components/loadingIndicator';
  11. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  12. import {t} from 'sentry/locale';
  13. import SentryTypes from 'sentry/sentryTypes';
  14. import space from 'sentry/styles/space';
  15. import {Group} from 'sentry/types';
  16. import withApi from 'sentry/utils/withApi';
  17. import SharedGroupHeader from './sharedGroupHeader';
  18. type Props = RouteComponentProps<{shareId: string}, {}> & {
  19. api: Client;
  20. };
  21. type State = {
  22. error: boolean;
  23. group: Group | null;
  24. loading: boolean;
  25. };
  26. class SharedGroupDetails extends Component<Props, State> {
  27. static childContextTypes = {
  28. group: SentryTypes.Group,
  29. };
  30. state: State = this.getInitialState();
  31. getInitialState() {
  32. return {
  33. group: null,
  34. loading: true,
  35. error: false,
  36. };
  37. }
  38. getChildContext() {
  39. return {
  40. group: this.state.group,
  41. };
  42. }
  43. componentWillMount() {
  44. document.body.classList.add('shared-group');
  45. }
  46. componentDidMount() {
  47. this.fetchData();
  48. }
  49. componentWillUnmount() {
  50. document.body.classList.remove('shared-group');
  51. }
  52. async fetchData() {
  53. const {params, api} = this.props;
  54. const {shareId} = params;
  55. try {
  56. const group = await api.requestPromise(`/shared/issues/${shareId}/`);
  57. this.setState({loading: false, group});
  58. } catch {
  59. this.setState({loading: false, error: true});
  60. }
  61. }
  62. handleRetry = () => {
  63. this.setState(this.getInitialState());
  64. this.fetchData();
  65. };
  66. getTitle() {
  67. const {group} = this.state;
  68. return group?.title ?? 'Sentry';
  69. }
  70. render() {
  71. const {group, loading, error} = this.state;
  72. if (loading) {
  73. return <LoadingIndicator />;
  74. }
  75. if (!group) {
  76. return <NotFound />;
  77. }
  78. if (error) {
  79. return <LoadingError onRetry={this.handleRetry} />;
  80. }
  81. const {location, api, route, router} = this.props;
  82. const {permalink, latestEvent, project} = group;
  83. const title = this.getTitle();
  84. return (
  85. <SentryDocumentTitle noSuffix title={title}>
  86. <div className="app">
  87. <div className="pattern-bg" />
  88. <div className="container">
  89. <div className="box box-modal">
  90. <div className="box-header">
  91. <Link className="logo" to="/">
  92. <span className="icon-sentry-logo-full" />
  93. </Link>
  94. {permalink && (
  95. <Link className="details" to={permalink}>
  96. {t('Details')}
  97. </Link>
  98. )}
  99. </div>
  100. <div className="box-content">
  101. <SharedGroupHeader group={group} />
  102. <Container className="group-overview event-details-container">
  103. <BorderlessEventEntries
  104. location={location}
  105. organization={project.organization}
  106. group={group}
  107. event={latestEvent}
  108. project={project}
  109. api={api}
  110. route={route}
  111. router={router}
  112. isShare
  113. />
  114. </Container>
  115. <Footer />
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </SentryDocumentTitle>
  121. );
  122. }
  123. }
  124. const Container = styled('div')`
  125. padding: ${space(4)};
  126. `;
  127. export {SharedGroupDetails};
  128. export default withApi(SharedGroupDetails);