resourcesAndMaybeSolutions.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import {AiSuggestedSolution} from 'sentry/components/events/aiSuggestedSolution';
  4. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  5. import {Resources} from 'sentry/components/events/interfaces/performance/resources';
  6. import {t} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import {Event, Group, Project} from 'sentry/types';
  9. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. type Props = {
  12. event: Event;
  13. group: Group;
  14. projectSlug: Project['slug'];
  15. };
  16. // This section provides users with resources and maybe solutions on how to resolve an issue
  17. export function ResourcesAndMaybeSolutions({event, projectSlug, group}: Props) {
  18. const organization = useOrganization();
  19. const config = getConfigForIssueType(group);
  20. const displayAiSuggestedSolution = organization.aiSuggestedSolution;
  21. if (!config.resources && !displayAiSuggestedSolution) {
  22. return null;
  23. }
  24. return (
  25. <Wrapper
  26. type="resources-and-maybe-solutions"
  27. title={t('Resources and Maybe Solutions')}
  28. configResources={!!config.resources}
  29. >
  30. <Content>
  31. {config.resources && (
  32. <Resources eventPlatform={event.platform} configResources={config.resources} />
  33. )}
  34. {displayAiSuggestedSolution && (
  35. <AiSuggestedSolution event={event} projectSlug={projectSlug} />
  36. )}
  37. </Content>
  38. </Wrapper>
  39. );
  40. }
  41. const Content = styled('div')`
  42. display: flex;
  43. flex-direction: column;
  44. gap: ${space(2)};
  45. `;
  46. const Wrapper = styled(EventDataSection)<{configResources: boolean}>`
  47. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  48. ${p =>
  49. !p.configResources &&
  50. css`
  51. && {
  52. padding-top: ${space(3)};
  53. }
  54. `}
  55. }
  56. `;