resources.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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[
  19. (eventPlatform ?? '') as keyof typeof configResources.linksByPlatform
  20. ] ?? []),
  21. ];
  22. return (
  23. <div>
  24. <p>{configResources.description}</p>
  25. <LinkSection>
  26. {links.map(({link, text}) => (
  27. <LinkButton
  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. priority="link"
  39. >
  40. {text}
  41. </LinkButton>
  42. ))}
  43. </LinkSection>
  44. </div>
  45. );
  46. }
  47. const LinkSection = styled('div')`
  48. display: flex;
  49. flex-direction: column;
  50. align-items: flex-start;
  51. text-decoration: underline;
  52. text-decoration-color: ${p => p.theme.linkUnderline};
  53. gap: ${space(1)};
  54. margin-top: ${space(1)};
  55. `;