resources.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. <LinkButton
  27. onClick={() =>
  28. trackAnalytics('issue_details.resources_link_clicked', {
  29. organization,
  30. resource: text,
  31. group_id: group.id,
  32. })
  33. }
  34. key={link}
  35. href={link}
  36. external
  37. >
  38. {text}
  39. </LinkButton>
  40. ))}
  41. </LinkSection>
  42. </div>
  43. );
  44. }
  45. const LinkSection = styled('div')`
  46. display: flex;
  47. gap: ${space(1)};
  48. margin-top: ${space(1)};
  49. `;