Skip to content

Commit 1a66130

Browse files
committed
Merge branch 'develop' into issue-778
2 parents 8881e52 + a6fca01 commit 1a66130

File tree

10 files changed

+108
-160
lines changed

10 files changed

+108
-160
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Expected behavior
2+
Describe.
3+
4+
### Actual behavior
5+
Describe.
6+
7+
### Steps to reproduce the problem
8+
- TBD.
9+
- TBD.
10+
- TBD.
11+
12+
### Screenshot/screencast
13+
Attach or link a resource.
14+
15+
--
16+
17+
#### Environment
18+
- OS:
19+
- Browser (w/version):
20+
- User role (client, copilot or manager):
21+
- Account used:

.github/ISSUE_TEMPLATE/may-7-bug-hunt-functionality-bug.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/may-7-bug-hunt-security-bug.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/may-7-bug-hunt-suggestion.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/may-7-bug-hunt-user-interface-bug.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/actions/challenges.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ export function replaceResourceInRole (challengeId, roleId, newMember, oldMember
478478
}
479479
}
480480
}
481-
await dispatch(createResource(challengeId, roleId, newMember))
481+
if (newMember) {
482+
await dispatch(createResource(challengeId, roleId, newMember))
483+
}
482484
}
483485
}

src/components/ChallengeEditor/ChallengeEditor.module.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,19 @@
403403
}
404404
}
405405

406+
ul.linkList {
407+
display: inline;
408+
margin: 0;
409+
padding: 0;
410+
411+
> li {
412+
display: inline;
413+
list-style: none;
414+
margin: 0;
415+
padding: 0;
416+
}
417+
418+
> li + li:before {
419+
content:',\0000a0'; /* Non-breaking space */
420+
}
421+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class TextEditorField extends Component {
5252
readOnly={readOnly}
5353
/>
5454
</div>)}
55+
{challenge.submitTriggered && !challenge.description && (
56+
<div className={styles.error}>Public Specification is required</div>
57+
)}
5558
{!readOnly && shouldShowPrivateDescription && !showShowPrivateDescriptionField && (<div className={styles.button} onClick={this.addNewPrivateDescription}>
5659
<PrimaryButton text={'Add private specification'} type={'info'} />
5760
</div>)}
@@ -73,9 +76,6 @@ class TextEditorField extends Component {
7376
/>
7477
</div>
7578
)}
76-
{challenge.submitTriggered && !challenge.description && (
77-
<div className={styles.error}>Public Specification is required</div>
78-
)}
7979
<TagsField
8080
challengeTags={challengeTagsFiltered}
8181
challenge={challenge}

src/components/ChallengeEditor/index.js

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
DEFAULT_NDA_UUID,
1818
SUBMITTER_ROLE_UUID,
1919
CREATE_FORUM_TYPE_IDS,
20-
MESSAGE
20+
MESSAGE,
21+
COMMUNITY_APP_URL
2122
} from '../../config/constants'
2223
import { PrimaryButton, OutlineButton } from '../Buttons'
2324
import TrackField from './Track-Field'
@@ -934,35 +935,67 @@ class ChallengeEditor extends Component {
934935
async updateAllChallengeInfo (status, cb = () => {}) {
935936
const { updateChallengeDetails, assignedMemberDetails: oldAssignedMember } = this.props
936937
if (this.state.isSaving) return
937-
this.setState({ isSaving: true })
938-
const challenge = this.collectChallengeData(status)
939-
let newChallenge = _.cloneDeep(this.state.challenge)
940-
newChallenge.status = status
941-
try {
942-
const challengeId = this.getCurrentChallengeId()
943-
const action = await updateChallengeDetails(challengeId, challenge)
944-
const { copilot: previousCopilot, reviewer: previousReviewer } = this.state.draftChallenge.data
945-
const { challenge: { copilot, reviewer }, assignedMemberDetails: assignedMember } = this.state
946-
if (copilot) await this.updateResource(challengeId, 'Copilot', copilot, previousCopilot)
947-
if (reviewer) await this.updateResource(challengeId, 'Reviewer', reviewer, previousReviewer)
948-
const oldMemberHandle = _.get(oldAssignedMember, 'handle')
949-
// assigned member has been updated
950-
if (assignedMember && assignedMember.handle !== oldMemberHandle) {
951-
await this.updateResource(challengeId, 'Submitter', assignedMember.handle, oldMemberHandle)
938+
this.setState({ isSaving: true }, async () => {
939+
const challenge = this.collectChallengeData(status)
940+
let newChallenge = _.cloneDeep(this.state.challenge)
941+
newChallenge.status = status
942+
try {
943+
const challengeId = this.getCurrentChallengeId()
944+
// state can have updated assigned member (in cases where user changes assignments without refreshing the page)
945+
const { challenge: { copilot, reviewer }, assignedMemberDetails: assignedMember } = this.state
946+
const oldMemberHandle = _.get(oldAssignedMember, 'handle')
947+
const assignedMemberHandle = _.get(assignedMember, 'handle')
948+
// assigned member has been updated
949+
if (assignedMemberHandle !== oldMemberHandle) {
950+
await this.updateResource(challengeId, 'Submitter', assignedMemberHandle, oldMemberHandle)
951+
}
952+
const action = await updateChallengeDetails(challengeId, challenge)
953+
const { copilot: previousCopilot, reviewer: previousReviewer } = this.state.draftChallenge.data
954+
if (copilot !== previousCopilot) await this.updateResource(challengeId, 'Copilot', copilot, previousCopilot)
955+
if (reviewer !== previousReviewer) await this.updateResource(challengeId, 'Reviewer', reviewer, previousReviewer)
956+
957+
const draftChallenge = { data: action.challengeDetails }
958+
draftChallenge.data.copilot = copilot
959+
draftChallenge.data.reviewer = reviewer
960+
this.setState({ isLaunch: true,
961+
isConfirm: newChallenge.id,
962+
draftChallenge,
963+
challenge: newChallenge,
964+
isSaving: false }, cb)
965+
} catch (e) {
966+
const error = this.formatResponseError(e) || `Unable to update the challenge to status ${status}`
967+
this.setState({ isSaving: false, error }, cb)
952968
}
969+
})
970+
}
953971

954-
const draftChallenge = { data: action.challengeDetails }
955-
draftChallenge.data.copilot = copilot
956-
draftChallenge.data.reviewer = reviewer
957-
this.setState({ isLaunch: true,
958-
isConfirm: newChallenge.id,
959-
draftChallenge,
960-
challenge: newChallenge,
961-
isSaving: false }, cb)
962-
} catch (e) {
963-
const error = _.get(e, 'response.data.message', `Unable to update the challenge to status ${status}`)
964-
this.setState({ isSaving: false, error }, cb)
972+
/**
973+
* Format the error we might get from some API endpoint.
974+
*
975+
* @param {Error} error error
976+
*
977+
* @returns {import('react').ReactNode}
978+
*/
979+
formatResponseError (error) {
980+
const errorMessage = _.get(error, 'response.data.message')
981+
const errorMetadata = _.get(error, 'response.data.metadata')
982+
983+
if (errorMetadata.missingTerms && errorMetadata.missingTerms.length > 0) {
984+
return <>
985+
{errorMessage}
986+
<ul className={styles.linkList}>{' '}
987+
{errorMetadata.missingTerms.map((terms, index) => {
988+
const termsNumber = errorMetadata.missingTerms.length > 1 ? ` ${index + 1}` : ''
989+
return (
990+
<li key={index}><a href={`${COMMUNITY_APP_URL}/challenges/terms/detail/${terms.termId}`} target='_blank'>link to terms{termsNumber}</a></li>
991+
)
992+
})}
993+
</ul>
994+
</>
965995
}
996+
997+
// if no special error data, just use message
998+
return errorMessage
966999
}
9671000

9681001
async onActiveChallenge () {
@@ -1055,7 +1088,6 @@ class ChallengeEditor extends Component {
10551088
return <div>Error loading challenge</div>
10561089
}
10571090
const isTask = _.get(challenge, 'task.isTask', false)
1058-
console.log(this.props.assignedMemberDetails)
10591091
const { assignedMemberDetails, error } = this.state
10601092
let isActive = false
10611093
let isDraft = false
@@ -1206,7 +1238,7 @@ class ChallengeEditor extends Component {
12061238
<OutlineButton text={isSaving ? 'Saving...' : 'Save'} type={'success'} onClick={this.onSaveChallenge} />
12071239
</div> */}
12081240
<div className={styles.button}>
1209-
<PrimaryButton text={'Save Draft'} type={'info'} onClick={this.createDraftHandler} />
1241+
<PrimaryButton text={isSaving ? 'Saving...' : 'Save Draft'} type={'info'} onClick={this.createDraftHandler} />
12101242
</div>
12111243
{isDraft && (
12121244
<div className={styles.button}>
@@ -1222,9 +1254,9 @@ class ChallengeEditor extends Component {
12221254
)}
12231255
</div>}
12241256
{!isLoading && isActive && <div className={styles.buttonContainer}>
1225-
{/* <div className={styles.button}>
1257+
<div className={styles.button}>
12261258
<OutlineButton text={isSaving ? 'Saving...' : 'Save'} type={'success'} onClick={this.onSaveChallenge} />
1227-
</div> */}
1259+
</div>
12281260
{isTask && (
12291261
<div className={styles.button}>
12301262
<PrimaryButton text={'Close Task'} type={'danger'} onClick={this.openCloseTaskConfirmation} />

src/components/Sidebar/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const Sidebar = ({
1717
<div className={styles.title}>Work Manager</div>
1818
<Link to='/'>
1919
<div className={cn(styles.homeLink, { [styles.active]: !projectId })} onClick={resetSidebarActiveParams}>
20-
Active challenges
20+
All Work
2121
</div>
2222
</Link>
23-
<a href='https://forms.gle/CsaVawSDkdR5E92B8' target='_blank' rel='noopener noreferrer' className='chameleon-feedback'>
23+
<a href='https://github.com/topcoder-platform/work-manager/issues/new' target='_blank' rel='noopener noreferrer' className='chameleon-feedback'>
2424
<div className={cn(styles.homeLink, { [styles.active]: !projectId })}>
2525
Give Application Feedback
2626
</div>

0 commit comments

Comments
 (0)