resourcesAndMaybeSolutions.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import {AiSuggestedSolution} from 'sentry/components/events/aiSuggestedSolution';
  4. import {Autofix} from 'sentry/components/events/autofix';
  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: Autofix is for INTERNAL testing only for now.
  25. const displayAiAutofix =
  26. project.features.includes('ai-autofix') &&
  27. organization.features.includes('issue-details-autofix-ui') &&
  28. !shouldShowCustomErrorResourceConfig(group, project);
  29. const displayAiSuggestedSolution =
  30. // Skip showing AI suggested solution if the issue has a custom resource
  31. organization.aiSuggestedSolution &&
  32. !shouldShowCustomErrorResourceConfig(group, project) &&
  33. !displayAiAutofix;
  34. if (!config.resources && !(displayAiSuggestedSolution || displayAiAutofix)) {
  35. return null;
  36. }
  37. return (
  38. <Wrapper
  39. type="resources-and-maybe-solutions"
  40. title={t('Resources and Maybe Solutions')}
  41. configResources={!!config.resources}
  42. >
  43. <Content>
  44. {config.resources && (
  45. <Resources
  46. eventPlatform={event.platform}
  47. groupId={group.id}
  48. configResources={config.resources}
  49. />
  50. )}
  51. {displayAiSuggestedSolution && (
  52. <AiSuggestedSolution event={event} projectSlug={project.slug} />
  53. )}
  54. {displayAiAutofix && <Autofix event={event} group={group} />}
  55. </Content>
  56. </Wrapper>
  57. );
  58. }
  59. const Content = styled('div')`
  60. display: flex;
  61. flex-direction: column;
  62. gap: ${space(2)};
  63. `;
  64. const Wrapper = styled(EventDataSection)<{configResources: boolean}>`
  65. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  66. ${p =>
  67. !p.configResources &&
  68. css`
  69. && {
  70. padding-top: ${space(3)};
  71. }
  72. `}
  73. }
  74. `;