1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-11 18:13:52 +02:00

Remove user menu for single-user

This commit is contained in:
Chen-I Lim 2021-01-21 10:42:05 -08:00
parent dfbc07c06d
commit 2bddb0cfc0
3 changed files with 48 additions and 31 deletions

View File

@ -97,6 +97,7 @@
"Sidebar.settings": "Settings",
"Sidebar.spanish": "Spanish",
"Sidebar.template-from-board": "New template from board",
"Sidebar.title": "Boards",
"Sidebar.untitled": "Untitled",
"Sidebar.untitled-board": "(Untitled Board)",
"Sidebar.untitled-view": "(Untitled View)",

View File

@ -44,8 +44,9 @@
padding: 3px 20px;
margin-bottom: 5px;
>.username {
>.heading {
line-height: 30px;
cursor: default;
}
>.IconButton {

View File

@ -9,7 +9,7 @@ import {BoardView, MutableBoardView} from '../blocks/boardView'
import mutator from '../mutator'
import octoClient from '../octoClient'
import {darkTheme, defaultTheme, lightTheme, setTheme} from '../theme'
import {UserContext} from '../user'
import {IUser, UserContext} from '../user'
import {WorkspaceTree} from '../viewModel/workspaceTree'
import Button from '../widgets/buttons/button'
import IconButton from '../widgets/buttons/iconButton'
@ -87,35 +87,21 @@ class Sidebar extends React.Component<Props, State> {
return (
<div className='Sidebar octo-sidebar'>
<div className='octo-sidebar-header'>
<UserContext.Consumer>
{(user) => (
<div className='username'>
<MenuWrapper>
<Button>
{user?.username}
</Button>
<Menu>
<Menu.Text
id='logout'
name={intl.formatMessage({id: 'Sidebar.logout', defaultMessage: 'Log out'})}
onClick={async () => {
octoClient.logout()
window.location.href = '/login'
}}
/>
<Menu.Text
id='changePassword'
name={intl.formatMessage({id: 'Sidebar.changePassword', defaultMessage: 'Change password'})}
onClick={async () => {
window.location.href = '/change_password'
}}
/>
</Menu>
</MenuWrapper>
</div>
)}
</UserContext.Consumer>
<div className='heading'>
<UserContext.Consumer>
{(user) => {
if (user) {
if (user.id === 'single-user') {
return (
<div>{intl.formatMessage({id: 'Sidebar.title', defaultMessage: 'Boards'})}</div>
)
}
return this.renderUserMenu(user)
}
return <div/>
}}
</UserContext.Consumer>
</div>
<div className='octo-spacer'/>
<IconButton
@ -375,6 +361,35 @@ class Sidebar extends React.Component<Props, State> {
)
}
private renderUserMenu(user: IUser): JSX.Element {
const {intl} = this.props
return (
<MenuWrapper>
<Button>
{user.username}
</Button>
<Menu>
<Menu.Text
id='logout'
name={intl.formatMessage({id: 'Sidebar.logout', defaultMessage: 'Log out'})}
onClick={async () => {
octoClient.logout()
window.location.href = '/login'
}}
/>
<Menu.Text
id='changePassword'
name={intl.formatMessage({id: 'Sidebar.changePassword', defaultMessage: 'Change password'})}
onClick={async () => {
window.location.href = '/change_password'
}}
/>
</Menu>
</MenuWrapper>
)
}
private boardClicked(board: Board): void {
this.props.showBoard(board.id)
}