resources.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import styled from '@emotion/styled';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {IconDocs} from 'sentry/icons';
  4. import {space} from 'sentry/styles/space';
  5. import type {Event} from 'sentry/types';
  6. import {trackAnalytics} from 'sentry/utils/analytics';
  7. import type {IssueTypeConfig} from 'sentry/utils/issueTypeConfig/types';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. export type ResourceLink = {
  10. link: string;
  11. text: string;
  12. };
  13. type Props = {
  14. configResources: NonNullable<IssueTypeConfig['resources']>;
  15. eventPlatform: Event['platform'];
  16. groupId: string;
  17. };
  18. // This section provides users with resources on how to resolve an issue
  19. export function Resources({configResources, eventPlatform, groupId}: Props) {
  20. const organization = useOrganization();
  21. const links = [
  22. ...configResources.links,
  23. ...(configResources.linksByPlatform[eventPlatform ?? ''] ?? []),
  24. ];
  25. return (
  26. <div>
  27. {configResources.description}
  28. <LinkSection>
  29. {links.map(({link, text}) => (
  30. // Please note that the UI will not fit a very long text and if we need to support that we will need to update the UI
  31. <ExternalLink
  32. onClick={() =>
  33. trackAnalytics('issue_details.resources_link_clicked', {
  34. organization,
  35. resource: text,
  36. group_id: groupId,
  37. })
  38. }
  39. key={link}
  40. href={link}
  41. openInNewTab
  42. >
  43. <IconDocs /> {text}
  44. </ExternalLink>
  45. ))}
  46. </LinkSection>
  47. </div>
  48. );
  49. }
  50. const LinkSection = styled('div')`
  51. display: flex;
  52. flex-direction: column;
  53. gap: ${space(1)};
  54. margin-top: ${space(2)};
  55. a {
  56. display: flex;
  57. align-items: center;
  58. width: max-content;
  59. }
  60. svg {
  61. margin-right: ${space(1)};
  62. }
  63. `;