You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.2 KiB

  1. // Package imports.
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import { defineMessages } from 'react-intl';
  6. import { Link } from 'react-router-dom';
  7. // Components.
  8. import Icon from 'flavours/glitch/components/icon';
  9. // Utils.
  10. import { conditionalRender } from 'flavours/glitch/util/react_helpers';
  11. // Messages.
  12. const messages = defineMessages({
  13. community: {
  14. defaultMessage: 'Local timeline',
  15. id: 'navigation_bar.community_timeline',
  16. },
  17. home_timeline: {
  18. defaultMessage: 'Home',
  19. id: 'tabs_bar.home',
  20. },
  21. logout: {
  22. defaultMessage: 'Logout',
  23. id: 'navigation_bar.logout',
  24. },
  25. notifications: {
  26. defaultMessage: 'Notifications',
  27. id: 'tabs_bar.notifications',
  28. },
  29. public: {
  30. defaultMessage: 'Federated timeline',
  31. id: 'navigation_bar.public_timeline',
  32. },
  33. settings: {
  34. defaultMessage: 'App settings',
  35. id: 'navigation_bar.app_settings',
  36. },
  37. start: {
  38. defaultMessage: 'Getting started',
  39. id: 'getting_started.heading',
  40. },
  41. });
  42. // The component.
  43. export default function DrawerHeader ({
  44. columns,
  45. intl,
  46. onSettingsClick,
  47. }) {
  48. // Only renders the component if the column isn't being shown.
  49. const renderForColumn = conditionalRender.bind(null,
  50. columnId => !columns || !columns.some(
  51. column => column.get('id') === columnId
  52. )
  53. );
  54. // The result.
  55. return (
  56. <nav className='drawer--header'>
  57. <Link
  58. aria-label={intl.formatMessage(messages.start)}
  59. title={intl.formatMessage(messages.start)}
  60. to='/getting-started'
  61. ><Icon icon='asterisk' /></Link>
  62. {renderForColumn('HOME', (
  63. <Link
  64. aria-label={intl.formatMessage(messages.home_timeline)}
  65. title={intl.formatMessage(messages.home_timeline)}
  66. to='/timelines/home'
  67. ><Icon icon='home' /></Link>
  68. ))}
  69. {renderForColumn('NOTIFICATIONS', (
  70. <Link
  71. aria-label={intl.formatMessage(messages.notifications)}
  72. title={intl.formatMessage(messages.notifications)}
  73. to='/notifications'
  74. ><Icon icon='bell' /></Link>
  75. ))}
  76. {renderForColumn('COMMUNITY', (
  77. <Link
  78. aria-label={intl.formatMessage(messages.community)}
  79. title={intl.formatMessage(messages.community)}
  80. to='/timelines/public/local'
  81. ><Icon icon='users' /></Link>
  82. ))}
  83. {renderForColumn('PUBLIC', (
  84. <Link
  85. aria-label={intl.formatMessage(messages.public)}
  86. title={intl.formatMessage(messages.public)}
  87. to='/timelines/public'
  88. ><Icon icon='globe' /></Link>
  89. ))}
  90. <a
  91. aria-label={intl.formatMessage(messages.settings)}
  92. onClick={onSettingsClick}
  93. role='button'
  94. title={intl.formatMessage(messages.settings)}
  95. tabIndex='0'
  96. ><Icon icon='cogs' /></a>
  97. <a
  98. aria-label={intl.formatMessage(messages.logout)}
  99. data-method='delete'
  100. href='/auth/sign_out'
  101. title={intl.formatMessage(messages.logout)}
  102. ><Icon icon='sign-out' /></a>
  103. </nav>
  104. );
  105. }
  106. // Props.
  107. DrawerHeader.propTypes = {
  108. columns: ImmutablePropTypes.list,
  109. intl: PropTypes.object,
  110. onSettingsClick: PropTypes.func,
  111. };