resources.tsx 1.6 KB

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