commit
1b0ce85e3d
@ -0,0 +1,20 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import Icon from 'mastodon/components/icon'; |
||||
|
||||
const formatNumber = num => num > 40 ? '40+' : num; |
||||
|
||||
const IconWithBadge = ({ id, count, className }) => ( |
||||
<i className='icon-with-badge'> |
||||
<Icon id={id} fixedWidth className={className} /> |
||||
{count > 0 && <i className='icon-with-badge__badge'>{formatNumber(count)}</i>} |
||||
</i> |
||||
); |
||||
|
||||
IconWithBadge.propTypes = { |
||||
id: PropTypes.string.isRequired, |
||||
count: PropTypes.number.isRequired, |
||||
className: PropTypes.string, |
||||
}; |
||||
|
||||
export default IconWithBadge; |
@ -0,0 +1,17 @@ |
||||
import React from 'react'; |
||||
import SearchContainer from 'mastodon/features/compose/containers/search_container'; |
||||
import SearchResultsContainer from 'mastodon/features/compose/containers/search_results_container'; |
||||
|
||||
const Search = () => ( |
||||
<div className='column search-page'> |
||||
<SearchContainer /> |
||||
|
||||
<div className='drawer__pager'> |
||||
<div className='drawer__inner darker'> |
||||
<SearchResultsContainer /> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
); |
||||
|
||||
export default Search; |
@ -0,0 +1,41 @@ |
||||
import React from 'react'; |
||||
import SearchContainer from 'mastodon/features/compose/containers/search_container'; |
||||
import ComposeFormContainer from 'mastodon/features/compose/containers/compose_form_container'; |
||||
import NavigationContainer from 'mastodon/features/compose/containers/navigation_container'; |
||||
import { invitesEnabled, version, repository, source_url } from 'mastodon/initial_state'; |
||||
import { Link } from 'react-router-dom'; |
||||
import { FormattedMessage } from 'react-intl'; |
||||
|
||||
const ComposePanel = () => ( |
||||
<div className='compose-panel'> |
||||
<SearchContainer openInRoute /> |
||||
<NavigationContainer /> |
||||
<ComposeFormContainer /> |
||||
|
||||
<div className='flex-spacer' /> |
||||
|
||||
<div className='getting-started__footer'> |
||||
<ul> |
||||
{invitesEnabled && <li><a href='/invites' target='_blank'><FormattedMessage id='getting_started.invite' defaultMessage='Invite people' /></a> · </li>} |
||||
<li><Link to='/keyboard-shortcuts'><FormattedMessage id='navigation_bar.keyboard_shortcuts' defaultMessage='Hotkeys' /></Link> · </li> |
||||
<li><a href='/auth/edit'><FormattedMessage id='getting_started.security' defaultMessage='Security' /></a> · </li> |
||||
<li><a href='/about/more' target='_blank'><FormattedMessage id='navigation_bar.info' defaultMessage='About this server' /></a> · </li> |
||||
<li><a href='https://joinmastodon.org/apps' target='_blank'><FormattedMessage id='navigation_bar.apps' defaultMessage='Mobile apps' /></a> · </li> |
||||
<li><a href='/terms' target='_blank'><FormattedMessage id='getting_started.terms' defaultMessage='Terms of service' /></a> · </li> |
||||
<li><a href='/settings/applications' target='_blank'><FormattedMessage id='getting_started.developers' defaultMessage='Developers' /></a> · </li> |
||||
<li><a href='https://docs.joinmastodon.org' target='_blank'><FormattedMessage id='getting_started.documentation' defaultMessage='Documentation' /></a> · </li> |
||||
<li><a href='/auth/sign_out' data-method='delete'><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></a></li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<FormattedMessage |
||||
id='getting_started.open_source_notice' |
||||
defaultMessage='Mastodon is open source software. You can contribute or report issues on GitHub at {github}.' |
||||
values={{ github: <span><a href={source_url} rel='noopener' target='_blank'>{repository}</a> (v{version})</span> }} |
||||
/> |
||||
</p> |
||||
</div> |
||||
</div> |
||||
); |
||||
|
||||
export default ComposePanel; |
@ -0,0 +1,44 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { fetchFollowRequests } from 'mastodon/actions/accounts'; |
||||
import { connect } from 'react-redux'; |
||||
import { NavLink, withRouter } from 'react-router-dom'; |
||||
import IconWithBadge from 'mastodon/components/icon_with_badge'; |
||||
import { me } from 'mastodon/initial_state'; |
||||
import { List as ImmutableList } from 'immutable'; |
||||
import { FormattedMessage } from 'react-intl'; |
||||
|
||||
const mapStateToProps = state => ({ |
||||
locked: state.getIn(['accounts', me, 'locked']), |
||||
count: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size, |
||||
}); |
||||
|
||||
export default @withRouter |
||||
@connect(mapStateToProps) |
||||
class FollowRequestsNavLink extends React.Component { |
||||
|
||||
static propTypes = { |
||||
dispatch: PropTypes.func.isRequired, |
||||
locked: PropTypes.bool, |
||||
count: PropTypes.number.isRequired, |
||||
}; |
||||
|
||||
componentDidMount () { |
||||
const { dispatch, locked } = this.props; |
||||
|
||||
if (locked) { |
||||
dispatch(fetchFollowRequests()); |
||||
} |
||||
} |
||||
|
||||
render () { |
||||
const { locked, count } = this.props; |
||||
|
||||
if (!locked || count === 0) { |
||||
return null; |
||||
} |
||||
|
||||
return <NavLink className='column-link column-link--transparent' to='/follow_requests'><IconWithBadge className='column-link__icon' id='user-plus' count={count} /><FormattedMessage id='navigation_bar.follow_requests' defaultMessage='Follow requests' /></NavLink>; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,55 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import ImmutablePureComponent from 'react-immutable-pure-component'; |
||||
import { fetchLists } from 'mastodon/actions/lists'; |
||||
import { connect } from 'react-redux'; |
||||
import { createSelector } from 'reselect'; |
||||
import { NavLink, withRouter } from 'react-router-dom'; |
||||
import Icon from 'mastodon/components/icon'; |
||||
|
||||
const getOrderedLists = createSelector([state => state.get('lists')], lists => { |
||||
if (!lists) { |
||||
return lists; |
||||
} |
||||
|
||||
return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title'))).take(4); |
||||
}); |
||||
|
||||
const mapStateToProps = state => ({ |
||||
lists: getOrderedLists(state), |
||||
}); |
||||
|
||||
export default @withRouter |
||||
@connect(mapStateToProps) |
||||
class ListPanel extends ImmutablePureComponent { |
||||
|
||||
static propTypes = { |
||||
dispatch: PropTypes.func.isRequired, |
||||
lists: ImmutablePropTypes.list, |
||||
}; |
||||
|
||||
componentDidMount () { |
||||
const { dispatch } = this.props; |
||||
dispatch(fetchLists()); |
||||
} |
||||
|
||||
render () { |
||||
const { lists } = this.props; |
||||
|
||||
if (!lists || lists.isEmpty()) { |
||||
return null; |
||||
} |
||||
|
||||
return ( |
||||
<div> |
||||
<hr /> |
||||
|
||||
{lists.map(list => ( |
||||
<NavLink key={list.get('id')} className='column-link column-link--transparent' strict to={`/timelines/list/${list.get('id')}`}><Icon className='column-link__icon' id='list-ul' fixedWidth />{list.get('title')}</NavLink> |
||||
))} |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@ |
||||
import React from 'react'; |
||||
import { NavLink, withRouter } from 'react-router-dom'; |
||||
import { FormattedMessage } from 'react-intl'; |
||||
import Icon from 'mastodon/components/icon'; |
||||
import NotificationsCounterIcon from './notifications_counter_icon'; |
||||
import FollowRequestsNavLink from './follow_requests_nav_link'; |
||||
import ListPanel from './list_panel'; |
||||
|
||||
const NavigationPanel = () => ( |
||||
<div className='navigation-panel'> |
||||
<NavLink className='column-link column-link--transparent' to='/timelines/home' data-preview-title-id='column.home' data-preview-icon='home' ><Icon className='column-link__icon' id='home' fixedWidth /><FormattedMessage id='tabs_bar.home' defaultMessage='Home' /></NavLink> |
||||
<NavLink className='column-link column-link--transparent' to='/notifications' data-preview-title-id='column.notifications' data-preview-icon='bell' ><NotificationsCounterIcon className='column-link__icon' /><FormattedMessage id='tabs_bar.notifications' defaultMessage='Notifications' /></NavLink> |
||||
<FollowRequestsNavLink /> |
||||
<NavLink className='column-link column-link--transparent' to='/timelines/public/local' data-preview-title-id='column.community' data-preview-icon='users' ><Icon className='column-link__icon' id='users' fixedWidth /><FormattedMessage id='tabs_bar.local_timeline' defaultMessage='Local' /></NavLink> |
||||
<NavLink className='column-link column-link--transparent' exact to='/timelines/public' data-preview-title-id='column.public' data-preview-icon='globe' ><Icon className='column-link__icon' id='globe' fixedWidth /><FormattedMessage id='tabs_bar.federated_timeline' defaultMessage='Federated' /></NavLink> |
||||
<NavLink className='column-link column-link--transparent' to='/timelines/direct'><Icon className='column-link__icon' id='envelope' fixedWidth /><FormattedMessage id='navigation_bar.direct' defaultMessage='Direct messages' /></NavLink> |
||||
<NavLink className='column-link column-link--transparent' to='/favourites'><Icon className='column-link__icon' id='star' fixedWidth /><FormattedMessage id='navigation_bar.favourites' defaultMessage='Favourites' /></NavLink> |
||||
<NavLink className='column-link column-link--transparent' to='/lists'><Icon className='column-link__icon' id='list-ul' fixedWidth /><FormattedMessage id='navigation_bar.lists' defaultMessage='Lists' /></NavLink> |
||||
|
||||
<ListPanel /> |
||||
|
||||
<hr /> |
||||
|
||||
<a className='column-link column-link--transparent' href='/settings/preferences' target='_blank'><Icon className='column-link__icon' id='cog' fixedWidth /><FormattedMessage id='navigation_bar.preferences' defaultMessage='Preferences' /></a> |
||||
<a className='column-link column-link--transparent' href='/relationships' target='_blank'><Icon className='column-link__icon' id='address-book-o' fixedWidth /><FormattedMessage id='navigation_bar.follows_and_followers' defaultMessage='Follows and followers' /></a> |
||||
</div> |
||||
); |
||||
|
||||
export default withRouter(NavigationPanel); |
@ -1,23 +1,9 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { connect } from 'react-redux'; |
||||
import Icon from 'mastodon/components/icon'; |
||||
import IconWithBadge from 'mastodon/components/icon_with_badge'; |
||||
|
||||
const mapStateToProps = state => ({ |
||||
count: state.getIn(['notifications', 'unread']), |
||||
id: 'bell', |
||||
}); |
||||
|
||||
const formatNumber = num => num > 99 ? '99+' : num; |
||||
|
||||
const NotificationsCounterIcon = ({ count }) => ( |
||||
<i className='icon-with-badge'> |
||||
<Icon id='bell' fixedWidth /> |
||||
{count > 0 && <i className='icon-with-badge__badge'>{formatNumber(count)}</i>} |
||||
</i> |
||||
); |
||||
|
||||
NotificationsCounterIcon.propTypes = { |
||||
count: PropTypes.number.isRequired, |
||||
}; |
||||
|
||||
export default connect(mapStateToProps)(NotificationsCounterIcon); |
||||
export default connect(mapStateToProps)(IconWithBadge); |
||||
|
Loading…
Reference in new issue