闭社主体 forked from https://github.com/tootsuite/mastodon
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
5.8 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 Link from 'react-router/lib/Link';
  6. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  7. import { connect } from 'react-redux';
  8. import PropTypes from 'prop-types';
  9. import ImmutablePropTypes from 'react-immutable-proptypes';
  10. import ImmutablePureComponent from 'react-immutable-pure-component';
  11. const messages = defineMessages({
  12. heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
  13. home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
  14. notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
  15. public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  16. navigation_subheading: { id: 'column_subheading.navigation', defaultMessage: 'Navigation' },
  17. settings_subheading: { id: 'column_subheading.settings', defaultMessage: 'Settings' },
  18. community_timeline: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  19. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  20. follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
  21. sign_out: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
  22. favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favourites' },
  23. blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
  24. mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
  25. info: { id: 'navigation_bar.info', defaultMessage: 'Extended information' },
  26. });
  27. const mapStateToProps = state => ({
  28. me: state.getIn(['accounts', state.getIn(['meta', 'me'])]),
  29. columns: state.getIn(['settings', 'columns']),
  30. });
  31. class GettingStarted extends ImmutablePureComponent {
  32. static propTypes = {
  33. intl: PropTypes.object.isRequired,
  34. me: ImmutablePropTypes.map.isRequired,
  35. columns: ImmutablePropTypes.list,
  36. multiColumn: PropTypes.bool,
  37. };
  38. render () {
  39. const { intl, me, columns, multiColumn } = this.props;
  40. let navItems = [];
  41. if (multiColumn) {
  42. if (!columns.find(item => item.get('id') === 'HOME')) {
  43. navItems.push(<ColumnLink key='0' icon='home' text={intl.formatMessage(messages.home_timeline)} to='/timelines/home' />);
  44. }
  45. if (!columns.find(item => item.get('id') === 'NOTIFICATIONS')) {
  46. navItems.push(<ColumnLink key='1' icon='bell' text={intl.formatMessage(messages.notifications)} to='/notifications' />);
  47. }
  48. if (!columns.find(item => item.get('id') === 'COMMUNITY')) {
  49. navItems.push(<ColumnLink key='2' icon='users' text={intl.formatMessage(messages.community_timeline)} to='/timelines/public/local' />);
  50. }
  51. if (!columns.find(item => item.get('id') === 'PUBLIC')) {
  52. navItems.push(<ColumnLink key='3' icon='globe' text={intl.formatMessage(messages.public_timeline)} to='/timelines/public' />);
  53. }
  54. }
  55. navItems = navItems.concat([
  56. <ColumnLink key='4' icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />,
  57. ]);
  58. if (me.get('locked')) {
  59. navItems.push(<ColumnLink key='5' icon='users' text={intl.formatMessage(messages.follow_requests)} to='/follow_requests' />);
  60. }
  61. navItems = navItems.concat([
  62. <ColumnLink key='6' icon='volume-off' text={intl.formatMessage(messages.mutes)} to='/mutes' />,
  63. <ColumnLink key='7' icon='ban' text={intl.formatMessage(messages.blocks)} to='/blocks' />,
  64. ]);
  65. return (
  66. <Column icon='asterisk' heading={intl.formatMessage(messages.heading)} hideHeadingOnMobile={true}>
  67. <div className='getting-started__wrapper'>
  68. <ColumnSubheading text={intl.formatMessage(messages.navigation_subheading)}/>
  69. {navItems}
  70. <ColumnSubheading text={intl.formatMessage(messages.settings_subheading)}/>
  71. <ColumnLink icon='book' text={intl.formatMessage(messages.info)} href='/about/more' />
  72. <ColumnLink icon='cog' text={intl.formatMessage(messages.preferences)} href='/settings/preferences' />
  73. <ColumnLink icon='sign-out' text={intl.formatMessage(messages.sign_out)} href='/auth/sign_out' method='delete' />
  74. </div>
  75. <div className='getting-started__footer scrollable optionally-scrollable'>
  76. <div className='static-content getting-started'>
  77. <p>
  78. <FormattedMessage
  79. id='getting_started.support'
  80. defaultMessage='{faq} • {userguide} • {apps}'
  81. values={{
  82. faq: <a href='https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/FAQ.md' rel='noopener' target='_blank'><FormattedMessage id='getting_started.faq' defaultMessage='FAQ' /></a>,
  83. userguide: <a href='https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/User-guide.md' rel='noopener' target='_blank'><FormattedMessage id='getting_started.userguide' defaultMessage='User Guide' /></a>,
  84. apps: <a href='https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/Apps.md' rel='noopener' target='_blank'><FormattedMessage id='getting_started.appsshort' defaultMessage='Apps' /></a>,
  85. }}
  86. />
  87. </p>
  88. <p>
  89. <FormattedMessage
  90. id='getting_started.open_source_notice'
  91. defaultMessage='Mastodon is open source software. You can contribute or report issues on GitHub at {github}.'
  92. values={{ github: <a href='https://github.com/tootsuite/mastodon' rel='noopener' target='_blank'>tootsuite/mastodon</a> }}
  93. />
  94. </p>
  95. </div>
  96. </div>
  97. </Column>
  98. );
  99. }
  100. }
  101. export default connect(mapStateToProps)(injectIntl(GettingStarted));