index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {useEffect} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {fetchOrganizationEnvironments} from 'sentry/actionCreators/environments';
  4. import {Client} from 'sentry/api';
  5. import LoadingError from 'sentry/components/loadingError';
  6. import LoadingIndicator from 'sentry/components/loadingIndicator';
  7. import {t} from 'sentry/locale';
  8. import OrganizationEnvironmentsStore from 'sentry/stores/organizationEnvironmentsStore';
  9. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  10. import {Environment, Group, Organization, PageFilters, Project} from 'sentry/types';
  11. import {Event} from 'sentry/types/event';
  12. import withApi from 'sentry/utils/withApi';
  13. import withOrganization from 'sentry/utils/withOrganization';
  14. import withPageFilters from 'sentry/utils/withPageFilters';
  15. import {ReprocessingStatus} from '../utils';
  16. import GroupEventDetails from './groupEventDetails';
  17. export interface GroupEventDetailsProps
  18. extends RouteComponentProps<{groupId: string; orgId: string; eventId?: string}, {}> {
  19. api: Client;
  20. event: Event;
  21. eventError: boolean;
  22. group: Group;
  23. groupReprocessingStatus: ReprocessingStatus;
  24. loadingEvent: boolean;
  25. onRetry: () => void;
  26. organization: Organization;
  27. project: Project;
  28. selection: PageFilters;
  29. }
  30. export function GroupEventDetailsContainer(props: GroupEventDetailsProps) {
  31. const state = useLegacyStore(OrganizationEnvironmentsStore);
  32. useEffect(() => {
  33. if (!state.environments && !state.error) {
  34. fetchOrganizationEnvironments(props.api, props.organization.slug);
  35. }
  36. // XXX: Missing dependencies, but it reflects the old of componentDidMount
  37. }, [props.api]);
  38. if (state.error) {
  39. return (
  40. <LoadingError
  41. message={t("There was an error loading your organization's environments")}
  42. />
  43. );
  44. }
  45. // null implies loading state
  46. if (!state.environments) {
  47. return <LoadingIndicator />;
  48. }
  49. const {selection, ...otherProps} = props;
  50. const environments: Environment[] = state.environments.filter(env =>
  51. selection.environments.includes(env.name)
  52. );
  53. return <GroupEventDetails {...otherProps} environments={environments} />;
  54. }
  55. export default withApi(withOrganization(withPageFilters(GroupEventDetailsContainer)));