-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager): Refactor user action buttons to common component
- Loading branch information
David Emory
committed
May 10, 2018
1 parent
12e7fac
commit 7918eee
Showing
4 changed files
with
78 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { Component, PropTypes } from 'react' | ||
import { Button } from 'react-bootstrap' | ||
import { LinkContainer } from 'react-router-bootstrap' | ||
import Icon from '@conveyal/woonerf/components/icon' | ||
|
||
/** | ||
* A common component containing buttons for standard user actions: "My | ||
* Account", "Site Admin", and "Logout" | ||
*/ | ||
|
||
export default class UserButtons extends Component { | ||
static propTypes = { | ||
logoutHandler: PropTypes.func, | ||
user: PropTypes.object | ||
} | ||
|
||
render () { | ||
const { logoutHandler, user } = this.props | ||
const buttonStyle = { margin: 2 } | ||
return ( | ||
<div style={{ marginTop: 15, textAlign: 'center' }}> | ||
<LinkContainer to='/settings/profile'> | ||
<Button bsStyle='primary' bsSize='small' style={buttonStyle}> | ||
<Icon type='user' /> My account | ||
</Button> | ||
</LinkContainer> | ||
{user.permissions && user.permissions.isApplicationAdmin() && | ||
user.permissions.canAdministerAnOrganization() && ( | ||
<LinkContainer to='/admin/users'> | ||
<Button | ||
bsStyle='success' | ||
bsSize='small' | ||
style={buttonStyle} | ||
> | ||
<Icon type='cog' /> Site Admin | ||
</Button> | ||
</LinkContainer> | ||
) | ||
} | ||
<Button | ||
style={buttonStyle} | ||
bsSize='small' | ||
bsStyle='primary' | ||
onClick={logoutHandler}> | ||
<Icon type='sign-out' /> Logout | ||
</Button> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters