Download spectrum/src/views/user/components/communityList.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/views/user/components/communityList.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/views/user/components/communityList.js
-
curl -L -o communityList.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/views/user/components/communityList.js
2.11 kB
| //@flow | |
| import * as React from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { withRouter } from 'react-router'; | |
| import compose from 'recompose/compose'; | |
| import { CommunityListItem } from 'src/components/entities'; | |
| import { ErrorBoundary } from 'src/components/error'; | |
| import { Loading } from 'src/components/loading'; | |
| import { PrimaryOutlineButton } from 'src/components/button'; | |
| import { getUserCommunityConnection } from 'shared/graphql/queries/user/getUserCommunityConnection'; | |
| import type { GetUserCommunityConnectionType } from 'shared/graphql/queries/user/getUserCommunityConnection'; | |
| type Props = { | |
| data: { | |
| user: GetUserCommunityConnectionType, | |
| }, | |
| currentUser: Object, | |
| user: Object, | |
| }; | |
| class CommunityList extends React.Component<Props> { | |
| render() { | |
| const { data } = this.props; | |
| if (data.loading) { | |
| return <Loading style={{ padding: '32px' }} />; | |
| } | |
| if ( | |
| !data.user || | |
| !data.user.communityConnection || | |
| !data.user.communityConnection.edges || | |
| data.user.communityConnection.edges.length === 0 | |
| ) { | |
| return ( | |
| <div style={{ padding: '16px' }}> | |
| <PrimaryOutlineButton style={{ flex: '1' }} to={'/explore'}> | |
| Explore communities | |
| </PrimaryOutlineButton> | |
| </div> | |
| ); | |
| } | |
| const communities = data.user.communityConnection.edges.map( | |
| c => c && c.node | |
| ); | |
| let sortedCommunities = communities; | |
| if (sortedCommunities[0] && sortedCommunities[0].contextPermissions) { | |
| sortedCommunities = communities.slice(); | |
| } | |
| return ( | |
| <div> | |
| {sortedCommunities.map(community => { | |
| if (!community) return null; | |
| return ( | |
| <ErrorBoundary key={community.id}> | |
| <CommunityListItem | |
| communityObject={community} | |
| profilePhoto={community.profilePhoto} | |
| name={community.name} | |
| /> | |
| </ErrorBoundary> | |
| ); | |
| })} | |
| </div> | |
| ); | |
| } | |
| } | |
| export default compose( | |
| withRouter, | |
| getUserCommunityConnection, | |
| connect() | |
| )(CommunityList); | |