resourcesAndMaybeSolutions.tsx 2.1 KB

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