index.tsx 4.1 KB

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