crashTitle.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled from '@emotion/styled';
  2. import GuideAnchor from 'sentry/components/assistant/guideAnchor';
  3. import Tooltip from 'sentry/components/tooltip';
  4. import {t} from 'sentry/locale';
  5. type Props = {
  6. newestFirst: boolean;
  7. title: string;
  8. beforeTitle?: React.ReactNode;
  9. hideGuide?: boolean;
  10. onChange?: ({newestFirst}: {newestFirst: boolean}) => void;
  11. };
  12. const CrashTitle = ({
  13. title,
  14. newestFirst,
  15. beforeTitle,
  16. hideGuide = false,
  17. onChange,
  18. }: Props) => {
  19. const handleToggleOrder = () => {
  20. if (onChange) {
  21. onChange({newestFirst: !newestFirst});
  22. }
  23. };
  24. return (
  25. <Wrapper>
  26. {beforeTitle}
  27. <StyledH3>
  28. <GuideAnchor target="exception" disabled={hideGuide} position="bottom">
  29. {title}
  30. </GuideAnchor>
  31. {onChange && (
  32. <Tooltip showUnderline title={t('Toggle stack trace order')}>
  33. <small>
  34. (
  35. <span onClick={handleToggleOrder}>
  36. {newestFirst ? t('most recent call first') : t('most recent call last')}
  37. </span>
  38. )
  39. </small>
  40. </Tooltip>
  41. )}
  42. </StyledH3>
  43. </Wrapper>
  44. );
  45. };
  46. export default CrashTitle;
  47. const Wrapper = styled('div')`
  48. display: flex;
  49. align-items: center;
  50. flex-wrap: wrap;
  51. flex-grow: 1;
  52. justify-content: flex-start;
  53. `;
  54. const StyledH3 = styled('h3')`
  55. margin-bottom: 0;
  56. max-width: 100%;
  57. white-space: nowrap;
  58. `;