resourcesAndMaybeSolutions.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 type {Event, Group, Project} from 'sentry/types';
  9. import {
  10. getConfigForIssueType,
  11. shouldShowCustomErrorResourceConfig,
  12. } from 'sentry/utils/issueTypeConfig';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. type Props = {
  15. event: Event;
  16. group: Group;
  17. projectSlug: Project['slug'];
  18. };
  19. // This section provides users with resources and maybe solutions on how to resolve an issue
  20. export function ResourcesAndMaybeSolutions({event, projectSlug, group}: Props) {
  21. const organization = useOrganization();
  22. const config = getConfigForIssueType(group);
  23. const displayAiSuggestedSolution =
  24. // Skip showing AI suggested solution if the issue has a custom resource
  25. organization.aiSuggestedSolution && !shouldShowCustomErrorResourceConfig(group);
  26. if (!config.resources && !displayAiSuggestedSolution) {
  27. return null;
  28. }
  29. return (
  30. <Wrapper
  31. type="resources-and-maybe-solutions"
  32. title={t('Resources and Maybe Solutions')}
  33. configResources={!!config.resources}
  34. >
  35. <Content>
  36. {config.resources && (
  37. <Resources
  38. eventPlatform={event.platform}
  39. groupId={group.id}
  40. configResources={config.resources}
  41. />
  42. )}
  43. {displayAiSuggestedSolution && (
  44. <AiSuggestedSolution event={event} projectSlug={projectSlug} />
  45. )}
  46. </Content>
  47. </Wrapper>
  48. );
  49. }
  50. const Content = styled('div')`
  51. display: flex;
  52. flex-direction: column;
  53. gap: ${space(2)};
  54. `;
  55. const Wrapper = styled(EventDataSection)<{configResources: boolean}>`
  56. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  57. ${p =>
  58. !p.configResources &&
  59. css`
  60. && {
  61. padding-top: ${space(3)};
  62. }
  63. `}
  64. }
  65. `;