mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 22:54:42 -04:00

* Extract code into hook * Refactor code to remove let * Reformat code * Extract version-info-modal into components * Use main block in landinglayout * Add fixedWidth and classname attribute to IconButton Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import equal from 'fast-deep-equal'
|
|
import React from 'react'
|
|
import { Dropdown } from 'react-bootstrap'
|
|
import { Trans, useTranslation } from 'react-i18next'
|
|
import { useSelector } from 'react-redux'
|
|
import { LinkContainer } from 'react-router-bootstrap'
|
|
import { ApplicationState } from '../../../redux'
|
|
import { clearUser } from '../../../redux/user/methods'
|
|
import { ForkAwesomeIcon } from '../../common/fork-awesome/fork-awesome-icon'
|
|
import { UserAvatar } from '../../common/user-avatar/user-avatar'
|
|
|
|
export const UserDropdown: React.FC = () => {
|
|
useTranslation()
|
|
const user = useSelector((state: ApplicationState) => state.user, equal)
|
|
|
|
if (!user) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<Dropdown alignRight>
|
|
<Dropdown.Toggle size="sm" variant="dark" id="dropdown-user" className={ 'd-flex align-items-center' }>
|
|
<UserAvatar name={ user.name } photo={ user.photo }/>
|
|
</Dropdown.Toggle>
|
|
|
|
<Dropdown.Menu className='text-start'>
|
|
<LinkContainer to={ '/n/features' }>
|
|
<Dropdown.Item dir='auto'>
|
|
<ForkAwesomeIcon icon="bolt" fixedWidth={ true } className="mx-2"/>
|
|
<Trans i18nKey="editor.help.documents.features"/>
|
|
</Dropdown.Item>
|
|
</LinkContainer>
|
|
<LinkContainer to={ '/profile' }>
|
|
<Dropdown.Item dir='auto'>
|
|
<ForkAwesomeIcon icon="user" fixedWidth={ true } className="mx-2"/>
|
|
<Trans i18nKey="profile.userProfile"/>
|
|
</Dropdown.Item>
|
|
</LinkContainer>
|
|
<Dropdown.Item
|
|
dir='auto'
|
|
onClick={ () => {
|
|
clearUser()
|
|
} }>
|
|
<ForkAwesomeIcon icon="sign-out" fixedWidth={ true } className="mx-2"/>
|
|
<Trans i18nKey="login.signOut"/>
|
|
</Dropdown.Item>
|
|
</Dropdown.Menu>
|
|
</Dropdown>)
|
|
}
|