-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from OpenChemistry/owner-module
Owner module
- Loading branch information
Showing
8 changed files
with
264 additions
and
15 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
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
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,126 @@ | ||
import React, { Component } from 'react'; | ||
|
||
import { withStyles, TextField, Link, InputAdornment, Paper, Grid, Typography } from '@material-ui/core'; | ||
import OpenInNewIcon from '@material-ui/icons/OpenInNew' | ||
|
||
import PageHead from '../page-head'; | ||
import PageBody from '../page-body'; | ||
|
||
import { TwitterTimelineEmbed } from 'react-twitter-embed'; | ||
|
||
const styles = theme => ({ | ||
paper: { | ||
padding: '10px' | ||
}, | ||
textField: { | ||
marginTop: '8px' | ||
}, | ||
column: { | ||
padding: theme.spacing.unit * 3 | ||
} | ||
}); | ||
|
||
class CreatorProfile extends Component { | ||
render () { | ||
const {userInfo, mediaIds, classes} = this.props; | ||
const { creator } = this.props.location.state; | ||
return ( | ||
<div> | ||
<PageHead> | ||
<Typography color="inherit" gutterBottom variant="display1"> | ||
{creator.login}'s Profile | ||
</Typography> | ||
</PageHead> | ||
<PageBody noOverlap> | ||
<Grid container style={{height: '100%'}} alignItems='stretch'> | ||
<Grid | ||
className={classes.column} | ||
item | ||
xs={mediaIds.twitterId ? 16 : 24} | ||
md={mediaIds.twitterId ? 8 : 12} > | ||
<Paper className={classes.paper}> | ||
<div> | ||
<TextField | ||
className={classes.textField} | ||
name='name' | ||
helperText='Name' | ||
value={userInfo.firstName + ' ' + userInfo.lastName} | ||
fullWidth | ||
InputProps={{ readOnly: true }} | ||
/> | ||
</div> | ||
<div> | ||
<TextField | ||
className={classes.textField} | ||
name='email' | ||
helperText='Email Address' | ||
value={userInfo.email} | ||
fullWidth | ||
InputProps={{ readOnly: true }} | ||
/> | ||
</div> | ||
<div> | ||
<TextField | ||
className={classes.textField} | ||
name='twitterId' | ||
helperText='Twitter Handle' | ||
value={mediaIds.twitterId ? mediaIds.twitterId : 'No Associated Twitter Handle'} | ||
InputProps={{ | ||
readOnly: true, | ||
startAdornment: | ||
<InputAdornment position='start'> | ||
{mediaIds.twitterId != undefined | ||
? <Link | ||
href={'http://www.twitter.com/' + mediaIds.twitterId} | ||
target='_blank' | ||
> | ||
<OpenInNewIcon/> | ||
</Link> | ||
: null } | ||
</InputAdornment>}} | ||
fullWidth | ||
/> | ||
</div> | ||
<div> | ||
<TextField | ||
className={classes.textField} | ||
name='orcidId' | ||
helperText='Orcid ID' | ||
value={mediaIds.orcidId ? mediaIds.orcidId : 'No Associated Orcid ID'} | ||
InputProps={{ | ||
readOnly: true, | ||
startAdornment: | ||
<InputAdornment position='start'> | ||
{mediaIds.orcidId != undefined | ||
? <Link | ||
href={'http://www.orcid.com/' + mediaIds.orcidId} | ||
target='_blank' | ||
> | ||
<OpenInNewIcon color={mediaIds.orcidId ? 'primary' : 'disabled'}/> | ||
</Link> | ||
: null } | ||
</InputAdornment>}} | ||
fullWidth | ||
/> | ||
</div> | ||
</Paper> | ||
</Grid> | ||
{mediaIds.twitterId | ||
? <Grid className={classes.column} item xs={8} md={4} > | ||
<Paper> | ||
<TwitterTimelineEmbed | ||
sourceType="profile" | ||
screenName={mediaIds.twitterId} | ||
options={{height: 500}} | ||
/> | ||
</Paper> | ||
</Grid> | ||
: null} | ||
</Grid> | ||
</PageBody> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styles)(CreatorProfile); |
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
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 } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import CreatorProfile from '../../components/user/creator-profile'; | ||
|
||
import { calculations, molecules, selectors } from '@openchemistry/redux'; | ||
|
||
class CreatorContainer extends Component { | ||
|
||
componentDidMount() { | ||
const { location, dispatch } = this.props; | ||
const { type, id } = location.state; | ||
if (type === 'calculation') { | ||
dispatch(calculations.loadCalculationById(id)) | ||
} else { | ||
dispatch(molecules.loadMoleculeById(id)) | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<CreatorProfile | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
const userInfo = selectors.calculations.getCalculationCreator(state); | ||
let twitterId = userInfo.twitterId; | ||
let orcidId = userInfo.orcidId; | ||
|
||
if (!twitterId) { | ||
twitterId = undefined | ||
} | ||
if (!orcidId) { | ||
orcidId = undefined | ||
} | ||
const mediaIds = {twitterId, orcidId} | ||
|
||
return { | ||
userInfo, | ||
mediaIds | ||
}; | ||
} | ||
|
||
CreatorContainer = connect(mapStateToProps)(CreatorContainer) | ||
|
||
export default CreatorContainer; |