navigationButtonGroup.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from 'react';
  2. import {Location} from 'history';
  3. import Button from 'app/components/button';
  4. import ButtonBar from 'app/components/buttonBar';
  5. import {IconNext, IconPrevious} from 'app/icons';
  6. import {t} from 'app/locale';
  7. type Props = {
  8. location: Location;
  9. /**
  10. * A set of pathName's that will be used in the buttons in the following order:
  11. * [OldestURL, OlderURL, NewerURL, NewestURL]
  12. */
  13. urls: [string, string, string, string];
  14. hasNext?: boolean;
  15. hasPrevious?: boolean;
  16. className?: string;
  17. };
  18. const NavigationButtonGroup = ({
  19. location,
  20. urls,
  21. hasNext = false,
  22. hasPrevious = false,
  23. className,
  24. }: Props) => (
  25. <ButtonBar className={className} merged>
  26. <Button
  27. size="small"
  28. to={{pathname: urls[0], query: location.query}}
  29. disabled={!hasPrevious}
  30. label={t('Oldest')}
  31. icon={<IconPrevious size="xs" />}
  32. />
  33. <Button
  34. size="small"
  35. to={{
  36. pathname: urls[1],
  37. query: location.query,
  38. }}
  39. disabled={!hasPrevious}
  40. >
  41. {t('Older')}
  42. </Button>
  43. <Button
  44. size="small"
  45. to={{pathname: urls[2], query: location.query}}
  46. disabled={!hasNext}
  47. >
  48. {t('Newer')}
  49. </Button>
  50. <Button
  51. size="small"
  52. to={{pathname: urls[3], query: location.query}}
  53. disabled={!hasNext}
  54. label={t('Newest')}
  55. icon={<IconNext size="xs" />}
  56. />
  57. </ButtonBar>
  58. );
  59. export default NavigationButtonGroup;