resources.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
  19. ...(configResources.linksByPlatform[eventPlatform ?? ''] ?? []),
  20. ];
  21. return (
  22. <div>
  23. <p>{configResources.description}</p>
  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. priority="link"
  38. >
  39. {text}
  40. </LinkButton>
  41. ))}
  42. </LinkSection>
  43. </div>
  44. );
  45. }
  46. const LinkSection = styled('div')`
  47. display: flex;
  48. flex-direction: column;
  49. align-items: flex-start;
  50. text-decoration: underline;
  51. text-decoration-color: ${p => p.theme.linkUnderline};
  52. gap: ${space(1)};
  53. margin-top: ${space(1)};
  54. `;