Skip to content

Moving latest and greatest to production #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/ChallengeEditor/TagsField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from './Tags-Field.module.scss'

const TagsField = ({ challengeTags, challenge, onUpdateMultiSelect, readOnly }) => {
const mapOps = item => ({ label: item.name, value: item.id })
const existingTags = (challenge.tags && challenge.tags.length) ? challenge.tags.join(',') : ''
return (
<>
<div className={styles.row}>
Expand All @@ -15,19 +16,19 @@ const TagsField = ({ challengeTags, challenge, onUpdateMultiSelect, readOnly })
<div className={cn(styles.field, styles.col2)}>
<input type='hidden' />
{readOnly ? (
<span>{(challenge.tags && challenge.tags.length) ? challenge.tags.join(', ') : ''}</span>
<span>{existingTags}</span>
) : (<Select
id='track-select'
multi
options={challengeTags.map(mapOps)}
simpleValue
value={(challenge.tags && challenge.tags.length) ? challenge.tags.join(',') : ''}
value={existingTags}
onChange={(value) => onUpdateMultiSelect(value, 'tags')}
/>)}
</div>
</div>

{ !readOnly && challenge.submitTriggered && !challenge.tags.length && <div className={styles.row}>
{ !readOnly && challenge.submitTriggered && (!challenge.tags || !challenge.tags.length) && <div className={styles.row}>
<div className={cn(styles.field, styles.col1)} />
<div className={cn(styles.field, styles.col2, styles.error)}>
Select at least one tag
Expand Down
30 changes: 20 additions & 10 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ class ChallengeEditor extends Component {
}

// calculate total cost of challenge
this.setState({ challenge: newChallenge })
this.setState({ challenge: newChallenge }, () => {
this.validateChallenge()
})
}

/**
Expand Down Expand Up @@ -331,7 +333,9 @@ class ChallengeEditor extends Component {
newChallenge[field][index][option.key] = option.name
}
}
this.setState({ challenge: newChallenge })
this.setState({ challenge: newChallenge }, () => {
this.validateChallenge()
})
}
}

Expand All @@ -350,7 +354,9 @@ class ChallengeEditor extends Component {
value = value.filter(val => _.values(PRIZE_SETS_TYPE).includes(val.type))
}
newChallenge[field] = value
this.setState({ challenge: newChallenge })
this.setState({ challenge: newChallenge }, () => {
this.validateChallenge()
})
}

/**
Expand Down Expand Up @@ -388,7 +394,9 @@ class ChallengeEditor extends Component {
} else {
_.set(newChallenge, `${field}.${index}.check`, checked)
}
this.setState({ challenge: newChallenge })
this.setState({ challenge: newChallenge }, () => {
this.validateChallenge()
})
}

/**
Expand Down Expand Up @@ -597,7 +605,7 @@ class ChallengeEditor extends Component {
}

isValidChallengePrizes () {
const challengePrizes = this.state.challenge.prizeSets.find(p => p.type === PRIZE_SETS_TYPE.CHALLENGE_PRIZES)
const challengePrizes = _.find(this.state.challenge.prizeSets, p => p.type === PRIZE_SETS_TYPE.CHALLENGE_PRIZES, [])
if (!challengePrizes || !challengePrizes.prizes || challengePrizes.prizes.length === 0) {
return false
}
Expand Down Expand Up @@ -668,7 +676,9 @@ class ChallengeEditor extends Component {
let newChallenge = { ...challenge }
newChallenge[field] = options ? options.split(',') : []

this.setState({ challenge: newChallenge })
this.setState({ challenge: newChallenge }, () => {
this.validateChallenge()
})
}

onUpdatePhase (newValue, property, index) {
Expand Down Expand Up @@ -1179,16 +1189,16 @@ class ChallengeEditor extends Component {
{!isLoading && <LastSavedDisplay timeLastSaved={draftChallenge.data.updated} />}
{!isLoading && (!isActive) && (!isCompleted) && <div className={styles.buttonContainer}>
<div className={styles.button}>
<OutlineButton text={'Save Draft'} type={'success'} onClick={this.createDraftHandler} />
<OutlineButton text={isSaving ? 'Saving...' : 'Save'} type={'success'} onClick={this.onSaveChallenge} />
</div>
<div className={styles.button}>
<PrimaryButton text={'Save Draft'} type={'info'} onClick={this.createDraftHandler} />
</div>
{ isDraft && <div className={styles.button}>
<PrimaryButton text={'Launch as Active'} type={'info'} onClick={this.toggleLaunch} />
</div>}
</div>}
{!isLoading && isActive && <div className={styles.buttonContainer}>
<div className={styles.button}>
<OutlineButton text={isSaving ? 'Saving...' : 'Save'} type={'success'} onClick={this.onSaveChallenge} />
</div>
{isTask && (
<div className={styles.button}>
<PrimaryButton text={'Close Task'} type={'danger'} onClick={this.openCloseTaskConfirmation} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChallengesComponent/ChallengeCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ChallengeCard extends React.Component {
onCancel={reloadChallengeList}
closeText='Close'
okText='View Challenge'
okLink='./view'
okLink={`/projects/${challenge.projectId}/challenges/${challenge.id}/view`}
onClose={this.resetModal}
/>
) }
Expand Down