Skip to content

Commit caea065

Browse files
WIP...
changed name of ChallengeList to Challenges container in routes; added new self-serve route & nav item; create self-serve challenges list;
1 parent edfb775 commit caea065

File tree

8 files changed

+25089
-99
lines changed

8 files changed

+25089
-99
lines changed

package-lock.json

Lines changed: 25030 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions/challenges.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
5858
/**
5959
* Loads active challenges of project by page
6060
*/
61-
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null) {
61+
export function loadChallengesByPage (page, projectId, status, filterChallengeName = null, selfService = false) {
6262
return (dispatch, getState) => {
6363
dispatch({
6464
type: LOAD_CHALLENGES_PENDING,
@@ -85,6 +85,9 @@ export function loadChallengesByPage (page, projectId, status, filterChallengeNa
8585
} else if (!(_.isInteger(projectId) && projectId > 0)) {
8686
filters['status'] = 'Active'
8787
}
88+
if (selfService) {
89+
filters.selfService = true
90+
}
8891

8992
return fetchChallenges(filters, {
9093
page,

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class ChallengeList extends Component {
4848
* @param {String} projectStatus project status
4949
*/
5050
updateSearchParam (searchText, projectStatus) {
51-
const { status, filterChallengeName, loadChallengesByPage, activeProjectId } = this.props
51+
const { status, filterChallengeName, loadChallengesByPage, activeProjectId, selfServe } = this.props
5252
this.setState({ searchText }, () => {
5353
if (status !== projectStatus || searchText !== filterChallengeName) {
54-
loadChallengesByPage(1, activeProjectId, projectStatus, searchText)
54+
loadChallengesByPage(1, activeProjectId, projectStatus, searchText, selfServe)
5555
}
5656
})
5757
}
@@ -62,9 +62,9 @@ class ChallengeList extends Component {
6262
*/
6363
handlePageChange (pageNumber) {
6464
const { searchText } = this.state
65-
const { page, loadChallengesByPage, activeProjectId, status } = this.props
65+
const { page, loadChallengesByPage, activeProjectId, status, selfServe } = this.props
6666
if (page !== pageNumber) {
67-
loadChallengesByPage(pageNumber, activeProjectId, status, searchText)
67+
loadChallengesByPage(pageNumber, activeProjectId, status, searchText, selfServe)
6868
}
6969
}
7070

@@ -73,8 +73,8 @@ class ChallengeList extends Component {
7373
*/
7474
reloadChallengeList () {
7575
const { searchText } = this.state
76-
const { page, loadChallengesByPage, activeProjectId, status } = this.props
77-
loadChallengesByPage(page, activeProjectId, status, searchText)
76+
const { page, loadChallengesByPage, activeProjectId, status, selfServe } = this.props
77+
loadChallengesByPage(page, activeProjectId, status, searchText, selfServe)
7878
}
7979

8080
/**
@@ -104,7 +104,8 @@ class ChallengeList extends Component {
104104
totalChallenges,
105105
partiallyUpdateChallengeDetails,
106106
deleteChallenge,
107-
isBillingAccountExpired
107+
isBillingAccountExpired,
108+
selfServe
108109
} = this.props
109110
if (warnMessage) {
110111
return <Message warnMessage={warnMessage} />
@@ -196,7 +197,7 @@ class ChallengeList extends Component {
196197
<TabPanel />
197198
</Tabs>)}
198199
{
199-
challenges.length === 0 && (
200+
challenges.length === 0 && !selfServe && (
200201
<NoChallenge activeProject={activeProject} />
201202
)
202203
}

src/components/ChallengesComponent/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const ChallengesComponent = ({
2727
totalChallenges,
2828
partiallyUpdateChallengeDetails,
2929
deleteChallenge,
30-
isBillingAccountExpired
30+
isBillingAccountExpired,
31+
selfServe
3132
}) => {
3233
return (
3334
<Sticky top={10}>
@@ -41,7 +42,7 @@ const ChallengesComponent = ({
4142
__html: xss(activeProject ? activeProject.name : '')
4243
}}
4344
/>
44-
{ activeProject && activeProject.id && (
45+
{activeProject && activeProject.id && (
4546
<span>
4647
(<a href={`${CONNECT_APP_URL}/projects/${activeProject.id}`} target='_blank' rel='noopener noreferrer'>View Project</a>)
4748
</span>
@@ -76,6 +77,7 @@ const ChallengesComponent = ({
7677
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
7778
deleteChallenge={deleteChallenge}
7879
isBillingAccountExpired={isBillingAccountExpired}
80+
selfServe={selfServe}
7981
/>
8082
)}
8183
</div>
@@ -101,7 +103,8 @@ ChallengesComponent.propTypes = {
101103
totalChallenges: PropTypes.number.isRequired,
102104
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
103105
deleteChallenge: PropTypes.func.isRequired,
104-
isBillingAccountExpired: PropTypes.bool
106+
isBillingAccountExpired: PropTypes.bool,
107+
selfServe: PropTypes.bool
105108
}
106109

107110
ChallengesComponent.defaultProps = {

src/components/Sidebar/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ const Sidebar = ({
2121
{isBetaMode() && <span className={styles.beta}>beta</span>}
2222
</div>
2323
<Link to='/'>
24-
<div className={cn(styles.homeLink, { [styles.active]: !projectId })} onClick={resetSidebarActiveParams}>
24+
<div className={cn(styles.homeLink, { [styles.active]: !projectId && !selfServe })} onClick={resetSidebarActiveParams}>
2525
All Work
2626
</div>
2727
</Link>
28+
<Link to='/self-serve'>
29+
<div className={cn(styles.homeLink, { [styles.active]: !projectId && selfServe })} onClick={resetSidebarActiveParams}>
30+
Self-Service Opportunities
31+
</div>
32+
</Link>
2833
<a href='https://github.com/topcoder-platform/work-manager/issues/new' target='_blank' rel='noopener noreferrer' className='chameleon-feedback'>
29-
<div className={cn(styles.homeLink, { [styles.active]: !projectId })}>
34+
<div className={cn(styles.homeLink, { [styles.active]: !projectId && !selfServe })}>
3035
Give Application Feedback
3136
</div>
3237
</a>

src/containers/Challenges/index.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import Loader from '../../components/Loader'
1313
import { loadChallengesByPage, partiallyUpdateChallengeDetails, deleteChallenge } from '../../actions/challenges'
1414
import { loadProject } from '../../actions/projects'
1515
import { loadProjects, setActiveProject, resetSidebarActiveParams } from '../../actions/sidebar'
16-
import {
17-
CHALLENGE_STATUS
18-
} from '../../config/constants'
16+
import { CHALLENGE_STATUS } from '../../config/constants'
1917
import styles from './Challenges.module.scss'
2018

2119
class Challenges extends Component {
@@ -25,20 +23,20 @@ class Challenges extends Component {
2523
searchProjectName: '',
2624
onlyMyProjects: true
2725
}
28-
2926
this.updateProjectName = this.updateProjectName.bind(this)
3027
this.toggleMyProjects = this.toggleMyProjects.bind(this)
3128
}
3229

3330
componentDidMount () {
34-
const { activeProjectId, resetSidebarActiveParams, menu, projectId } = this.props
31+
console.debug('here')
32+
const { activeProjectId, resetSidebarActiveParams, menu, projectId, selfServe } = this.props
3533
if (menu === 'NULL' && activeProjectId !== -1) {
3634
resetSidebarActiveParams()
37-
} else {
38-
if (projectId) {
35+
} else if (projectId || selfServe) {
36+
if (!!projectId) {
3937
this.props.loadProject(projectId)
40-
this.reloadChallenges(this.props)
4138
}
39+
this.reloadChallenges(this.props)
4240
}
4341
}
4442

@@ -49,11 +47,11 @@ class Challenges extends Component {
4947
}
5048

5149
reloadChallenges (props) {
52-
const { activeProjectId, projectDetail: reduxProjectInfo, projectId, challengeProjectId, loadProject } = props
53-
if (activeProjectId !== challengeProjectId) {
54-
this.props.loadChallengesByPage(1, projectId ? parseInt(projectId) : -1, CHALLENGE_STATUS.ACTIVE, '')
55-
if (
56-
(!reduxProjectInfo || `${reduxProjectInfo.id}` !== projectId)
50+
const { activeProjectId, projectDetail: reduxProjectInfo, projectId, challengeProjectId, loadProject, selfServe } = props
51+
if (activeProjectId !== challengeProjectId || selfServe) {
52+
this.props.loadChallengesByPage(1, projectId ? parseInt(projectId) : -1, CHALLENGE_STATUS.ACTIVE, '', selfServe)
53+
if (!selfServe
54+
&& (!reduxProjectInfo || `${reduxProjectInfo.id}` !== projectId)
5755
) {
5856
loadProject(projectId)
5957
}
@@ -88,7 +86,8 @@ class Challenges extends Component {
8886
setActiveProject,
8987
partiallyUpdateChallengeDetails,
9088
deleteChallenge,
91-
isBillingAccountExpired
89+
isBillingAccountExpired,
90+
selfServe
9291
} = this.props
9392
const { searchProjectName, onlyMyProjects } = this.state
9493
const projectInfo = _.find(projects, { id: activeProjectId }) || {}
@@ -123,7 +122,7 @@ class Challenges extends Component {
123122
<label>My Projects</label>
124123
</div>
125124
{
126-
activeProjectId === -1 && <div>No project selected. Select one below</div>
125+
activeProjectId === -1 && !selfServe && <div>No project selected. Select one below</div>
127126
}
128127
{
129128
isLoading ? <Loader /> : (
@@ -133,7 +132,7 @@ class Challenges extends Component {
133132
)
134133
}
135134
</div>
136-
{ activeProjectId !== -1 && <ChallengesComponent
135+
{(activeProjectId !== -1 || selfServe) && <ChallengesComponent
137136
activeProject={({
138137
...projectInfo,
139138
...((reduxProjectInfo && reduxProjectInfo.id === activeProjectId) ? reduxProjectInfo : {})
@@ -151,6 +150,7 @@ class Challenges extends Component {
151150
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
152151
deleteChallenge={deleteChallenge}
153152
isBillingAccountExpired={isBillingAccountExpired}
153+
selfServe={selfServe}
154154
/>
155155
}
156156
</Fragment>
@@ -179,7 +179,8 @@ Challenges.propTypes = {
179179
setActiveProject: PropTypes.func.isRequired,
180180
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
181181
deleteChallenge: PropTypes.func.isRequired,
182-
isBillingAccountExpired: PropTypes.bool
182+
isBillingAccountExpired: PropTypes.bool,
183+
selfServe: PropTypes.bool
183184
}
184185

185186
const mapStateToProps = ({ challenges, sidebar, projects }) => ({

src/containers/Sidebar/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class SidebarContainer extends Component {
1515
}
1616

1717
componentDidMount () {
18-
const { projectId, activeProjectId, isLoading } = this.props
19-
if (!projectId && activeProjectId === -1 && !isLoading) {
18+
const { projectId, activeProjectId, isLoading, selfServe } = this.props
19+
if (!projectId && activeProjectId === -1 && !isLoading && !selfServe) {
2020
this.props.loadProjects()
2121
}
2222

@@ -62,7 +62,8 @@ SidebarContainer.propTypes = {
6262
activeProjectId: PropTypes.number,
6363
setActiveProject: PropTypes.func,
6464
projectId: PropTypes.string,
65-
resetSidebarActiveParams: PropTypes.func
65+
resetSidebarActiveParams: PropTypes.func,
66+
selfServe: PropTypes.bool
6667
}
6768

6869
const mapStateToProps = ({ sidebar }) => ({

src/routes.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { BETA_MODE_COOKIE_TAG } from './config/constants'
99
import renderApp from './components/App'
1010
import TopBarContainer from './containers/TopbarContainer'
1111
import Sidebar from './containers/Sidebar'
12-
import ChallengeList from './containers/Challenges'
12+
import Challenges from './containers/Challenges'
1313
import ChallengeEditor from './containers/ChallengeEditor'
1414
import { getFreshToken, decodeToken } from 'tc-auth-lib'
1515
import { saveToken } from './actions/auth'
@@ -100,7 +100,7 @@ class Routes extends React.Component {
100100
<Switch>
101101
<Route exact path='/'
102102
render={() => renderApp(
103-
<ChallengeList menu='NULL' warnMessage={warnMessage} />,
103+
<Challenges menu='NULL' warnMessage={warnMessage} />,
104104
<TopBarContainer />,
105105
<Sidebar />
106106
)()}
@@ -114,11 +114,18 @@ class Routes extends React.Component {
114114
<Switch>
115115
<Route exact path='/'
116116
render={() => renderApp(
117-
<ChallengeList menu='NULL' />,
117+
<Challenges menu='NULL' />,
118118
<TopBarContainer />,
119119
<Sidebar />
120120
)()}
121121
/>
122+
<Route exact path='/self-serve'
123+
render={() => renderApp(
124+
<Challenges selfServe='true' />,
125+
<TopBarContainer />,
126+
<Sidebar selfServe='true' />
127+
)()}
128+
/>
122129
<Route exact path='/projects/:projectId/challenges/new'
123130
render={({ match }) => renderApp(
124131
<ChallengeEditor />,
@@ -135,7 +142,7 @@ class Routes extends React.Component {
135142
)()} />
136143
<Route exact path='/projects/:projectId/challenges'
137144
render={({ match }) => renderApp(
138-
<ChallengeList projectId={match.params.projectId} />,
145+
<Challenges projectId={match.params.projectId} />,
139146
<TopBarContainer projectId={match.params.projectId} />,
140147
<Sidebar projectId={match.params.projectId} />
141148
)()} />

0 commit comments

Comments
 (0)