2019-04-19 20:14:32 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 16:38:10 +02:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
2019-04-19 20:14:32 +02:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2023-05-28 16:38:10 +02:00
|
|
|
|
|
|
|
import { Helmet } from 'react-helmet';
|
2024-02-22 22:04:09 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
2023-05-28 16:38:10 +02:00
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2023-05-28 16:38:10 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2019-04-20 18:21:11 +02:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-28 16:38:10 +02:00
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
import PeopleIcon from '@/material-icons/400-24px/group.svg?react';
|
|
|
|
import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react';
|
|
|
|
import LogoutIcon from '@/material-icons/400-24px/logout.svg?react';
|
2024-02-22 23:59:03 +01:00
|
|
|
import ManufacturingIcon from '@/material-icons/400-24px/manufacturing-fill.svg?react';
|
2024-02-22 22:04:09 +01:00
|
|
|
import MenuIcon from '@/material-icons/400-24px/menu.svg?react';
|
|
|
|
import NotificationsIcon from '@/material-icons/400-24px/notifications-fill.svg?react';
|
|
|
|
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
|
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2023-05-28 16:38:10 +02:00
|
|
|
import Column from 'flavours/glitch/components/column';
|
2024-02-22 22:04:09 +01:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
|
|
|
import { logOut } from 'flavours/glitch/utils/log_out';
|
2023-05-28 16:38:10 +02:00
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
import elephantUIPlane from '../../../../images/elephant_ui_plane.svg';
|
|
|
|
import { changeComposing, mountCompose, unmountCompose } from '../../actions/compose';
|
2023-11-15 12:01:51 +01:00
|
|
|
import { mascot } from '../../initial_state';
|
2024-02-22 22:04:09 +01:00
|
|
|
import { isMobile } from '../../is_mobile';
|
2023-05-28 16:38:10 +02:00
|
|
|
import Motion from '../ui/util/optional_motion';
|
|
|
|
|
|
|
|
import ComposeFormContainer from './containers/compose_form_container';
|
|
|
|
import SearchContainer from './containers/search_container';
|
|
|
|
import SearchResultsContainer from './containers/search_results_container';
|
|
|
|
|
2018-08-28 12:01:04 +02:00
|
|
|
const messages = defineMessages({
|
2024-02-22 22:04:09 +01:00
|
|
|
start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
|
|
|
|
home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
|
|
|
|
notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
|
|
|
|
public: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
|
|
|
|
community: { id: 'navigation_bar.community_timeline', defaultMessage: 'Local timeline' },
|
2024-02-22 23:59:03 +01:00
|
|
|
settings: { id: 'navigation_bar.app_settings', defaultMessage: 'App settings' },
|
2024-02-22 22:04:09 +01:00
|
|
|
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
2022-05-03 10:59:23 +02:00
|
|
|
compose: { id: 'navigation_bar.compose', defaultMessage: 'Compose new post' },
|
2024-02-22 22:04:09 +01:00
|
|
|
logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' },
|
|
|
|
logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' },
|
2018-08-28 12:01:04 +02:00
|
|
|
});
|
|
|
|
|
2019-04-20 18:21:11 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => ({
|
2024-02-22 22:04:09 +01:00
|
|
|
columns: state.getIn(['settings', 'columns']),
|
2022-10-23 23:37:58 +02:00
|
|
|
showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : false,
|
2017-12-24 07:16:45 +01:00
|
|
|
});
|
|
|
|
|
2023-05-28 14:18:23 +02:00
|
|
|
class Compose extends PureComponent {
|
2023-02-03 20:52:07 +01:00
|
|
|
|
2019-04-19 20:14:32 +02:00
|
|
|
static propTypes = {
|
2024-02-22 22:04:09 +01:00
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
columns: ImmutablePropTypes.list.isRequired,
|
2019-04-19 20:14:32 +02:00
|
|
|
multiColumn: PropTypes.bool,
|
2019-04-20 18:21:11 +02:00
|
|
|
showSearch: PropTypes.bool,
|
2019-04-21 19:07:48 +02:00
|
|
|
intl: PropTypes.object.isRequired,
|
2019-04-19 20:14:32 +02:00
|
|
|
};
|
2017-12-24 07:16:45 +01:00
|
|
|
|
2019-06-14 12:59:59 +02:00
|
|
|
componentDidMount () {
|
2024-02-22 22:04:09 +01:00
|
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(mountCompose());
|
2019-06-14 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
2024-02-22 22:04:09 +01:00
|
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(unmountCompose());
|
2019-06-14 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
handleLogoutClick = e => {
|
|
|
|
const { dispatch, intl } = this.props;
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
closeWhenConfirm: false,
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2024-02-22 23:59:03 +01:00
|
|
|
handleSettingsClick = e => {
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
dispatch(openModal({ modalType: 'SETTINGS', modalProps: {} }));
|
|
|
|
};
|
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
onFocus = () => {
|
|
|
|
this.props.dispatch(changeComposing(true));
|
|
|
|
};
|
|
|
|
|
|
|
|
onBlur = () => {
|
|
|
|
this.props.dispatch(changeComposing(false));
|
|
|
|
};
|
|
|
|
|
2017-12-27 01:54:28 +01:00
|
|
|
render () {
|
2024-02-22 22:04:09 +01:00
|
|
|
const { multiColumn, showSearch, intl } = this.props;
|
2018-01-08 17:40:34 +01:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
if (multiColumn) {
|
2024-02-22 22:04:09 +01:00
|
|
|
const { columns } = this.props;
|
2019-04-20 21:28:03 +02:00
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
return (
|
|
|
|
<div className='drawer' role='region' aria-label={intl.formatMessage(messages.compose)}>
|
|
|
|
<nav className='drawer__header'>
|
|
|
|
<Link to='/getting-started' className='drawer__tab' title={intl.formatMessage(messages.start)} aria-label={intl.formatMessage(messages.start)}><Icon id='bars' icon={MenuIcon} /></Link>
|
|
|
|
{!columns.some(column => column.get('id') === 'HOME') && (
|
|
|
|
<Link to='/home' className='drawer__tab' title={intl.formatMessage(messages.home_timeline)} aria-label={intl.formatMessage(messages.home_timeline)}><Icon id='home' icon={HomeIcon} /></Link>
|
|
|
|
)}
|
|
|
|
{!columns.some(column => column.get('id') === 'NOTIFICATIONS') && (
|
|
|
|
<Link to='/notifications' className='drawer__tab' title={intl.formatMessage(messages.notifications)} aria-label={intl.formatMessage(messages.notifications)}><Icon id='bell' icon={NotificationsIcon} /></Link>
|
|
|
|
)}
|
|
|
|
{!columns.some(column => column.get('id') === 'COMMUNITY') && (
|
|
|
|
<Link to='/public/local' className='drawer__tab' title={intl.formatMessage(messages.community)} aria-label={intl.formatMessage(messages.community)}><Icon id='users' icon={PeopleIcon} /></Link>
|
|
|
|
)}
|
|
|
|
{!columns.some(column => column.get('id') === 'PUBLIC') && (
|
|
|
|
<Link to='/public' className='drawer__tab' title={intl.formatMessage(messages.public)} aria-label={intl.formatMessage(messages.public)}><Icon id='globe' icon={PublicIcon} /></Link>
|
|
|
|
)}
|
2024-02-22 23:59:03 +01:00
|
|
|
<a
|
|
|
|
onClick={this.handleSettingsClick}
|
|
|
|
href='/settings/preferences'
|
|
|
|
className='drawer__tab'
|
|
|
|
title={intl.formatMessage(messages.settings)}
|
|
|
|
aria-label={intl.formatMessage(messages.settings)}
|
|
|
|
>
|
|
|
|
<Icon id='cogs' icon={ManufacturingIcon} />
|
|
|
|
</a>
|
2024-02-22 22:04:09 +01:00
|
|
|
<a href='/auth/sign_out' className='drawer__tab' title={intl.formatMessage(messages.logout)} aria-label={intl.formatMessage(messages.logout)} onClick={this.handleLogoutClick}><Icon id='sign-out' icon={LogoutIcon} /></a>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
{multiColumn && <SearchContainer /> }
|
2019-05-23 01:35:22 +02:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
<div className='drawer__pager'>
|
2024-02-22 22:04:09 +01:00
|
|
|
<div className='drawer__inner' onFocus={this.onFocus}>
|
|
|
|
<ComposeFormContainer autoFocus={!isMobile(window.innerWidth)} />
|
2018-12-19 19:09:04 +01:00
|
|
|
|
2022-10-04 20:13:23 +02:00
|
|
|
<div className='drawer__inner__mastodon'>
|
2024-02-22 22:04:09 +01:00
|
|
|
<img alt='' draggable='false' src={mascot || elephantUIPlane} />
|
2019-04-20 18:21:11 +02:00
|
|
|
</div>
|
2022-10-23 23:37:58 +02:00
|
|
|
</div>
|
2022-10-04 20:13:23 +02:00
|
|
|
|
2022-10-23 23:37:58 +02:00
|
|
|
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
|
2022-10-04 20:13:23 +02:00
|
|
|
{({ x }) => (
|
|
|
|
<div className='drawer__inner darker' style={{ transform: `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
|
|
|
|
<SearchResultsContainer />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
2017-12-29 23:55:06 +01:00
|
|
|
</div>
|
2022-10-04 20:13:23 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2024-02-22 22:04:09 +01:00
|
|
|
<Column onFocus={this.onFocus}>
|
2022-10-04 20:13:23 +02:00
|
|
|
<ComposeFormContainer />
|
2022-10-20 14:35:29 +02:00
|
|
|
|
|
|
|
<Helmet>
|
|
|
|
<meta name='robots' content='noindex' />
|
|
|
|
</Helmet>
|
2022-10-04 20:13:23 +02:00
|
|
|
</Column>
|
2017-12-27 01:54:28 +01:00
|
|
|
);
|
|
|
|
}
|
2019-04-20 21:28:03 +02:00
|
|
|
|
2017-12-24 07:16:45 +01:00
|
|
|
}
|
2023-03-24 23:15:25 +01:00
|
|
|
|
2024-02-22 22:04:09 +01:00
|
|
|
export default connect(mapStateToProps)(injectIntl(Compose));
|