logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

index.js (6992B)


  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 } from '../../initial_state';
  11. import { fetchFollowRequests } from '../../actions/accounts';
  12. import { fetchPanel, fetchPleromaConfig } from '../../actions/pleroma';
  13. import { List as ImmutableList } from 'immutable';
  14. const messages = defineMessages({
  15. heading: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
  16. home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
  17. notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
  18. public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
  19. navigation_subheading: { id: 'column_subheading.navigation', defaultMessage: 'Navigation' },
  20. settings_subheading: { id: 'column_subheading.settings', defaultMessage: 'Settings' },
  21. community_timeline: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
  22. preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  23. follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
  24. sign_out: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
  25. favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favourites' },
  26. blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
  27. keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Keyboard shortcuts' },
  28. });
  29. const mapStateToProps = state => ({
  30. myAccount: state.getIn(['accounts', me]),
  31. columns: state.getIn(['settings', 'columns']),
  32. unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
  33. unreadNotifications: state.getIn(['notifications', 'unread']),
  34. customPanelEnabled: state.getIn(['custom_panel', 'enabled']),
  35. customPanel: state.getIn(['custom_panel', 'panel']),
  36. });
  37. const mapDispatchToProps = dispatch => ({
  38. fetchFollowRequests: () => dispatch(fetchFollowRequests()),
  39. fetchPanel: () => dispatch(fetchPanel()),
  40. fetchPleromaConfig: () => dispatch(fetchPleromaConfig()),
  41. });
  42. const badgeDisplay = (number, limit) => {
  43. if (number === 0) {
  44. return undefined;
  45. } else if (limit && number >= limit) {
  46. return `${limit}+`;
  47. } else {
  48. return number;
  49. }
  50. };
  51. @connect(mapStateToProps, mapDispatchToProps)
  52. @injectIntl
  53. export default class GettingStarted extends ImmutablePureComponent {
  54. static propTypes = {
  55. intl: PropTypes.object.isRequired,
  56. myAccount: ImmutablePropTypes.map.isRequired,
  57. columns: ImmutablePropTypes.list,
  58. multiColumn: PropTypes.bool,
  59. fetchFollowRequests: PropTypes.func.isRequired,
  60. fetchPanel: PropTypes.func.isRequired,
  61. fetchPleromaConfig: PropTypes.func.isRequired,
  62. unreadFollowRequests: PropTypes.number,
  63. unreadNotifications: PropTypes.number,
  64. customPanelEnabled: PropTypes.bool,
  65. customPanel: PropTypes.string.isRequired,
  66. };
  67. componentDidMount () {
  68. const { myAccount, fetchFollowRequests, fetchPleromaConfig, fetchPanel } = this.props;
  69. if (myAccount.get('locked')) {
  70. fetchFollowRequests();
  71. }
  72. fetchPleromaConfig();
  73. fetchPanel();
  74. }
  75. render () {
  76. const { intl, myAccount, columns, multiColumn, unreadFollowRequests, unreadNotifications, customPanelEnabled, customPanel } = this.props;
  77. const navItems = [];
  78. if (multiColumn) {
  79. if (!columns.find(item => item.get('id') === 'HOME')) {
  80. navItems.push(<ColumnLink key='0' icon='home' text={intl.formatMessage(messages.home_timeline)} to='/timelines/home' />);
  81. }
  82. if (!columns.find(item => item.get('id') === 'NOTIFICATIONS')) {
  83. navItems.push(<ColumnLink key='1' icon='bell' text={intl.formatMessage(messages.notifications)} badge={badgeDisplay(unreadNotifications)} to='/notifications' />);
  84. }
  85. if (!columns.find(item => item.get('id') === 'COMMUNITY')) {
  86. navItems.push(<ColumnLink key='2' icon='users' text={intl.formatMessage(messages.community_timeline)} to='/timelines/public/local' />);
  87. }
  88. if (!columns.find(item => item.get('id') === 'PUBLIC')) {
  89. navItems.push(<ColumnLink key='3' icon='globe' text={intl.formatMessage(messages.public_timeline)} to='/timelines/public' />);
  90. }
  91. }
  92. navItems.push(
  93. <ColumnLink key='4' icon='star' text={intl.formatMessage(messages.favourites)} to='/favourites' />,
  94. );
  95. if (myAccount.get('locked')) {
  96. navItems.push(<ColumnLink key='6' icon='users' text={intl.formatMessage(messages.follow_requests)} badge={badgeDisplay(unreadFollowRequests, 40)} to='/follow_requests' />);
  97. }
  98. if (multiColumn) {
  99. navItems.push(<ColumnLink key='7' icon='question' text={intl.formatMessage(messages.keyboard_shortcuts)} to='/keyboard-shortcuts' />);
  100. }
  101. const dot = ' • ';
  102. const staticContent = (customPanelEnabled ? <div dangerouslySetInnerHTML={{__html: customPanel}} style={{marginLeft: -12, marginRight: -12}} /> :
  103. <p>
  104. <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>
  105. {dot}
  106. <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>
  107. {dot}
  108. <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>
  109. {dot}
  110. <a href='https://pleroma.social'><FormattedMessage id='getting_started.pleroma' defaultMessage='Pleroma' /></a>
  111. </p>
  112. );
  113. return (
  114. <Column icon='asterisk' heading={intl.formatMessage(messages.heading)} hideHeadingOnMobile>
  115. <div className='getting-started__wrapper'>
  116. <ColumnSubheading text={intl.formatMessage(messages.navigation_subheading)} />
  117. {navItems}
  118. <ColumnSubheading text={intl.formatMessage(messages.settings_subheading)} />
  119. <ColumnLink icon='ban' text={intl.formatMessage(messages.blocks)} to='/blocks' />
  120. <ColumnLink icon='cog' text={intl.formatMessage(messages.preferences)} href='/user-settings' />
  121. <ColumnLink icon='sign-out' text={intl.formatMessage(messages.sign_out)} href='/auth/sign_out' method='delete' />
  122. </div>
  123. <div className='static-content getting-started'>
  124. {staticContent}
  125. </div>
  126. </Column>
  127. );
  128. }
  129. }