The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

185 lines
8.1 KiB

  1. import React from 'react';
  2. import Column from '../ui/components/column';
  3. import ColumnLink from '../ui/components/column_link';
  4. import ColumnSubheading from '../ui/components/column_subheading';
  5. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  6. import { connect } from 'react-redux';
  7. import PropTypes from 'prop-types';
  8. import ImmutablePropTypes from 'react-immutable-proptypes';
  9. import ImmutablePureComponent from 'react-immutable-pure-component';
  10. import { me, invitesEnabled, version, profile_directory } from '../../initial_state';
  11. import { fetchFollowRequests } from '../../actions/accounts';
  12. import { List as ImmutableList } from 'immutable';
  13. import { Link } from 'react-router-dom';
  14. import NavigationBar from '../compose/components/navigation_bar';
  15. import Icon from 'mastodon/components/icon';
  16. const messages = defineMessages({
  17. home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
  18. notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
  19. public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  20. settings_subheading: { id: 'column_subheading.settings', defaultMessage: 'Settings' },
  21. community_timeline: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  22. direct: { id: 'navigation_bar.direct', defaultMessage: 'Direct messages' },
  23. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  24. follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
  25. favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favourites' },
  26. blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
  27. domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
  28. mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
  29. pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned toots' },
  30. lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' },
  31. discover: { id: 'navigation_bar.discover', defaultMessage: 'Discover' },
  32. personal: { id: 'navigation_bar.personal', defaultMessage: 'Personal' },
  33. security: { id: 'navigation_bar.security', defaultMessage: 'Security' },
  34. menu: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
  35. profile_directory: { id: 'getting_started.directory', defaultMessage: 'Profile directory' },
  36. });
  37. const mapStateToProps = state => ({
  38. myAccount: state.getIn(['accounts', me]),
  39. unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
  40. });
  41. const mapDispatchToProps = dispatch => ({
  42. fetchFollowRequests: () => dispatch(fetchFollowRequests()),
  43. });
  44. const badgeDisplay = (number, limit) => {
  45. if (number === 0) {
  46. return undefined;
  47. } else if (limit && number >= limit) {
  48. return `${limit}+`;
  49. } else {
  50. return number;
  51. }
  52. };
  53. export default @connect(mapStateToProps, mapDispatchToProps)
  54. @injectIntl
  55. class GettingStarted extends ImmutablePureComponent {
  56. static propTypes = {
  57. intl: PropTypes.object.isRequired,
  58. myAccount: ImmutablePropTypes.map.isRequired,
  59. columns: ImmutablePropTypes.list,
  60. multiColumn: PropTypes.bool,
  61. fetchFollowRequests: PropTypes.func.isRequired,
  62. unreadFollowRequests: PropTypes.number,
  63. unreadNotifications: PropTypes.number,
  64. };
  65. componentDidMount () {
  66. const { myAccount, fetchFollowRequests } = this.props;
  67. if (myAccount.get('locked')) {
  68. fetchFollowRequests();
  69. }
  70. }
  71. render () {
  72. const { intl, myAccount, multiColumn, unreadFollowRequests } = this.props;
  73. const navItems = [];
  74. let i = 1;
  75. let height = (multiColumn) ? 0 : 60;
  76. if (multiColumn) {
  77. navItems.push(
  78. <ColumnSubheading key={i++} text={intl.formatMessage(messages.discover)} />,
  79. <ColumnLink key={i++} icon='users' text={intl.formatMessage(messages.community_timeline)} to='/timelines/public/local' />,
  80. <ColumnLink key={i++} icon='globe' text={intl.formatMessage(messages.public_timeline)} to='/timelines/public' />,
  81. );
  82. height += 34 + 48*2;
  83. if (profile_directory) {
  84. navItems.push(
  85. <ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} href='/explore' />
  86. );
  87. height += 48;
  88. }
  89. navItems.push(
  90. <ColumnSubheading key={i++} text={intl.formatMessage(messages.personal)} />
  91. );
  92. height += 34;
  93. } else if (profile_directory) {
  94. navItems.push(
  95. <ColumnLink key={i++} icon='address-book' text={intl.formatMessage(messages.profile_directory)} href='/explore' />
  96. );
  97. height += 48;
  98. }
  99. navItems.push(
  100. <ColumnLink key={i++} icon='envelope' text={intl.formatMessage(messages.direct)} to='/timelines/direct' />,
  101. <ColumnLink key={i++} icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />,
  102. <ColumnLink key={i++} icon='list-ul' text={intl.formatMessage(messages.lists)} to='/lists' />
  103. );
  104. height += 48*3;
  105. if (myAccount.get('locked')) {
  106. navItems.push(<ColumnLink key={i++} icon='users' text={intl.formatMessage(messages.follow_requests)} badge={badgeDisplay(unreadFollowRequests, 40)} to='/follow_requests' />);
  107. height += 48;
  108. }
  109. if (!multiColumn) {
  110. navItems.push(
  111. <ColumnSubheading key={i++} text={intl.formatMessage(messages.settings_subheading)} />,
  112. <ColumnLink key={i++} icon='gears' text={intl.formatMessage(messages.preferences)} href='/settings/preferences' />,
  113. );
  114. height += 34 + 48;
  115. }
  116. return (
  117. <Column label={intl.formatMessage(messages.menu)}>
  118. {multiColumn && <div className='column-header__wrapper'>
  119. <h1 className='column-header'>
  120. <button>
  121. <Icon id='bars' className='column-header__icon' fixedWidth />
  122. <FormattedMessage id='getting_started.heading' defaultMessage='Getting started' />
  123. </button>
  124. </h1>
  125. </div>}
  126. <div className='getting-started'>
  127. <div className='getting-started__wrapper' style={{ height }}>
  128. {!multiColumn && <NavigationBar account={myAccount} />}
  129. {navItems}
  130. </div>
  131. {!multiColumn && <div className='flex-spacer' />}
  132. <div className='getting-started__footer'>
  133. <ul>
  134. {invitesEnabled && <li><a href='/invites' target='_blank'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>}
  135. {multiColumn && <li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li>}
  136. <li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li>
  137. <li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this instance' /></a> · </li>
  138. <li><a href='https://joinmastodon.org/apps' target='_blank'><FormattedMessage id='navigation_bar.apps' defaultMessage='Mobile apps' /></a> · </li>
  139. <li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li>
  140. <li><a href='/settings/applications' target='_blank'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li>
  141. <li><a href='https://docs.joinmastodon.org' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li>
  142. <li><a href='/auth/sign_out' data-method='delete'><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li>
  143. </ul>
  144. <p>
  145. <FormattedMessage
  146. id='getting_started.open_source_notice'
  147. defaultMessage='Mastodon is open source software. You can contribute or report issues on GitHub at {github}.'
  148. values={{ github: <span><a href='https://github.com/tootsuite/mastodon' rel='noopener' target='_blank'>tootsuite/mastodon</a> (v{version})</span> }}
  149. />
  150. </p>
  151. </div>
  152. </div>
  153. </Column>
  154. );
  155. }
  156. }