From 03578201eaf8bda3beb6f2d4bc1bcbaddc5bceb5 Mon Sep 17 00:00:00 2001 From: maxceem Date: Tue, 8 Dec 2020 17:33:41 +0200 Subject: [PATCH] fix: disable on the listing page without legacy ref issue #943 --- .../ChallengeEditor/ChallengeView/index.js | 3 +- src/components/ChallengeEditor/index.js | 5 +- .../ChallengeCard/ChallengeCard.module.scss | 32 +++++- .../ChallengeCard/index.js | 103 ++++++++---------- src/components/LegacyLinks/index.js | 6 +- src/config/constants.js | 9 ++ 6 files changed, 94 insertions(+), 64 deletions(-) diff --git a/src/components/ChallengeEditor/ChallengeView/index.js b/src/components/ChallengeEditor/ChallengeView/index.js index e4b18b52..a7ef66f0 100644 --- a/src/components/ChallengeEditor/ChallengeView/index.js +++ b/src/components/ChallengeEditor/ChallengeView/index.js @@ -22,6 +22,7 @@ import LegacyLinks from '../../LegacyLinks' import AssignedMemberField from '../AssignedMember-Field' import { getResourceRoleByName } from '../../../util/tc' import Tooltip from '../../Tooltip' +import { MESSAGE } from '../../../config/constants' const ChallengeView = ({ projectDetail, @@ -78,7 +79,7 @@ const ChallengeView = ({ {challenge.legacyId ? ( ) : ( - + {/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */} diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 907e616e..adedeeda 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -16,7 +16,8 @@ import { DEFAULT_TERM_UUID, DEFAULT_NDA_UUID, SUBMITTER_ROLE_UUID, - CREATE_FORUM_TYPE_IDS + CREATE_FORUM_TYPE_IDS, + MESSAGE } from '../../config/constants' import { PrimaryButton, OutlineButton } from '../Buttons' import TrackField from './Track-Field' @@ -1200,7 +1201,7 @@ class ChallengeEditor extends Component { {challenge.legacyId ? ( ) : ( - + {/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */} diff --git a/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss b/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss index 5613eaa9..bac62146 100644 --- a/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss +++ b/src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss @@ -49,6 +49,13 @@ text-decoration-line: underline; } + span.link, + span.link:hover, + span.link:visited { + color: $inactive; + cursor: default; + } + &.onlyOne { justify-content: center; } @@ -160,6 +167,13 @@ text-decoration-line: underline; } + span.link, + span.link:hover, + span.link:visited { + color: $inactive; + cursor: default; + } + &.onlyOne { justify-content: center; } @@ -171,14 +185,19 @@ height: 100%; justify-content: center; - span { + span.linkDivider { margin: 0 5px; } .linkGroupLeftBottom { - a { + a, + span { font-size: 12px; } + + span.linkDivider { + font-size: 16px; + } } } } @@ -227,6 +246,15 @@ align-items: center; color: $status-green; } + + &.activateButtonDisabled { + border-color: $inactive; + cursor: default; + + > span { + color: $inactive; + } + } } .icon { diff --git a/src/components/ChallengesComponent/ChallengeCard/index.js b/src/components/ChallengesComponent/ChallengeCard/index.js index d25b6564..e97b7b6b 100644 --- a/src/components/ChallengesComponent/ChallengeCard/index.js +++ b/src/components/ChallengesComponent/ChallengeCard/index.js @@ -14,10 +14,11 @@ import ChallengeStatus from '../ChallengeStatus' import ChallengeTag from '../ChallengeTag' import styles from './ChallengeCard.module.scss' import { getFormattedDuration, formatDate } from '../../../util/date' -import { CHALLENGE_STATUS, COMMUNITY_APP_URL, DIRECT_PROJECT_URL, ONLINE_REVIEW_URL } from '../../../config/constants' +import { CHALLENGE_STATUS, COMMUNITY_APP_URL, DIRECT_PROJECT_URL, MESSAGE, ONLINE_REVIEW_URL } from '../../../config/constants' import { patchChallenge } from '../../../services/challenges' import ConfirmationModal from '../../Modal/ConfirmationModal' import AlertModal from '../../Modal/AlertModal' +import Tooltip from '../../Tooltip' const theme = { container: styles.modalContainer @@ -96,68 +97,58 @@ const getPhaseInfo = (c) => { * @param onUpdateLaunch * @returns {*} */ -const hoverComponents = (challenge, onUpdateLaunch, showError) => { +const hoverComponents = (challenge, onUpdateLaunch) => { const communityAppUrl = `${COMMUNITY_APP_URL}/challenges/${challenge.id}` const directUrl = `${DIRECT_PROJECT_URL}/contest/detail?projectId=${challenge.legacyId}` const orUrl = `${ONLINE_REVIEW_URL}/review/actions/ViewProjectDetails?pid=${challenge.legacyId}` - const showLegacyError = () => { - if (showError) { - showError((The legacy processor has not yet given this challenge a legacy ID. Please wait a few minutes or contact support@topcoder.com)) - } + + // NEW projects never have Legacy challenge created, so don't show links and "Activate" button for them at all + if (challenge.status.toUpperCase() === CHALLENGE_STATUS.NEW) { + return null } - switch (challenge.status.toUpperCase()) { - case CHALLENGE_STATUS.DRAFT: - case CHALLENGE_STATUS.ACTIVE: - default: - return challenge.legacyId ? ( -
- - { - challenge.status === 'Draft' && ( - - ) - } + return challenge.legacyId ? ( +
+
+ View Challenge +
+ Direct + | + OR
- ) : ( -
- - { - challenge.status === 'Draft' && ( - - ) - } +
+ {challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT && ( + + )} +
+ ) : ( +
+
+ View Challenge +
+ + Direct + + | + + OR +
- ) - } +
+ { + challenge.status === 'Draft' && ( + + {/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */} + + + ) + } +
+ ) } const renderStatus = (status) => { diff --git a/src/components/LegacyLinks/index.js b/src/components/LegacyLinks/index.js index d8c5f889..cf7a8c94 100644 --- a/src/components/LegacyLinks/index.js +++ b/src/components/LegacyLinks/index.js @@ -4,7 +4,7 @@ import React, { useCallback } from 'react' import PropTypes from 'prop-types' import styles from './LegacyLinks.module.scss' -import { DIRECT_PROJECT_URL, ONLINE_REVIEW_URL } from '../../config/constants' +import { DIRECT_PROJECT_URL, MESSAGE, ONLINE_REVIEW_URL } from '../../config/constants' import PrimaryButton from '../Buttons/PrimaryButton' import Tooltip from '../Tooltip' @@ -28,11 +28,11 @@ const LegacyLinks = ({ challenge }) => { ) : ( <> - + {/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */} - + {/* Don't disable button for real inside tooltip, otherwise mouseEnter/Leave events work not good */} diff --git a/src/config/constants.js b/src/config/constants.js index 344e91fa..c297d61c 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -176,3 +176,12 @@ export const GROUPS_DROPDOWN_PER_PAGE = 1000000 // make sure we are getting all * The list of challenge types which can have multiple prizes */ export const CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES = ['Challenge'] + +/** + * All the repeating messages. + * + * To have the same wording across the app. + */ +export const MESSAGE = { + NO_LEGACY_CHALLENGE: 'Legacy challenge is not yet created' +}