2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-05-15 03:31:24 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import { closePopover } from '../../actions/popover'
|
2020-12-16 22:29:06 +00:00
|
|
|
import { openModal } from '../../actions/modal'
|
2020-05-15 21:29:46 +01:00
|
|
|
import { meUsername } from '../../initial_state'
|
2020-12-16 22:29:06 +00:00
|
|
|
import { MODAL_DISPLAY_OPTIONS } from '../../constants'
|
2020-05-15 03:31:24 +01:00
|
|
|
import PopoverLayout from './popover_layout'
|
|
|
|
import List from '../list'
|
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class NavSettingsPopover extends React.PureComponent {
|
2020-05-15 03:31:24 +01:00
|
|
|
|
2020-05-18 22:49:51 +01:00
|
|
|
handleOnClosePopover = () => {
|
|
|
|
this.props.onClosePopover()
|
2020-05-15 03:31:24 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 22:29:06 +00:00
|
|
|
handleOpenDisplayOptions = () => {
|
|
|
|
this.props.onOpenDisplayOptions()
|
|
|
|
this.handleOnClosePopover()
|
|
|
|
}
|
|
|
|
|
2020-05-15 03:31:24 +01:00
|
|
|
render() {
|
|
|
|
const { intl, isXS } = this.props
|
|
|
|
|
|
|
|
if (isXS) return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PopoverLayout width={240}>
|
|
|
|
<List
|
2020-07-25 00:54:44 +01:00
|
|
|
size='small'
|
2020-05-15 03:31:24 +01:00
|
|
|
scrollKey='profile_options'
|
|
|
|
items={[
|
2020-05-15 21:29:46 +01:00
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.profile),
|
2020-05-18 22:49:51 +01:00
|
|
|
to: `/${meUsername}`,
|
|
|
|
onClick: this.handleOnClosePopover,
|
2020-05-15 21:29:46 +01:00
|
|
|
},
|
2020-12-16 22:29:06 +00:00
|
|
|
{
|
|
|
|
title: 'Display options',
|
|
|
|
onClick: this.handleOpenDisplayOptions,
|
|
|
|
},
|
2020-05-15 03:31:24 +01:00
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.help),
|
|
|
|
href: 'https://help.gab.com',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.settings),
|
|
|
|
href: '/settings/preferences',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: intl.formatMessage(messages.logout),
|
|
|
|
href: '/auth/sign_out',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</PopoverLayout>
|
|
|
|
)
|
|
|
|
}
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
profile: { id: 'account.profile', defaultMessage: 'Profile' },
|
|
|
|
display: { id: 'display_options', defaultMessage: 'Display Options' },
|
|
|
|
help: { id: 'getting_started.help', defaultMessage: 'Help' },
|
|
|
|
settings: { id: 'settings', defaultMessage: 'Settings' },
|
|
|
|
logout: { 'id': 'confirmations.logout.confirm', 'defaultMessage': 'Log out' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onClosePopover() {
|
|
|
|
dispatch(closePopover())
|
|
|
|
},
|
2020-12-16 22:29:06 +00:00
|
|
|
onOpenDisplayOptions() {
|
|
|
|
dispatch(openModal(MODAL_DISPLAY_OPTIONS))
|
|
|
|
}
|
2020-08-19 01:22:15 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
NavSettingsPopover.propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onClosePopover: PropTypes.func.isRequired,
|
|
|
|
isXS: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(null, mapDispatchToProps)(NavSettingsPopover))
|