index.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import Feature from 'sentry/components/acl/feature';
  4. import FeatureDisabled from 'sentry/components/acl/featureDisabled';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import LoadingError from 'sentry/components/loadingError';
  7. import LoadingIndicator from 'sentry/components/loadingIndicator';
  8. import {t} from 'sentry/locale';
  9. import {space} from 'sentry/styles/space';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import {useParams} from 'sentry/utils/useParams';
  12. import {useGroup} from 'sentry/views/issueDetails/useGroup';
  13. import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
  14. import GroupEventAttachments from './groupEventAttachments';
  15. function GroupEventAttachmentsContainer() {
  16. const organization = useOrganization();
  17. const hasStreamlinedUI = useHasStreamlinedUI();
  18. const params = useParams();
  19. const {
  20. data: group,
  21. isPending: isGroupPending,
  22. isError: isGroupError,
  23. refetch: refetchGroup,
  24. } = useGroup({groupId: params.groupId});
  25. if (isGroupPending) {
  26. return <LoadingIndicator />;
  27. }
  28. if (isGroupError) {
  29. return <LoadingError onRetry={refetchGroup} />;
  30. }
  31. return (
  32. <Feature
  33. features="event-attachments"
  34. organization={organization}
  35. renderDisabled={props => (
  36. <FeatureDisabled {...props} featureName={t('Event Attachments')} />
  37. )}
  38. >
  39. <StyledLayoutBody hasStreamlinedUI={hasStreamlinedUI}>
  40. <Layout.Main fullWidth>
  41. <GroupEventAttachments project={group.project} groupId={group.id} />
  42. </Layout.Main>
  43. </StyledLayoutBody>
  44. </Feature>
  45. );
  46. }
  47. const StyledLayoutBody = styled(Layout.Body)<{hasStreamlinedUI?: boolean}>`
  48. ${p =>
  49. p.hasStreamlinedUI &&
  50. css`
  51. border: 1px solid ${p.theme.border};
  52. border-radius: ${p.theme.borderRadius};
  53. padding: ${space(2)} 0;
  54. @media (min-width: ${p.theme.breakpoints.medium}) {
  55. padding: ${space(2)} ${space(2)};
  56. }
  57. `}
  58. `;
  59. export default GroupEventAttachmentsContainer;