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
, repository
, source_url
} from '../../initial_state';
11 import { fetchFollowRequests
} from 'mastodon/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';
17 const messages
= defineMessages({
18 home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
19 notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
20 public_timeline: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
21 settings_subheading: { id: 'column_subheading.settings', defaultMessage: 'Settings' },
22 community_timeline: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
23 direct: { id: 'navigation_bar.direct', defaultMessage: 'Direct messages' },
24 preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
25 follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
26 favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favourites' },
27 blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
28 domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
29 mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
30 pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned toots' },
31 lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' },
32 discover: { id: 'navigation_bar.discover', defaultMessage: 'Discover' },
33 personal: { id: 'navigation_bar.personal', defaultMessage: 'Personal' },
34 security: { id: 'navigation_bar.security', defaultMessage: 'Security' },
35 menu: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
36 profile_directory: { id: 'getting_started.directory', defaultMessage: 'Profile directory' },
39 const mapStateToProps
= state
=> ({
40 myAccount: state
.getIn(['accounts', me
]),
41 unreadFollowRequests: state
.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size
,
44 const mapDispatchToProps
= dispatch
=> ({
45 fetchFollowRequests: () => dispatch(fetchFollowRequests()),
48 const badgeDisplay
= (number
, limit
) => {
51 } else if (limit
&& number
>= limit
) {
58 const NAVIGATION_PANEL_BREAKPOINT
= 600 + (285 * 2) + (10 * 2);
60 export default @connect(mapStateToProps
, mapDispatchToProps
)
62 class GettingStarted
extends ImmutablePureComponent
{
64 static contextTypes
= {
65 router: PropTypes
.object
.isRequired
,
69 intl: PropTypes
.object
.isRequired
,
70 myAccount: ImmutablePropTypes
.map
.isRequired
,
71 columns: ImmutablePropTypes
.list
,
72 multiColumn: PropTypes
.bool
,
73 fetchFollowRequests: PropTypes
.func
.isRequired
,
74 unreadFollowRequests: PropTypes
.number
,
75 unreadNotifications: PropTypes
.number
,
78 componentDidMount () {
79 const { myAccount
, fetchFollowRequests
, multiColumn
} = this.props
;
81 if (!multiColumn
&& window
.innerWidth
>= NAVIGATION_PANEL_BREAKPOINT
) {
82 this.context
.router
.history
.replace('/timelines/home');
86 if (myAccount
.get('locked')) {
87 fetchFollowRequests();
92 const { intl
, myAccount
, multiColumn
, unreadFollowRequests
} = this.props
;
96 let height
= (multiColumn
) ? 0 : 60;
100 <ColumnSubheading key
={i
++} text
={intl
.formatMessage(messages
.discover
)} />,
101 <ColumnLink key
={i
++} icon
='users' text
={intl
.formatMessage(messages
.community_timeline
)} to
='/timelines/public/local' />,
102 <ColumnLink key
={i
++} icon
='globe' text
={intl
.formatMessage(messages
.public_timeline
)} to
='/timelines/public' />,
107 if (profile_directory
) {
109 <ColumnLink key
={i
++} icon
='address-book' text
={intl
.formatMessage(messages
.profile_directory
)} href
='/explore' />
116 <ColumnSubheading key
={i
++} text
={intl
.formatMessage(messages
.personal
)} />
120 } else if (profile_directory
) {
122 <ColumnLink key
={i
++} icon
='address-book' text
={intl
.formatMessage(messages
.profile_directory
)} href
='/explore' />
129 <ColumnLink key
={i
++} icon
='envelope' text
={intl
.formatMessage(messages
.direct
)} to
='/timelines/direct' />,
130 <ColumnLink key
={i
++} icon
='star' text
={intl
.formatMessage(messages
.favourites
)} to
='/favourites' />,
131 <ColumnLink key
={i
++} icon
='list-ul' text
={intl
.formatMessage(messages
.lists
)} to
='/lists' />
136 if (myAccount
.get('locked')) {
137 navItems
.push(<ColumnLink key
={i
++} icon
='user-plus' text
={intl
.formatMessage(messages
.follow_requests
)} badge
={badgeDisplay(unreadFollowRequests
, 40)} to
='/follow_requests' />);
143 <ColumnSubheading key
={i
++} text
={intl
.formatMessage(messages
.settings_subheading
)} />,
144 <ColumnLink key
={i
++} icon
='gears' text
={intl
.formatMessage(messages
.preferences
)} href
='/settings/preferences' />,
151 <Column label
={intl
.formatMessage(messages
.menu
)}>
152 {multiColumn
&& <div className
='column-header__wrapper'>
153 <h1 className
='column-header'>
155 <Icon id
='bars' className
='column-header__icon' fixedWidth
/>
156 <FormattedMessage id
='getting_started.heading' defaultMessage
='Getting started' />
161 <div className
='getting-started'>
162 <div className
='getting-started__wrapper' style
={{ height
}}>
163 {!multiColumn
&& <NavigationBar account
={myAccount
} />}
167 {!multiColumn
&& <div className
='flex-spacer' />}
169 <div className
='getting-started__footer'>
171 {invitesEnabled
&& <li
><a href
='/invites' target
='_blank'><FormattedMessage id
='getting_started.invite' defaultMessage
='Invite people' /></a> · </li
>}
172 {multiColumn
&& <li
><Link to
='/keyboard-shortcuts'><FormattedMessage id
='navigation_bar.keyboard_shortcuts' defaultMessage
='Hotkeys' /></Link
> · </li
>}
173 <li
><a href
='/auth/edit'><FormattedMessage id
='getting_started.security' defaultMessage
='Security' /></a> · </li
>
174 <li
><a href
='/about/more' target
='_blank'><FormattedMessage id
='navigation_bar.info' defaultMessage
='About this server' /></a> · </li
>
175 <li
><a href
='https://joinmastodon.org/apps' target
='_blank'><FormattedMessage id
='navigation_bar.apps' defaultMessage
='Mobile apps' /></a> · </li
>
176 <li
><a href
='/terms' target
='_blank'><FormattedMessage id
='getting_started.terms' defaultMessage
='Terms of service' /></a> · </li
>
177 <li
><a href
='/settings/applications' target
='_blank'><FormattedMessage id
='getting_started.developers' defaultMessage
='Developers' /></a> · </li
>
178 <li
><a href
='https://docs.joinmastodon.org' target
='_blank'><FormattedMessage id
='getting_started.documentation' defaultMessage
='Documentation' /></a> · </li
>
179 <li
><a href
='/auth/sign_out' data
-method
='delete'><FormattedMessage id
='navigation_bar.logout' defaultMessage
='Logout' /></a></li
>
184 id
='getting_started.open_source_notice'
185 defaultMessage
='Mastodon is open source software. You can contribute or report issues on GitHub at {github}.'
186 values
={{ github: <span
><a href
={source_url
} rel
='noopener' target
='_blank'>{repository
}</a
> (v
{version
})</span
> }}