Skip to content

Commit a000be0

Browse files
Merge branch 'cf-jan-2021' into fixes-#927
2 parents b614c36 + 6597d74 commit a000be0

File tree

12 files changed

+78
-12
lines changed

12 files changed

+78
-12
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ npm install
3939

4040
1. copy the environment file in docs/dev.env to /.env
4141

42-
1. add `127.0.0.1 local.topcoder-dev.com` to your /etc/hosts file
43-
4442
1. If you are using local instances of the API's, change the DEV_API_HOSTNAME in configs/constants/development.js to match your local api endpoint.
4543
- For example change it to 'http://localhost:3000/',
4644

@@ -50,7 +48,7 @@ npm install
5048
npm run dev
5149
```
5250

53-
You can access the app from [http://local.topcoder-dev.com:3001/](http://local.topcoder-dev.com:3001/)
51+
You can access the app from [http://localhost:3000/](http://localhost:3000/)
5452

5553
The page will reload if you make edits.
5654

config/constants/development.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
88
MEMBER_API_URL: `${DEV_API_HOSTNAME}/v4/members`,
99
MEMBER_API_V3_URL: `${DEV_API_HOSTNAME}/v3/members`,
10-
DEV_APP_URL: `http://local.${DOMAIN}`,
1110
CHALLENGE_API_URL: `${DEV_API_HOSTNAME}/v5/challenges`,
1211
CHALLENGE_TIMELINE_TEMPLATES_URL: `${DEV_API_HOSTNAME}/v5/timeline-templates`,
1312
CHALLENGE_TYPES_URL: `${DEV_API_HOSTNAME}/v5/challenge-types`,

config/constants/production.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
88
MEMBER_API_URL: `${PROD_API_HOSTNAME}/v4/members`,
99
MEMBER_API_V3_URL: `${PROD_API_HOSTNAME}/v3/members`,
10-
DEV_APP_URL: `https://submission-review.${DOMAIN}`,
1110
CHALLENGE_API_URL: `${PROD_API_HOSTNAME}/v5/challenges`,
1211
CHALLENGE_TIMELINE_TEMPLATES_URL: `${PROD_API_HOSTNAME}/v5/timeline-templates`,
1312
CHALLENGE_TYPES_URL: `${PROD_API_HOSTNAME}/v5/challenge-types`,

public/favicon.ico

15.4 KB
Binary file not shown.

scripts/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ checkBrowsers(paths.appPath, isInteractive)
9999
clearConsole()
100100
}
101101
console.log(chalk.cyan('Starting the development server...\n'))
102-
openBrowser(constants.DEV_APP_URL ? `${constants.DEV_APP_URL}:${process.env.PORT || 3000}` : urls.localUrlForBrowser)
102+
openBrowser(urls.localUrlForBrowser)
103103
})
104104

105105
const SIGNALS = ['SIGINT', 'SIGTERM']

src/actions/challenges.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
fetchResourceRoles,
1414
fetchChallengeTimelines,
1515
fetchChallengeTracks,
16+
fetchGroupDetail,
1617
updateChallenge,
1718
patchChallenge,
1819
deleteChallenge as deleteChallengeAPI,
@@ -186,6 +187,14 @@ export function loadChallengeDetails (projectId, challengeId) {
186187
}
187188
}
188189

190+
/**
191+
* Loads group details
192+
*/
193+
export function loadGroupDetails (groupIds) {
194+
const promiseAll = groupIds.map(id => fetchGroupDetail(id))
195+
return Promise.all(promiseAll)
196+
}
197+
189198
/**
190199
* Update challenge details
191200
*

src/components/ChallengeEditor/AssignedMember-Field/AssignedMember-Field.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,10 @@
4545
.readOnlyValue {
4646
margin-bottom: 0.5rem; // the same like `label` to be aligned
4747
}
48+
49+
.assignSelfField {
50+
margin-left: 20px;
51+
padding-top: 6px;
52+
}
4853
}
4954

src/components/ChallengeEditor/AssignedMember-Field/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import cn from 'classnames'
77
import styles from './AssignedMember-Field.module.scss'
88
import SelectUserAutocomplete from '../../SelectUserAutocomplete'
99

10-
const AssignedMemberField = ({ challenge, onChange, assignedMemberDetails, readOnly }) => {
10+
const AssignedMemberField = ({ challenge, onAssignSelf, onChange, assignedMemberDetails, readOnly }) => {
1111
const value = assignedMemberDetails ? {
1212
// if we know assigned member details, then show user `handle`, otherwise fallback to `userId`
1313
label: assignedMemberDetails.handle,
1414
value: assignedMemberDetails.userId + ''
1515
} : null
16+
1617
return (
1718
<div className={styles.row}>
1819
<div className={cn(styles.field, styles.col1)}>
@@ -28,6 +29,15 @@ const AssignedMemberField = ({ challenge, onChange, assignedMemberDetails, readO
2829
/>
2930
)}
3031
</div>
32+
{
33+
!readOnly &&
34+
<div className={styles.assignSelfField}>
35+
<a href='#' onClick={(e) => {
36+
e.preventDefault()
37+
onAssignSelf()
38+
}}>Assign to me</a>
39+
</div>
40+
}
3141
</div>
3242
)
3343
}
@@ -41,7 +51,8 @@ AssignedMemberField.propTypes = {
4151
challenge: PropTypes.shape().isRequired,
4252
onChange: PropTypes.func,
4353
assignedMemberDetails: PropTypes.shape(),
44-
readOnly: PropTypes.bool
54+
readOnly: PropTypes.bool,
55+
onAssignSelf: PropTypes.func
4556
}
4657

4758
export default AssignedMemberField

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import _ from 'lodash'
33
import { Helmet } from 'react-helmet'
44
import PropTypes from 'prop-types'
@@ -21,6 +21,7 @@ import PhaseInput from '../../PhaseInput'
2121
import LegacyLinks from '../../LegacyLinks'
2222
import AssignedMemberField from '../AssignedMember-Field'
2323
import { getResourceRoleByName } from '../../../util/tc'
24+
import { loadGroupDetails } from '../../../actions/challenges'
2425
import Tooltip from '../../Tooltip'
2526
import { MESSAGE, REVIEW_TYPES } from '../../../config/constants'
2627

@@ -40,6 +41,18 @@ const ChallengeView = ({
4041
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
4142

4243
const [openAdvanceSettings, setOpenAdvanceSettings] = useState(false)
44+
const [groups, setGroups] = useState('')
45+
46+
useEffect(() => {
47+
if (challenge.groups && challenge.groups.length > 0) {
48+
loadGroupDetails(challenge.groups).then(res => {
49+
const groups = _.map(res, 'name').join(', ')
50+
setGroups(groups)
51+
})
52+
} else {
53+
setGroups('')
54+
}
55+
}, [challenge.groups])
4356

4457
const getResourceFromProps = (name) => {
4558
const { resourceRoles } = metadata
@@ -167,7 +180,7 @@ const ChallengeView = ({
167180
</div>
168181
{openAdvanceSettings && (<div className={cn(styles.row, styles.topRow)}>
169182
<div className={styles.col}>
170-
<span><span className={styles.fieldTitle}>Groups:</span> {challenge.groups ? challenge.groups.join(', ') : ''}</span>
183+
<span><span className={styles.fieldTitle}>Groups:</span> {groups}</span>
171184
</div>
172185
</div>)}
173186
{

src/components/ChallengeEditor/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class ChallengeEditor extends Component {
9191
this.onUpdateOthers = this.onUpdateOthers.bind(this)
9292
this.onUpdateCheckbox = this.onUpdateCheckbox.bind(this)
9393
this.onUpdateAssignedMember = this.onUpdateAssignedMember.bind(this)
94+
this.onAssignSelf = this.onAssignSelf.bind(this)
9495
this.addFileType = this.addFileType.bind(this)
9596
this.removeFileType = this.removeFileType.bind(this)
9697
this.updateFileTypesMetadata = this.updateFileTypesMetadata.bind(this)
@@ -359,6 +360,22 @@ class ChallengeEditor extends Component {
359360
})
360361
}
361362

363+
/**
364+
* Update Assigned Member to Current User
365+
*/
366+
onAssignSelf () {
367+
const { loggedInUser } = this.props
368+
369+
const assignedMemberDetails = {
370+
handle: loggedInUser.handle,
371+
userId: loggedInUser.userId
372+
}
373+
374+
this.setState({
375+
assignedMemberDetails
376+
})
377+
}
378+
362379
/**
363380
* Update Single Select
364381
* @param option The select option
@@ -1350,6 +1367,7 @@ class ChallengeEditor extends Component {
13501367
challenge={challenge}
13511368
onChange={this.onUpdateAssignedMember}
13521369
assignedMemberDetails={assignedMemberDetails}
1370+
onAssignSelf={this.onAssignSelf}
13531371
/>
13541372
)}
13551373
<CopilotField challenge={challenge} copilots={metadata.members} onUpdateOthers={this.onUpdateOthers} />
@@ -1508,7 +1526,8 @@ ChallengeEditor.propTypes = {
15081526
createChallenge: PropTypes.func,
15091527
replaceResourceInRole: PropTypes.func,
15101528
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
1511-
deleteChallenge: PropTypes.func.isRequired
1529+
deleteChallenge: PropTypes.func.isRequired,
1530+
loggedInUser: PropTypes.shape().isRequired
15121531
}
15131532

15141533
export default withRouter(ChallengeEditor)

src/containers/ChallengeEditor/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ class ChallengeEditor extends Component {
231231
partiallyUpdateChallengeDetails,
232232
createChallenge,
233233
replaceResourceInRole,
234-
deleteChallenge
234+
deleteChallenge,
235+
loggedInUser
235236
// members
236237
} = this.props
237238
const {
@@ -338,6 +339,7 @@ class ChallengeEditor extends Component {
338339
replaceResourceInRole={replaceResourceInRole}
339340
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
340341
deleteChallenge={deleteChallenge}
342+
loggedInUser={loggedInUser}
341343
/>
342344
))
343345
} />

src/services/challenges.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ export async function fetchGroups (filters) {
6565
return _.get(response, 'data', [])
6666
}
6767

68+
/**
69+
* Api request for fetching Group Detail
70+
*
71+
* @param groupId
72+
* @returns {Promise<*>}
73+
*/
74+
export async function fetchGroupDetail (id) {
75+
const response = await axiosInstance.get(`${GROUPS_API_URL}/${id}`)
76+
return _.get(response, 'data', [])
77+
}
78+
6879
/**
6980
* Api request for fetching timeline templates
7081
* @returns {Promise<*>}

0 commit comments

Comments
 (0)