resourcesAndMaybeSolutions.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 =
  21. organization.aiSuggestedSolution &&
  22. organization.features.includes('open-ai-suggestion');
  23. if (!config.resources && !displayAiSuggestedSolution) {
  24. return null;
  25. }
  26. return (
  27. <Wrapper
  28. type="resources-and-maybe-solutions"
  29. title={t('Resources and Maybe Solutions')}
  30. configResources={!!config.resources}
  31. >
  32. <Content>
  33. {config.resources && (
  34. <Resources eventPlatform={event.platform} configResources={config.resources} />
  35. )}
  36. {displayAiSuggestedSolution && (
  37. <AiSuggestedSolution event={event} projectSlug={projectSlug} />
  38. )}
  39. </Content>
  40. </Wrapper>
  41. );
  42. }
  43. const Content = styled('div')`
  44. display: flex;
  45. flex-direction: column;
  46. gap: ${space(2)};
  47. `;
  48. const Wrapper = styled(EventDataSection)<{configResources: boolean}>`
  49. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  50. ${p =>
  51. !p.configResources &&
  52. css`
  53. && {
  54. padding-top: ${space(3)};
  55. }
  56. `}
  57. }
  58. `;