-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ec1eda
commit e0c928f
Showing
21 changed files
with
375 additions
and
22 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
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
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,95 @@ | ||
import React from 'react'; | ||
import { CircularProgress } from '@material-ui/core'; | ||
import APIService from '../../services/APIService'; | ||
import OrgHomeHeader from './OrgHomeHeader'; | ||
import OrgHomeTabs from './OrgHomeTabs'; | ||
|
||
class OrgHome extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
isLoading: true, | ||
org: {}, | ||
members: [], | ||
tab: this.getDefaultTabIndex() | ||
} | ||
} | ||
|
||
getDefaultTabIndex() { | ||
const { location } = this.props; | ||
|
||
if(location.pathname.indexOf('/about') > -1) | ||
return 3; | ||
if(location.pathname.indexOf('/collections') > -1) | ||
return 2; | ||
if(location.pathname.indexOf('/sources') > -1) | ||
return 1; | ||
|
||
return 0; | ||
} | ||
|
||
componentDidMount() { | ||
this.refreshDataByURL() | ||
this.getMembers() | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if(prevProps.location.pathname !== this.props.location.pathname) { | ||
this.refreshDataByURL() | ||
this.getMembers() | ||
this.onTabChange(null, this.getDefaultTabIndex()) | ||
} | ||
} | ||
|
||
getURLFromPath() { | ||
const { location } = this.props; | ||
|
||
return location.pathname.split('/').slice(0, 3).join('/') + '/'; | ||
} | ||
|
||
refreshDataByURL() { | ||
this.setState( | ||
{isLoading: true}, | ||
() => APIService.new() | ||
.overrideURL(this.getURLFromPath()) | ||
.get() | ||
.then(response => this.setState({isLoading: false, org: response.data}))) | ||
} | ||
|
||
getMembers() { | ||
APIService.new() | ||
.overrideURL(this.getURLFromPath() + 'members/') | ||
.get() | ||
.then(response => this.setState({members: response.data})) | ||
} | ||
|
||
onTabChange = (event, value) => { | ||
this.setState({tab: value}) | ||
} | ||
|
||
render() { | ||
const { org, isLoading, tab, members } = this.state; | ||
const url = this.getURLFromPath() | ||
return ( | ||
<div style={isLoading ? {textAlign: 'center', marginTop: '40px'} : {}}> | ||
{ | ||
isLoading ? | ||
<CircularProgress color='primary' /> : | ||
<div className='col-md-12 home-container no-side-padding'> | ||
<OrgHomeHeader org={org} url={url} /> | ||
<OrgHomeTabs | ||
tab={tab} | ||
onChange={this.onTabChange} | ||
org={org} | ||
location={this.props.location} | ||
url={url} | ||
members={members} | ||
/> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default OrgHome; |
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,23 @@ | ||
import React from 'react'; | ||
import Search from '../search/Search'; | ||
|
||
class OrgHomeChildrenList extends React.Component { | ||
getURL() { | ||
const { url, resource } = this.props; | ||
|
||
return `${url}${resource}/`; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Search | ||
{...this.props} | ||
nested={true} | ||
baseURL={this.getURL()} | ||
fixedFilters={{isTable: true, limit: 25}} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
export default OrgHomeChildrenList; |
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,95 @@ | ||
import React from 'react'; | ||
import { | ||
Accordion, AccordionSummary, AccordionDetails, Typography, | ||
} from '@material-ui/core'; | ||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; | ||
import { get, map, isEmpty } from 'lodash'; | ||
import CustomAttributesAccordian from '../common/CustomAttributesAccordian'; | ||
import UserButton from '../common/UserButton'; | ||
|
||
const ACCORDIAN_HEADING_STYLES = { | ||
fontWeight: 'bold', | ||
} | ||
const ACCORDIAN_DETAILS_STYLES = { | ||
display: 'inline-block', width: '100%', textAlign: 'left', | ||
} | ||
|
||
const OrgHomeDetails = ({ org, members }) => { | ||
return ( | ||
<div className='col-md-12'> | ||
<div className='col-md-8 no-left-padding'> | ||
<Accordion defaultExpanded> | ||
<AccordionSummary | ||
className='light-gray-bg' | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel1a-content" | ||
> | ||
<Typography style={ACCORDIAN_HEADING_STYLES}>Organization Details</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}> | ||
<div className='col-md-12' style={{marginBottom: '5px', marginTop: '15px'}}> | ||
<div style={{fontWeight: '300'}} className='col-md-4 no-left-padding'> | ||
Company | ||
</div> | ||
<div className='col-md-8 no-right-padding'> | ||
{org.company} | ||
</div> | ||
</div> | ||
<div className='col-md-12' style={{marginBottom: '5px'}}> | ||
<div style={{fontWeight: '300'}} className='col-md-4 no-left-padding'> | ||
Website | ||
</div> | ||
<div className='col-md-8 no-right-padding'> | ||
{ | ||
org.website && | ||
<a href={org.website} target="_blank" rel="noopener noreferrer"> | ||
{org.website} | ||
</a> | ||
} | ||
</div> | ||
</div> | ||
<div className='col-md-12' style={{marginBottom: '15px'}}> | ||
<div style={{fontWeight: '300'}} className='col-md-4 no-left-padding'> | ||
Public Access | ||
</div> | ||
<div className='col-md-8 no-right-padding'> | ||
{org.public_access} | ||
</div> | ||
</div> | ||
</AccordionDetails> | ||
</Accordion> | ||
<CustomAttributesAccordian | ||
attributes={get(org, 'extras', {})} | ||
headingStyles={ACCORDIAN_HEADING_STYLES} | ||
detailStyles={ACCORDIAN_DETAILS_STYLES} | ||
/> | ||
</div> | ||
<div className='col-md-4 no-right-padding'> | ||
<Accordion defaultExpanded> | ||
<AccordionSummary | ||
className='light-gray-bg' | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel1a-content" | ||
> | ||
<Typography style={ACCORDIAN_HEADING_STYLES}>Members</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails style={ACCORDIAN_DETAILS_STYLES}> | ||
{ | ||
isEmpty(members) ? | ||
<div> No Members </div> : | ||
map(members, member => { | ||
let label = member.name; | ||
if(label === '- -') | ||
label = member.username | ||
return <UserButton label={label} href={`#${member.url}`} />; | ||
}) | ||
|
||
} | ||
</AccordionDetails> | ||
</Accordion> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default OrgHomeDetails; |
Oops, something went wrong.