resourcesAndMaybeSolutions.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import {AiAutofix} from 'sentry/components/events/aiAutofix';
  4. import {AiSuggestedSolution} from 'sentry/components/events/aiSuggestedSolution';
  5. import {EventDataSection} from 'sentry/components/events/eventDataSection';
  6. import {Resources} from 'sentry/components/events/interfaces/performance/resources';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import type {Event, Group, Project} from 'sentry/types';
  10. import {
  11. getConfigForIssueType,
  12. shouldShowCustomErrorResourceConfig,
  13. } from 'sentry/utils/issueTypeConfig';
  14. import useOrganization from 'sentry/utils/useOrganization';
  15. type Props = {
  16. event: Event;
  17. group: Group;
  18. project: Project;
  19. };
  20. // This section provides users with resources and maybe solutions on how to resolve an issue
  21. export function ResourcesAndMaybeSolutions({event, project, group}: Props) {
  22. const organization = useOrganization();
  23. const config = getConfigForIssueType(group, project);
  24. // NOTE: AI Autofix is for INTERNAL testing only for now.
  25. const displayAiAutofix =
  26. project.features.includes('ai-autofix') &&
  27. !shouldShowCustomErrorResourceConfig(group, project);
  28. const displayAiSuggestedSolution =
  29. // Skip showing AI suggested solution if the issue has a custom resource
  30. organization.aiSuggestedSolution &&
  31. !shouldShowCustomErrorResourceConfig(group, project) &&
  32. !displayAiAutofix;
  33. if (!config.resources && !(displayAiSuggestedSolution || displayAiAutofix)) {
  34. return null;
  35. }
  36. return (
  37. <Wrapper
  38. type="resources-and-maybe-solutions"
  39. title={t('Resources and Maybe Solutions')}
  40. configResources={!!config.resources}
  41. >
  42. <Content>
  43. {config.resources && (
  44. <Resources
  45. eventPlatform={event.platform}
  46. groupId={group.id}
  47. configResources={config.resources}
  48. />
  49. )}
  50. {displayAiSuggestedSolution && (
  51. <AiSuggestedSolution event={event} projectSlug={project.slug} />
  52. )}
  53. {displayAiAutofix && <AiAutofix group={group} />}
  54. </Content>
  55. </Wrapper>
  56. );
  57. }
  58. const Content = styled('div')`
  59. display: flex;
  60. flex-direction: column;
  61. gap: ${space(2)};
  62. `;
  63. const Wrapper = styled(EventDataSection)<{configResources: boolean}>`
  64. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  65. ${p =>
  66. !p.configResources &&
  67. css`
  68. && {
  69. padding-top: ${space(3)};
  70. }
  71. `}
  72. }
  73. `;