help.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import styled from '@emotion/styled';
  2. import {openHelpSearchModal} from 'sentry/actionCreators/modal';
  3. import DeprecatedDropdownMenu from 'sentry/components/deprecatedDropdownMenu';
  4. import Hook from 'sentry/components/hook';
  5. import SidebarItem from 'sentry/components/sidebar/sidebarItem';
  6. import {IconQuestion} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import type {Organization} from 'sentry/types/organization';
  10. import SidebarDropdownMenu from './sidebarDropdownMenu.styled';
  11. import SidebarMenuItem from './sidebarMenuItem';
  12. import type {CommonSidebarProps} from './types';
  13. type Props = Pick<
  14. CommonSidebarProps,
  15. 'collapsed' | 'hidePanel' | 'orientation' | 'hasNewNav'
  16. > & {
  17. organization: Organization;
  18. };
  19. function SidebarHelp({orientation, collapsed, hidePanel, organization}: Props) {
  20. return (
  21. <DeprecatedDropdownMenu>
  22. {({isOpen, getActorProps, getMenuProps}) => (
  23. <HelpRoot>
  24. <HelpActor {...getActorProps({onClick: hidePanel})}>
  25. <SidebarItem
  26. data-test-id="help-sidebar"
  27. orientation={orientation}
  28. collapsed={collapsed}
  29. hasPanel={false}
  30. icon={<IconQuestion size="md" />}
  31. label={t('Help')}
  32. id="help"
  33. />
  34. </HelpActor>
  35. {isOpen && (
  36. <HelpMenu {...getMenuProps({})} orientation={orientation}>
  37. <SidebarMenuItem
  38. data-test-id="search-docs-and-faqs"
  39. onClick={() => openHelpSearchModal({organization})}
  40. >
  41. {t('Search Support, Docs and More')}
  42. </SidebarMenuItem>
  43. <SidebarMenuItem href="https://sentry.zendesk.com/hc/en-us">
  44. {t('Visit Help Center')}
  45. </SidebarMenuItem>
  46. <SidebarMenuItem href="https://discord.com/invite/sentry">
  47. {t('Join our Discord')}
  48. </SidebarMenuItem>
  49. <Hook name="sidebar:help-menu" organization={organization} />
  50. </HelpMenu>
  51. )}
  52. </HelpRoot>
  53. )}
  54. </DeprecatedDropdownMenu>
  55. );
  56. }
  57. export default SidebarHelp;
  58. const HelpRoot = styled('div')`
  59. position: relative;
  60. `;
  61. // This exists to provide a styled actor for the dropdown. Making the actor a regular,
  62. // non-styled react component causes some issues with toggling correctly because of
  63. // how refs are handled.
  64. const HelpActor = styled('div')``;
  65. const HelpMenu = styled('div', {shouldForwardProp: p => p !== 'orientation'})<{
  66. orientation: Props['orientation'];
  67. }>`
  68. ${SidebarDropdownMenu};
  69. ${p => (p.orientation === 'left' ? 'bottom: 100%' : `top: ${space(4)}; right: 0px;`)}
  70. `;