Skip to content

Commit ab260d4

Browse files
committed
PM-839 - disable "launch new" challenge button when project is not active
1 parent 5f7bbad commit ab260d4

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

src/components/ChallengesComponent/ProjectStatus/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import cn from 'classnames'
4-
import { PROJECT_STATUS } from '../../../config/constants'
4+
import { PROJECT_STATUSES } from '../../../config/constants'
55
import styles from './ProjectStatus.module.scss'
66

77
const ProjectStatus = ({ status }) => {
88
return (
99
<div className={cn(styles.container, styles[status])}>
10-
<div>{PROJECT_STATUS.find(item => item.value === status).label}</div>
10+
<div>{PROJECT_STATUSES.find(item => item.value === status).label}</div>
1111
</div>
1212
)
1313
}

src/components/ChallengesComponent/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
77
import { Helmet } from 'react-helmet'
88
import { Link } from 'react-router-dom'
99
import ProjectStatus from './ProjectStatus'
10-
import { PROJECT_ROLES, TYPEFORM_URL } from '../../config/constants'
10+
import { PROJECT_ROLES, TYPEFORM_URL, PROJECT_STATUS } from '../../config/constants'
1111
import { PrimaryButton, OutlineButton } from '../Buttons'
1212
import ChallengeList from './ChallengeList'
1313
import styles from './ChallengesComponent.module.scss'
@@ -101,11 +101,15 @@ const ChallengesComponent = ({
101101
target={'_blank'}
102102
/>
103103
)}
104-
<Link
105-
to={`/projects/${activeProject.id}/challenges/new`}
106-
>
107-
<PrimaryButton text={'Launch New'} type={'info'} />
108-
</Link>
104+
{activeProject.status === PROJECT_STATUS.ACTIVE ? (
105+
<Link
106+
to={`/projects/${activeProject.id}/challenges/new`}
107+
>
108+
<PrimaryButton text={'Launch New'} type={'info'} />
109+
</Link>
110+
) : (
111+
<PrimaryButton text={'Launch New'} type={'info'} disabled />
112+
)}
109113
</div>
110114
) : (
111115
<span />

src/components/ProjectCard/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Link } from 'react-router-dom'
44
import cn from 'classnames'
55
import { find } from 'lodash'
66

7-
import { PROJECT_STATUS } from '../../config/constants'
7+
import { PROJECT_STATUSES } from '../../config/constants'
88

99
import styles from './ProjectCard.module.scss'
1010

@@ -18,7 +18,7 @@ const ProjectCard = ({ projectName, projectStatus, projectId, selected, setActiv
1818
>
1919
<div className={styles.name}>
2020
<span>{projectName}</span>
21-
<span className={styles.status}>{find(PROJECT_STATUS, { value: projectStatus }).label}</span>
21+
<span className={styles.status}>{find(PROJECT_STATUSES, { value: projectStatus }).label}</span>
2222
</div>
2323
</Link>
2424
</div>

src/components/ProjectForm/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { get } from 'lodash'
55
import styles from './ProjectForm.module.scss'
66
import { PrimaryButton } from '../Buttons'
77
import Select from '../Select'
8-
import { PROJECT_STATUS, DEFAULT_NDA_UUID } from '../../config/constants'
8+
import { PROJECT_STATUSES, DEFAULT_NDA_UUID } from '../../config/constants'
99
import GroupsFormField from './GroupsFormField'
1010

1111
const ProjectForm = ({
@@ -30,7 +30,7 @@ const ProjectForm = ({
3030
projectName: isEdit ? projectDetail.name : '',
3131
description: isEdit ? projectDetail.description : '',
3232
status: isEdit
33-
? PROJECT_STATUS.find((item) => item.value === projectDetail.status) ||
33+
? PROJECT_STATUSES.find((item) => item.value === projectDetail.status) ||
3434
null
3535
: null,
3636
projectType: isEdit
@@ -127,7 +127,7 @@ const ProjectForm = ({
127127
rules={{ required: 'Please select a status' }}
128128
render={({ field }) => (
129129
<Select
130-
options={PROJECT_STATUS}
130+
options={PROJECT_STATUSES}
131131
id='status'
132132
{...field}
133133
placeholder='Select Project Status'

src/config/constants.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ export const SPECIAL_CHALLENGE_TAGS = [
408408
/**
409409
* Possible statuses of projects
410410
*/
411-
export const PROJECT_STATUS = [
411+
export const PROJECT_STATUSES = [
412412
{ label: 'Active', value: 'active' },
413413
{ label: 'In Review', value: 'in_review' },
414414
{ label: 'Reviewed', value: 'reviewed' },
@@ -417,6 +417,15 @@ export const PROJECT_STATUS = [
417417
{ label: 'Paused', value: 'paused' }
418418
]
419419

420+
export const PROJECT_STATUS = {
421+
ACTIVE: 'active',
422+
IN_REVIEW: 'in_review',
423+
REVIEWED: 'reviewed',
424+
COMPLETED: 'completed',
425+
CANCELLED: 'cancelled',
426+
PAUSED: 'paused'
427+
}
428+
420429
export const JOB_ROLE_OPTIONS = [
421430
{ value: null, label: 'Select Role' },
422431
{ value: 'designer', label: 'Designer' },

0 commit comments

Comments
 (0)