resources.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import styled from '@emotion/styled';
  2. import {LinkButton} from 'sentry/components/button';
  3. import {space} from 'sentry/styles/space';
  4. import type {Event} from 'sentry/types/event';
  5. import type {Group} from 'sentry/types/group';
  6. import {IssueCategory} from 'sentry/types/group';
  7. import {trackAnalytics} from 'sentry/utils/analytics';
  8. import type {IssueTypeConfig, ResourceLink} from 'sentry/utils/issueTypeConfig/types';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. type Props = {
  11. configResources: NonNullable<IssueTypeConfig['resources']>;
  12. eventPlatform: Event['platform'];
  13. group: Group;
  14. };
  15. export default function Resources({configResources, eventPlatform, group}: Props) {
  16. const organization = useOrganization();
  17. const links: ResourceLink[] = [
  18. ...configResources.links,
  19. ...(configResources.linksByPlatform[eventPlatform ?? ''] ?? []),
  20. ];
  21. return (
  22. <div>
  23. {group.issueCategory !== IssueCategory.ERROR && configResources.description}
  24. <LinkSection>
  25. {links.map(({link, text}) => (
  26. <StyledLinkButton
  27. priority="link"
  28. onClick={() =>
  29. trackAnalytics('issue_details.resources_link_clicked', {
  30. organization,
  31. resource: text,
  32. group_id: group.id,
  33. })
  34. }
  35. key={link}
  36. href={link}
  37. external
  38. >
  39. {text}
  40. </StyledLinkButton>
  41. ))}
  42. </LinkSection>
  43. </div>
  44. );
  45. }
  46. const LinkSection = styled('div')`
  47. display: flex;
  48. flex-direction: column;
  49. gap: ${space(1)};
  50. margin-top: ${space(1)};
  51. `;
  52. const StyledLinkButton = styled(LinkButton)`
  53. text-decoration: underline;
  54. align-self: flex-start;
  55. `;