index.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {useEffect} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {fetchProjectDetails} from 'sentry/actionCreators/project';
  4. import {PageFilters} from 'sentry/types';
  5. import {analytics} from 'sentry/utils/analytics';
  6. import useApi from 'sentry/utils/useApi';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import useProjects from 'sentry/utils/useProjects';
  9. import withPageFilters from 'sentry/utils/withPageFilters';
  10. import GroupDetails from './groupDetails';
  11. type Props = {
  12. children: React.ReactNode;
  13. isGlobalSelectionReady: boolean;
  14. selection: PageFilters;
  15. } & RouteComponentProps<{groupId: string}, {}>;
  16. function IssueDetailsContainer({selection, ...props}: Props) {
  17. const organization = useOrganization();
  18. const {projects} = useProjects();
  19. const api = useApi();
  20. const {params, location} = props;
  21. const projectId = location.query.project;
  22. const project = projects.find(proj => proj.id === projectId);
  23. useEffect(() => {
  24. if (!project?.slug) {
  25. return;
  26. }
  27. fetchProjectDetails({api, orgSlug: organization.slug, projSlug: project.slug});
  28. }, [api, organization.slug, project?.slug]);
  29. useEffect(() => {
  30. analytics('issue_page.viewed', {
  31. group_id: parseInt(params.groupId, 10),
  32. org_id: parseInt(organization.id, 10),
  33. });
  34. }, [organization, params.groupId]);
  35. return (
  36. <GroupDetails
  37. key={`${params.groupId}-envs:${selection.environments.join(',')}`}
  38. environments={selection.environments}
  39. organization={organization}
  40. projects={projects}
  41. {...props}
  42. />
  43. );
  44. }
  45. export default withPageFilters(IssueDetailsContainer);