container.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, {Component} from 'react';
  2. import DocumentTitle from 'react-document-title';
  3. import NoProjectMessage from 'app/components/noProjectMessage';
  4. import GlobalSelectionHeader from 'app/components/organizations/globalSelectionHeader';
  5. import GroupStore from 'app/stores/groupStore';
  6. import {Organization, Project} from 'app/types';
  7. import {callIfFunction} from 'app/utils/callIfFunction';
  8. import withOrganization from 'app/utils/withOrganization';
  9. import SampleEventAlert from 'app/views/organizationGroupDetails/sampleEventAlert';
  10. type Props = {
  11. organization: Organization;
  12. projects: Project[];
  13. };
  14. type State = {
  15. showSampleEventBanner: boolean;
  16. };
  17. class IssueListContainer extends Component<Props, State> {
  18. state: State = {
  19. showSampleEventBanner: false,
  20. };
  21. listener = GroupStore.listen(() => this.onGroupChange(), undefined);
  22. render() {
  23. const {organization, children} = this.props;
  24. return (
  25. <DocumentTitle title={this.getTitle()}>
  26. <React.Fragment>
  27. {this.state.showSampleEventBanner && <SampleEventAlert />}
  28. <GlobalSelectionHeader>
  29. <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
  30. </GlobalSelectionHeader>
  31. </React.Fragment>
  32. </DocumentTitle>
  33. );
  34. }
  35. onGroupChange() {
  36. this.setState({
  37. showSampleEventBanner: GroupStore.getAllItemIds().length === 1,
  38. });
  39. }
  40. componentWillUnmount() {
  41. callIfFunction(this.listener);
  42. }
  43. getTitle() {
  44. return `Issues - ${this.props.organization.slug} - Sentry`;
  45. }
  46. }
  47. export default withOrganization(IssueListContainer);
  48. export {IssueListContainer};