Skip to content

Commit d120521

Browse files
author
vikasrohit
authored
Merge pull request #947 from topcoder-platform/develop
Prod Update - Disable activate and legacy links on listing page
2 parents ff33cc4 + b8ba616 commit d120521

File tree

7 files changed

+95
-65
lines changed

7 files changed

+95
-65
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"sass-loader": "7.1.0",
9292
"simplemde": "^1.11.2",
9393
"style-loader": "0.23.0",
94-
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1",
94+
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.3",
9595
"terser": "^3.16.1",
9696
"terser-webpack-plugin": "1.1.0",
9797
"topcoder-healthcheck-dropin": "^1.0.3",

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import LegacyLinks from '../../LegacyLinks'
2222
import AssignedMemberField from '../AssignedMember-Field'
2323
import { getResourceRoleByName } from '../../../util/tc'
2424
import Tooltip from '../../Tooltip'
25+
import { MESSAGE } from '../../../config/constants'
2526

2627
const ChallengeView = ({
2728
projectDetail,
@@ -78,7 +79,7 @@ const ChallengeView = ({
7879
{challenge.legacyId ? (
7980
<PrimaryButton text={'Launch'} type={'info'} onClick={onLaunchChallenge} />
8081
) : (
81-
<Tooltip content='Legacy project is not yet created'>
82+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
8283
{/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */}
8384
<PrimaryButton text={'Launch'} type={'disabled'} />
8485
</Tooltip>

src/components/ChallengeEditor/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
DEFAULT_TERM_UUID,
1717
DEFAULT_NDA_UUID,
1818
SUBMITTER_ROLE_UUID,
19-
CREATE_FORUM_TYPE_IDS
19+
CREATE_FORUM_TYPE_IDS,
20+
MESSAGE
2021
} from '../../config/constants'
2122
import { PrimaryButton, OutlineButton } from '../Buttons'
2223
import TrackField from './Track-Field'
@@ -1200,7 +1201,7 @@ class ChallengeEditor extends Component {
12001201
{challenge.legacyId ? (
12011202
<PrimaryButton text={'Launch as Active'} type={'info'} onClick={this.toggleLaunch} />
12021203
) : (
1203-
<Tooltip content='Legacy project is not yet created'>
1204+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
12041205
{/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */}
12051206
<PrimaryButton text={'Launch as Active'} type={'disabled'} />
12061207
</Tooltip>

src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
text-decoration-line: underline;
5050
}
5151

52+
span.link,
53+
span.link:hover,
54+
span.link:visited {
55+
color: $inactive;
56+
cursor: default;
57+
}
58+
5259
&.onlyOne {
5360
justify-content: center;
5461
}
@@ -160,6 +167,13 @@
160167
text-decoration-line: underline;
161168
}
162169

170+
span.link,
171+
span.link:hover,
172+
span.link:visited {
173+
color: $inactive;
174+
cursor: default;
175+
}
176+
163177
&.onlyOne {
164178
justify-content: center;
165179
}
@@ -171,14 +185,19 @@
171185
height: 100%;
172186
justify-content: center;
173187

174-
span {
188+
span.linkDivider {
175189
margin: 0 5px;
176190
}
177191

178192
.linkGroupLeftBottom {
179-
a {
193+
a,
194+
span {
180195
font-size: 12px;
181196
}
197+
198+
span.linkDivider {
199+
font-size: 16px;
200+
}
182201
}
183202
}
184203
}
@@ -227,6 +246,15 @@
227246
align-items: center;
228247
color: $status-green;
229248
}
249+
250+
&.activateButtonDisabled {
251+
border-color: $inactive;
252+
cursor: default;
253+
254+
> span {
255+
color: $inactive;
256+
}
257+
}
230258
}
231259

232260
.icon {

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import ChallengeStatus from '../ChallengeStatus'
1414
import ChallengeTag from '../ChallengeTag'
1515
import styles from './ChallengeCard.module.scss'
1616
import { getFormattedDuration, formatDate } from '../../../util/date'
17-
import { CHALLENGE_STATUS, COMMUNITY_APP_URL, DIRECT_PROJECT_URL, ONLINE_REVIEW_URL } from '../../../config/constants'
17+
import { CHALLENGE_STATUS, COMMUNITY_APP_URL, DIRECT_PROJECT_URL, MESSAGE, ONLINE_REVIEW_URL } from '../../../config/constants'
1818
import { patchChallenge } from '../../../services/challenges'
1919
import ConfirmationModal from '../../Modal/ConfirmationModal'
2020
import AlertModal from '../../Modal/AlertModal'
21+
import Tooltip from '../../Tooltip'
2122

2223
const theme = {
2324
container: styles.modalContainer
@@ -96,68 +97,58 @@ const getPhaseInfo = (c) => {
9697
* @param onUpdateLaunch
9798
* @returns {*}
9899
*/
99-
const hoverComponents = (challenge, onUpdateLaunch, showError) => {
100+
const hoverComponents = (challenge, onUpdateLaunch) => {
100101
const communityAppUrl = `${COMMUNITY_APP_URL}/challenges/${challenge.id}`
101102
const directUrl = `${DIRECT_PROJECT_URL}/contest/detail?projectId=${challenge.legacyId}`
102103
const orUrl = `${ONLINE_REVIEW_URL}/review/actions/ViewProjectDetails?pid=${challenge.legacyId}`
103-
const showLegacyError = () => {
104-
if (showError) {
105-
showError((<span>The legacy processor has not yet given this challenge a legacy ID. Please wait a few minutes or contact <a href='mailto: support@topcoder.com'>support@topcoder.com</a></span>))
106-
}
104+
105+
// NEW projects never have Legacy challenge created, so don't show links and "Activate" button for them at all
106+
if (challenge.status.toUpperCase() === CHALLENGE_STATUS.NEW) {
107+
return null
107108
}
108109

109-
switch (challenge.status.toUpperCase()) {
110-
case CHALLENGE_STATUS.DRAFT:
111-
case CHALLENGE_STATUS.ACTIVE:
112-
default:
113-
return challenge.legacyId ? (
114-
<div className={styles.linkGroup}>
115-
<div className={styles.linkGroupLeft} onClick={() => {
116-
window.location.href = communityAppUrl
117-
}}>
118-
<a className={styles.link} href={communityAppUrl}>View Challenge</a>
119-
<div className={styles.linkGroupLeftBottom}>
120-
<a onClick={(e) => e.stopPropagation()} className={styles.link} href={directUrl} target='_blank'>Direct</a>
121-
<span>|</span>
122-
<a onClick={(e) => e.stopPropagation()} className={styles.link} href={orUrl} target='_blank'>OR</a>
123-
</div>
124-
</div>
125-
{
126-
challenge.status === 'Draft' && (
127-
<button className={styles.activateButton} onClick={() => onUpdateLaunch()}>
128-
<span>Activate</span>
129-
</button>
130-
)
131-
}
110+
return challenge.legacyId ? (
111+
<div className={styles.linkGroup}>
112+
<div className={styles.linkGroupLeft}>
113+
<a className={styles.link} href={communityAppUrl} target='_blank'>View Challenge</a>
114+
<div className={styles.linkGroupLeftBottom}>
115+
<a className={styles.link} href={directUrl} target='_blank'>Direct</a>
116+
<span className={styles.linkDivider}>|</span>
117+
<a className={styles.link} href={orUrl} target='_blank'>OR</a>
132118
</div>
133-
) : (
134-
<div className={styles.linkGroup}>
135-
<div className={styles.linkGroupLeft} onClick={() => {
136-
window.location.href = communityAppUrl
137-
}}>
138-
<a className={styles.link} href={communityAppUrl}>View Challenge</a>
139-
<div className={styles.linkGroupLeftBottom}>
140-
<a onClick={(e) => {
141-
e.stopPropagation()
142-
showLegacyError()
143-
}} className={styles.link}>Direct</a>
144-
<span>|</span>
145-
<a onClick={(e) => {
146-
e.stopPropagation()
147-
showLegacyError()
148-
}} className={styles.link}>OR</a>
149-
</div>
150-
</div>
151-
{
152-
challenge.status === 'Draft' && (
153-
<button className={styles.activateButton} onClick={() => onUpdateLaunch()}>
154-
<span>Activate</span>
155-
</button>
156-
)
157-
}
119+
</div>
120+
{challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT && (
121+
<button className={styles.activateButton} onClick={() => onUpdateLaunch()}>
122+
<span>Activate</span>
123+
</button>
124+
)}
125+
</div>
126+
) : (
127+
<div className={styles.linkGroup}>
128+
<div className={styles.linkGroupLeft}>
129+
<a className={styles.link} href={communityAppUrl}>View Challenge</a>
130+
<div className={styles.linkGroupLeftBottom}>
131+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
132+
<span className={styles.link}>Direct</span>
133+
</Tooltip>
134+
<span className={styles.linkDivider}>|</span>
135+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
136+
<span className={styles.link}>OR</span>
137+
</Tooltip>
158138
</div>
159-
)
160-
}
139+
</div>
140+
{
141+
challenge.status === 'Draft' && (
142+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
143+
{/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */}
144+
<button className={cn(styles.activateButton, styles.activateButtonDisabled)}>
145+
<span>Activate</span>
146+
</button>
147+
</Tooltip>
148+
)
149+
}
150+
</div>
151+
)
161152
}
162153

163154
const renderStatus = (status) => {

src/components/LegacyLinks/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React, { useCallback } from 'react'
55
import PropTypes from 'prop-types'
66
import styles from './LegacyLinks.module.scss'
7-
import { DIRECT_PROJECT_URL, ONLINE_REVIEW_URL } from '../../config/constants'
7+
import { DIRECT_PROJECT_URL, MESSAGE, ONLINE_REVIEW_URL } from '../../config/constants'
88
import PrimaryButton from '../Buttons/PrimaryButton'
99
import Tooltip from '../Tooltip'
1010

@@ -28,11 +28,11 @@ const LegacyLinks = ({ challenge }) => {
2828
</>
2929
) : (
3030
<>
31-
<Tooltip content='Legacy project is not yet created'>
31+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
3232
{/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */}
3333
<PrimaryButton text={'Direct'} type={'disabled'} />
3434
</Tooltip>
35-
<Tooltip content='Legacy project is not yet created'>
35+
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
3636
{/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */}
3737
<PrimaryButton text={'Online Review'} type={'disabled'} />
3838
</Tooltip>

src/config/constants.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,12 @@ export const GROUPS_DROPDOWN_PER_PAGE = 1000000 // make sure we are getting all
176176
* The list of challenge types which can have multiple prizes
177177
*/
178178
export const CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES = ['Challenge']
179+
180+
/**
181+
* All the repeating messages.
182+
*
183+
* To have the same wording across the app.
184+
*/
185+
export const MESSAGE = {
186+
NO_LEGACY_CHALLENGE: 'Legacy challenge is not yet created'
187+
}

0 commit comments

Comments
 (0)