-
Notifications
You must be signed in to change notification settings - Fork 212
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 #77 from topcoder-platform/develop
First version of Join Community
- Loading branch information
Showing
28 changed files
with
348 additions
and
30 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
13 changes: 5 additions & 8 deletions
13
__tests__/shared/components/__snapshots__/LoadingIndicator.jsx.snap
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 |
---|---|---|
@@ -1,12 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders correctly 1`] = ` | ||
<div | ||
className="src-shared-components-LoadingIndicator-___styles__root___3fi9o" | ||
> | ||
<img | ||
alt="Loading data" | ||
src="https://raw.githubusercontent.com/appirio-tech/topcoder-app/dev/assets/images/ripple.gif" | ||
/> | ||
</div> | ||
<img | ||
alt="Loading..." | ||
className="src-shared-components-LoadingIndicator-___styles__style___3RNHL" | ||
src="2f402d440d802a10b7672b75897c47a5.gif" | ||
/> | ||
`; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,22 @@ | ||
import _ from 'lodash'; | ||
import { createActions } from 'redux-actions'; | ||
import { getService as getGroupService } from 'services/groups'; | ||
|
||
/** | ||
* Creates the action for joining the group. | ||
* @param {String} token Topcoder auth token V3. | ||
* @param {String} groupId | ||
* @param {String} memberId | ||
*/ | ||
function joinDone(token, groupId, memberId) { | ||
const service = getGroupService(token); | ||
return service.addMember(groupId, memberId, 'user'); | ||
} | ||
|
||
export default createActions({ | ||
TC_COMMUNITY: { | ||
HIDE_JOIN_BUTTON: _.noop, | ||
JOIN_INIT: _.noop, | ||
JOIN_DONE: joinDone, | ||
}, | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import PT from 'prop-types'; | ||
import Source from 'assets/images/ripple.gif'; | ||
import React from 'react'; | ||
import './styles.scss'; | ||
import { themr } from 'react-css-themr'; | ||
import style from './styles.scss'; | ||
|
||
const Loader = 'https://raw.githubusercontent.com/appirio-tech/topcoder-app/dev/assets/images/ripple.gif'; | ||
|
||
export default function LoadingIndicator() { | ||
function LoadingIndicator({ theme }) { | ||
return ( | ||
<div styleName="root"> | ||
<img src={Loader} alt="Loading data" /> | ||
</div> | ||
<img | ||
alt="Loading..." | ||
className={theme.style} | ||
src={Source} | ||
/> | ||
); | ||
} | ||
|
||
LoadingIndicator.propTypes = { | ||
theme: PT.shape().isRequired, | ||
}; | ||
|
||
export default themr('LoadingIndicator', style)(LoadingIndicator); |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
@import '~styles/tc-styles'; | ||
|
||
.root { | ||
.style { | ||
display: block; | ||
margin: 0 auto; | ||
text-align: center; | ||
} |
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
81 changes: 81 additions & 0 deletions
81
src/shared/components/tc-communities/JoinCommunity/index.jsx
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,81 @@ | ||
/** | ||
* Join Community component. It includes 'Join Community' button, which is | ||
* automatically hidden, when a user is already member of community. Button | ||
* text changes to the loading symbol, when the joining is underway. And a | ||
* modal is shown on success. | ||
*/ | ||
|
||
/* global window */ | ||
|
||
import config from 'utils/config'; | ||
import LoadingIndicator from 'components/LoadingIndicator'; | ||
import Modal from 'components/Modal'; | ||
import PT from 'prop-types'; | ||
import React from 'react'; | ||
import style from './style.scss'; | ||
|
||
export default function JoinCommunity({ | ||
canJoin, | ||
communityName, | ||
groupId, | ||
hideJoinButton, | ||
join, | ||
joined, | ||
joining, | ||
token, | ||
userId, | ||
}) { | ||
if (!canJoin) return <div styleName="placeholder" />; | ||
return ( | ||
<div> | ||
<button | ||
onClick={() => { | ||
if (joining || joined) return; | ||
if (token) join(token, groupId, userId); | ||
else { | ||
/* If our visitor is not authenticated, the button redirects to | ||
* login page, with return URL set back to this page. */ | ||
const url = encodeURIComponent(window.location.href); | ||
window.location = `${config.URL.AUTH}?retUrl=${url}`; | ||
} | ||
}} | ||
styleName={`link ${joining ? 'joining' : ''}`} | ||
> | ||
{ joining ? ( | ||
<div> | ||
<p>Joining...</p> | ||
<LoadingIndicator theme={{ style: style.loadingIndicator }} /> | ||
</div> | ||
) : 'Join Community'} | ||
</button> | ||
{ joined ? ( | ||
<Modal onCancel={hideJoinButton}> | ||
<h1 styleName="modalTitle">Congratulations!</h1> | ||
<p styleName="modalMsg">You have joined {communityName}!</p> | ||
<button | ||
onClick={hideJoinButton} | ||
styleName="done" | ||
>Return to the Community</button> | ||
</Modal> | ||
) : null} | ||
</div> | ||
); | ||
} | ||
|
||
JoinCommunity.defaultProps = { | ||
groupId: null, | ||
token: null, | ||
userId: null, | ||
}; | ||
|
||
JoinCommunity.propTypes = { | ||
canJoin: PT.bool.isRequired, | ||
communityName: PT.string.isRequired, | ||
groupId: PT.string, | ||
hideJoinButton: PT.func.isRequired, | ||
join: PT.func.isRequired, | ||
joined: PT.bool.isRequired, | ||
joining: PT.bool.isRequired, | ||
token: PT.string, | ||
userId: PT.string, | ||
}; |
88 changes: 88 additions & 0 deletions
88
src/shared/components/tc-communities/JoinCommunity/style.scss
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,88 @@ | ||
@import "~styles/tc-styles"; | ||
|
||
.done { | ||
color: $tc-light-blue; | ||
display: block; | ||
background: $tc-white; | ||
border: 1px solid $tc-light-blue; | ||
border-radius: 20px; | ||
font: 700 14px/40px 'Open Sans'; | ||
margin: 0 auto; | ||
height: 40px; | ||
text-align: center; | ||
text-transform: uppercase; | ||
width: 300px; | ||
|
||
&:hover, | ||
&:active, | ||
&:focus, | ||
&:visited { | ||
color: $tc-light-blue; | ||
outline: none; | ||
text-decoration: none; | ||
} | ||
|
||
&:hover { | ||
background: $tc-light-blue-10; | ||
} | ||
} | ||
|
||
.link { | ||
color: $tc-green; | ||
display: block; | ||
background: $tc-white; | ||
border: 1px solid $tc-green; | ||
border-radius: 20px; | ||
font: 700 14px/40px 'Open Sans'; | ||
margin: 24px auto; | ||
height: 40px; | ||
text-align: center; | ||
text-transform: uppercase; | ||
width: 171px; | ||
|
||
&:hover, | ||
&:active, | ||
&:focus, | ||
&:visited { | ||
color: $tc-green; | ||
outline: none; | ||
text-decoration: none; | ||
} | ||
|
||
&:hover { | ||
background: $tc-green-10; | ||
} | ||
|
||
&.joining:hover { | ||
background: $tc-white; | ||
cursor: default; | ||
} | ||
|
||
&.joining div p { | ||
display: inline-block; | ||
margin-right: 12px; | ||
vertical-align: top; | ||
} | ||
} | ||
|
||
.loadingIndicator { | ||
display: inline-block; | ||
height: 32px; | ||
padding-top: 4px; | ||
width: 32px; | ||
} | ||
|
||
.modalTitle { | ||
text-align: center; | ||
} | ||
|
||
.modalMsg { | ||
@include tc-body; | ||
|
||
margin: 24px 0; | ||
text-align: center; | ||
} | ||
|
||
.placeholder { | ||
height: 24px; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
@import '~styles/tc-styles'; | ||
|
||
.container { | ||
padding: 35px 0; | ||
padding-bottom: 70px; | ||
|
||
@include xxs-to-sm { | ||
|
Oops, something went wrong.