Skip to content

Add an option to select a timeline template #1072

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 10 commits into from
Mar 11, 2021
Prev Previous commit
Next Next commit
Add ability to view the timeline template on view mode
  • Loading branch information
ThomasKranitsas committed Mar 3, 2021
commit 056f08d27b59b5acc3b34f914e22051a1c455f9f
8 changes: 8 additions & 0 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { isBetaMode } from '../../../util/cookie'
import { loadGroupDetails } from '../../../actions/challenges'
import Tooltip from '../../Tooltip'
import { MESSAGE, REVIEW_TYPES } from '../../../config/constants'
import TimelineTemplateField from '../TimelineTemplate-Field'

const ChallengeView = ({
projectDetail,
Expand Down Expand Up @@ -202,6 +203,13 @@ const ChallengeView = ({
{isBetaMode() && (
<UseSchedulingAPIField challenge={challenge} readOnly />
)}
<TimelineTemplateField
challengeTimelines={metadata.challengeTimelines}
timelineTemplates={metadata.timelineTemplates}
challenge={challenge}
onUpdateSelect={() => {}}
readOnly
/>
</>
)}
{
Expand Down
10 changes: 6 additions & 4 deletions src/components/ChallengeEditor/TimelineTemplate-Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class TimelineTemplateField extends Component {
<>
<div className={styles.row}>
<div className={cn(styles.field, styles.col1)}>
<label htmlFor='type'>Timeline Template <span>*</span> :</label>
<label htmlFor='type'>Timeline Template {!this.props.readOnly && <span>*</span>} :</label>
</div>
<div className={cn(styles.field, styles.col2, { [styles.disabled]: this.state.validOptions.length === 0 })}>
<Select
Expand All @@ -90,7 +90,7 @@ class TimelineTemplateField extends Component {
placeholder='Timeline Template'
isClearable={false}
onChange={(e) => this.props.onUpdateSelect(e.value, false, 'timelineTemplateId')}
isDisabled={this.state.validOptions.length === 0}
isDisabled={this.state.validOptions.length === 0 || this.props.readOnly}
/>
</div>
</div>
Expand All @@ -107,14 +107,16 @@ class TimelineTemplateField extends Component {

TimelineTemplateField.defaultProps = {
challengeTimelines: [],
timelineTemplates: []
timelineTemplates: [],
readOnly: false
}

TimelineTemplateField.propTypes = {
challengeTimelines: PropTypes.arrayOf(PropTypes.shape()).isRequired,
timelineTemplates: PropTypes.arrayOf(PropTypes.shape()).isRequired,
challenge: PropTypes.shape().isRequired,
onUpdateSelect: PropTypes.func.isRequired
onUpdateSelect: PropTypes.func.isRequired,
readOnly: PropTypes.bool
}

export default TimelineTemplateField