From 751d392670989d535772a9a7a4ec5e038b36b22c Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Tue, 11 Jul 2023 16:31:05 -0500 Subject: [PATCH 1/3] Redirect old profile requests to new profiles app --- config/default.js | 1 + config/production.js | 1 + src/shared/routes/Profile.jsx | 40 +++++++++++++-------------- src/shared/routes/Topcoder/Routes.jsx | 6 ---- src/shared/routes/index.jsx | 6 ++++ 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/config/default.js b/config/default.js index fa819effcf..9d2d93dfa1 100644 --- a/config/default.js +++ b/config/default.js @@ -476,5 +476,6 @@ module.exports = { }, /* development id - makes surveys have warning about environment */ UNIVERSAL_NAV_URL: '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js', + MEMBER_PROFILE_REDIRECT_URL: 'https://profiles.topcoder-dev.com', SPRIG_ENVIRONMENT_ID: 'bUcousVQ0-yF', }; diff --git a/config/production.js b/config/production.js index 05ec83aee0..cb5cd3cbb0 100644 --- a/config/production.js +++ b/config/production.js @@ -236,6 +236,7 @@ module.exports = { DICE_VERIFY_URL: 'https://accounts-auth0.topcoder.com', /* development id - makes surveys have warning about environment */ UNIVERSAL_NAV_URL: '//uni-nav.topcoder.com/v1/tc-universal-nav.js', + MEMBER_PROFILE_REDIRECT_URL: 'https://profiles.topcoder.com', SPRIG_ENVIRONMENT_ID: 'a-IZBZ6-r7bU', // Specifically for the terms ID that matches the NDA requirement. diff --git a/src/shared/routes/Profile.jsx b/src/shared/routes/Profile.jsx index ee7de0f151..27394c87a9 100644 --- a/src/shared/routes/Profile.jsx +++ b/src/shared/routes/Profile.jsx @@ -1,27 +1,25 @@ /** * The loader of Profile webpack chunks. */ -import path from 'path'; -import React from 'react'; - -import LoadingPagePlaceholder from 'components/LoadingPagePlaceholder'; -import { AppChunk, webpack } from 'topcoder-react-utils'; +import PT from 'prop-types'; +import { config } from 'topcoder-react-utils'; export default function ProfileLoader(props) { - return ( - import(/* webpackChunkName: "profile/chunk" */ 'containers/Profile') - .then(({ default: ProfileContainer }) => ( - - )) - } - renderPlaceholder={() => } - renderServer={() => { - const p = webpack.resolveWeak('containers/Profile'); - const ProfileContainer = webpack.requireWeak(path.resolve(__dirname, p)); - return ; - }} - /> - ); + if (typeof window !== 'undefined') { + const { + match: { + params: { handle }, + }, + } = props; + window.location.replace(`${config.MEMBER_PROFILE_REDIRECT_URL}/${handle}`); // totest + } + return null; } + +ProfileLoader.propTypes = { + match: PT.shape({ + params: PT.shape({ + handle: PT.string, + }), + }).isRequired, +}; diff --git a/src/shared/routes/Topcoder/Routes.jsx b/src/shared/routes/Topcoder/Routes.jsx index 769904af87..707ca1d1d4 100644 --- a/src/shared/routes/Topcoder/Routes.jsx +++ b/src/shared/routes/Topcoder/Routes.jsx @@ -30,7 +30,6 @@ import Dashboard from './Dashboard'; import Notifications from './Notifications'; import Settings from '../Settings'; import HallOfFame from '../HallOfFame'; -import Profile from '../Profile'; import ProfileBadges from '../ProfileBadges'; import Scoreboard from '../tco/scoreboard'; import MemberSearch from '../../containers/MemberSearch'; @@ -85,11 +84,6 @@ export default function Topcoder() { exact path="/challenges/:challengeId([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}|\d{5,8})/submit" /> - { config.GAMIFICATION.ENABLE_BADGE_UI && ( + From f707bfa8ee712589ee9837d67f4f3231d3b486ba Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Thu, 20 Jul 2023 16:08:47 +1000 Subject: [PATCH 2/3] Show the security reminder to all users on all challenges, not just NDA challenges https://topcoder.atlassian.net/browse/PROD-4255 --- config/custom-environment-variables.js | 1 - config/default.js | 3 --- config/development.js | 3 --- config/production.js | 3 --- config/qa.js | 2 -- src/shared/containers/challenge-detail/index.jsx | 11 ++--------- 6 files changed, 2 insertions(+), 21 deletions(-) diff --git a/config/custom-environment-variables.js b/config/custom-environment-variables.js index 04174fec58..7a46f7a078 100644 --- a/config/custom-environment-variables.js +++ b/config/custom-environment-variables.js @@ -11,7 +11,6 @@ module.exports = { }, DISABLE_SERVICE_WORKER: 'DISABLE_SERVICE_WORKER', LOG_ENTRIES_TOKEN: 'LOG_ENTRIES_TOKEN', - TERM_NDA_ID: 'TERM_NDA_ID', MOCK_TERMS_SERVICE: 'MOCK_TERMS_SERVICE', NEWSLETTER_SIGNUP: { diff --git a/config/default.js b/config/default.js index 9d2d93dfa1..724308b1ed 100644 --- a/config/default.js +++ b/config/default.js @@ -69,9 +69,6 @@ module.exports = { * agreement flow. */ MOCK_TERMS_SERVICE: false, - // Specifically for the terms ID that matches the NDA requirement. - TERM_NDA_ID: '', - /* Holds params to signup for different newsletters. */ NEWSLETTER_SIGNUP: { DEFAUL_LIST_ID: '28bfd3c062', diff --git a/config/development.js b/config/development.js index e5bf748a1a..5088a55f80 100644 --- a/config/development.js +++ b/config/development.js @@ -6,7 +6,4 @@ module.exports = { }, PLATFORM_SITE_URL: 'https://platform.topcoder-dev.com', PLATFORMUI_SITE_URL: 'https://platform-ui.topcoder-dev.com', - - // Specifically for the terms ID that matches the NDA requirement. - TERM_NDA_ID: 'e5811a7b-43d1-407a-a064-69e5015b4900', }; diff --git a/config/production.js b/config/production.js index cb5cd3cbb0..d23f59b91b 100644 --- a/config/production.js +++ b/config/production.js @@ -238,7 +238,4 @@ module.exports = { UNIVERSAL_NAV_URL: '//uni-nav.topcoder.com/v1/tc-universal-nav.js', MEMBER_PROFILE_REDIRECT_URL: 'https://profiles.topcoder.com', SPRIG_ENVIRONMENT_ID: 'a-IZBZ6-r7bU', - - // Specifically for the terms ID that matches the NDA requirement. - TERM_NDA_ID: 'c41e90e5-4d0e-4811-bd09-38ff72674490', }; diff --git a/config/qa.js b/config/qa.js index 280621e44a..d709837e5d 100644 --- a/config/qa.js +++ b/config/qa.js @@ -6,6 +6,4 @@ module.exports = { }, PLATFORM_SITE_URL: 'https://platform.topcoder-qa.com', PLATFORMUI_SITE_URL: 'https://platform-ui.topcoder-qa.com', - // Specifically for the terms ID that matches the NDA requirement. - TERM_NDA_ID: 'c41e90e5-4d0e-4811-bd09-38ff72674490', }; diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index 201424022f..daf65f3bb6 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -323,23 +323,16 @@ class ChallengeDetailPageContainer extends React.Component { registerForChallenge() { const { auth, - challengeId, communityId, - registerForChallenge, - openTermsModal, - terms, } = this.props; if (!auth.tokenV3) { const utmSource = communityId || 'community-app-main'; window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(window.location.href)}&utm_source=${utmSource}®Source=challenges`; - } else if (terms && !!_.find(terms, { id: config.TERM_NDA_ID })) { + } else { + // Show security reminder to all registrants this.setState({ showSecurityReminder: true, }); - } else if (_.every(terms, 'agreed')) { - registerForChallenge(auth, challengeId); - } else { - openTermsModal(); } } From 63d6aa15c35ccea53451f7efc285aff47c1015dd Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Tue, 25 Jul 2023 16:33:22 +1000 Subject: [PATCH 3/3] Redirect fix for new profiles and account settings apps --- config/default.js | 1 + config/production.js | 1 + .../components/RedirectExternalUrlPage.jsx | 22 ++++++ src/shared/routes/Profile.jsx | 40 +++++----- src/shared/routes/ProfileRedirect.jsx | 28 +++++++ src/shared/routes/Settings/Router.jsx | 2 - .../routes/Settings/SettingRedirect.jsx | 74 +++++++++++++++++++ src/shared/routes/index.jsx | 10 ++- 8 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 src/shared/components/RedirectExternalUrlPage.jsx create mode 100644 src/shared/routes/ProfileRedirect.jsx create mode 100644 src/shared/routes/Settings/SettingRedirect.jsx diff --git a/config/default.js b/config/default.js index 724308b1ed..fbb2261cab 100644 --- a/config/default.js +++ b/config/default.js @@ -474,5 +474,6 @@ module.exports = { /* development id - makes surveys have warning about environment */ UNIVERSAL_NAV_URL: '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js', MEMBER_PROFILE_REDIRECT_URL: 'https://profiles.topcoder-dev.com', + ACCOUNT_SETTINGS_REDIRECT_URL: 'https://account-settings.topcoder-dev.com', SPRIG_ENVIRONMENT_ID: 'bUcousVQ0-yF', }; diff --git a/config/production.js b/config/production.js index d23f59b91b..2d3a108894 100644 --- a/config/production.js +++ b/config/production.js @@ -238,4 +238,5 @@ module.exports = { UNIVERSAL_NAV_URL: '//uni-nav.topcoder.com/v1/tc-universal-nav.js', MEMBER_PROFILE_REDIRECT_URL: 'https://profiles.topcoder.com', SPRIG_ENVIRONMENT_ID: 'a-IZBZ6-r7bU', + ACCOUNT_SETTINGS_REDIRECT_URL: 'https://account-settings.topcoder.com', }; diff --git a/src/shared/components/RedirectExternalUrlPage.jsx b/src/shared/components/RedirectExternalUrlPage.jsx new file mode 100644 index 0000000000..41b48ff7f5 --- /dev/null +++ b/src/shared/components/RedirectExternalUrlPage.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import PT from 'prop-types'; +import { Helmet } from 'react-helmet'; + +export default function RedirectExternalUrlPage(props) { + const { externalRedirectUrl } = props; + if (typeof window !== 'undefined' && externalRedirectUrl) { + window.location.replace(externalRedirectUrl); + } + if (!externalRedirectUrl) { + return null; + } + return ( + + + + ); +} + +RedirectExternalUrlPage.propTypes = { + externalRedirectUrl: PT.string.isRequired, +}; diff --git a/src/shared/routes/Profile.jsx b/src/shared/routes/Profile.jsx index 27394c87a9..ee7de0f151 100644 --- a/src/shared/routes/Profile.jsx +++ b/src/shared/routes/Profile.jsx @@ -1,25 +1,27 @@ /** * The loader of Profile webpack chunks. */ -import PT from 'prop-types'; -import { config } from 'topcoder-react-utils'; +import path from 'path'; +import React from 'react'; + +import LoadingPagePlaceholder from 'components/LoadingPagePlaceholder'; +import { AppChunk, webpack } from 'topcoder-react-utils'; export default function ProfileLoader(props) { - if (typeof window !== 'undefined') { - const { - match: { - params: { handle }, - }, - } = props; - window.location.replace(`${config.MEMBER_PROFILE_REDIRECT_URL}/${handle}`); // totest - } - return null; + return ( + import(/* webpackChunkName: "profile/chunk" */ 'containers/Profile') + .then(({ default: ProfileContainer }) => ( + + )) + } + renderPlaceholder={() => } + renderServer={() => { + const p = webpack.resolveWeak('containers/Profile'); + const ProfileContainer = webpack.requireWeak(path.resolve(__dirname, p)); + return ; + }} + /> + ); } - -ProfileLoader.propTypes = { - match: PT.shape({ - params: PT.shape({ - handle: PT.string, - }), - }).isRequired, -}; diff --git a/src/shared/routes/ProfileRedirect.jsx b/src/shared/routes/ProfileRedirect.jsx new file mode 100644 index 0000000000..f1c923e121 --- /dev/null +++ b/src/shared/routes/ProfileRedirect.jsx @@ -0,0 +1,28 @@ +/** + * The loader of Profile webpack chunks. + */ +import React from 'react'; +import PT from 'prop-types'; +import { config } from 'topcoder-react-utils'; +import RedirectExternalUrlPage from '../components/RedirectExternalUrlPage'; + +export default function ProfileRedirect(props) { + const { + match: { + params: { handle }, + }, + } = props; + return ( + + ); +} + +ProfileRedirect.propTypes = { + match: PT.shape({ + params: PT.shape({ + handle: PT.string, + }), + }).isRequired, +}; diff --git a/src/shared/routes/Settings/Router.jsx b/src/shared/routes/Settings/Router.jsx index 90e394edd6..41a3cc6859 100644 --- a/src/shared/routes/Settings/Router.jsx +++ b/src/shared/routes/Settings/Router.jsx @@ -6,7 +6,6 @@ import React from 'react'; import PT from 'prop-types'; import { Route, Switch } from 'react-router-dom'; -import Settings from 'containers/Settings'; import Success from 'components/Settings/Account/MyAccount/EmailVerifiResult/Success'; import Failed from 'components/Settings/Account/MyAccount/EmailVerifiResult/Failed'; import AlmostDone from 'components/Settings/Account/MyAccount/EmailVerifiResult/AlmostDone'; @@ -16,7 +15,6 @@ import Error404 from 'components/Error404'; export default function Router({ base }) { return ( - diff --git a/src/shared/routes/Settings/SettingRedirect.jsx b/src/shared/routes/Settings/SettingRedirect.jsx new file mode 100644 index 0000000000..48e84b9691 --- /dev/null +++ b/src/shared/routes/Settings/SettingRedirect.jsx @@ -0,0 +1,74 @@ +/** + * The loader of Profile webpack chunks. + */ +import React from 'react'; +import PT from 'prop-types'; +import _ from 'lodash'; +import { config } from 'topcoder-react-utils'; +import { connect } from 'react-redux'; +import { goToLogin } from 'utils/tc'; +import { isTokenExpired } from '@topcoder-platform/tc-auth-lib'; +import RedirectExternalUrlPage from '../../components/RedirectExternalUrlPage'; + +function SettingRedirect(props) { + const { + match: { + params: { settingsTab }, + }, + authenticating, + tokenV3, + handle, + } = props; + let externalUrl = ''; + if (settingsTab === 'profile' && handle) { + externalUrl = `${config.MEMBER_PROFILE_REDIRECT_URL}/${handle}`; + } else if (settingsTab === 'skills' && handle) { + externalUrl = `${config.MEMBER_PROFILE_REDIRECT_URL}/${handle}/?edit-mode=skills`; + } else if (settingsTab === 'tracks') { + externalUrl = `${config.ACCOUNT_SETTINGS_REDIRECT_URL}/#tcandyou`; + } else if (settingsTab === 'tools') { + externalUrl = `${config.ACCOUNT_SETTINGS_REDIRECT_URL}/#tools`; + } else if (settingsTab === 'account') { + externalUrl = `${config.ACCOUNT_SETTINGS_REDIRECT_URL}/#account`; + } else if (settingsTab === 'preferences') { + externalUrl = `${config.ACCOUNT_SETTINGS_REDIRECT_URL}/#preferences`; + } else if (settingsTab === 'payment') { + externalUrl = `${config.ACCOUNT_SETTINGS_REDIRECT_URL}/#payment`; + } + + if (!authenticating && !externalUrl) { + // Check auth token, go to login page if invalid + if (!tokenV3 || isTokenExpired(tokenV3)) { + goToLogin('community-app-main'); + return null; + } + } + + return ; +} + +SettingRedirect.defaultProps = { + handle: '', + tokenV3: '', +}; + +SettingRedirect.propTypes = { + match: PT.shape({ + params: PT.shape({ + settingsTab: PT.string, + }), + }).isRequired, + authenticating: PT.bool.isRequired, + handle: PT.string, + tokenV3: PT.string, +}; + +function mapStateToProps(state) { + return { + authenticating: state.auth.authenticating, + handle: _.get(state.auth, 'user.handle'), + tokenV3: state.auth.tokenV3, + }; +} + +export default connect(mapStateToProps)(SettingRedirect); diff --git a/src/shared/routes/index.jsx b/src/shared/routes/index.jsx index dff96dc401..d5a831c24a 100644 --- a/src/shared/routes/index.jsx +++ b/src/shared/routes/index.jsx @@ -29,7 +29,8 @@ import TrackHomePages from './TrackHomePages'; import TimelineWall from './TimelineWall'; import PolicyPages from './PolicyPages'; import GigsPages from './GigsPages'; -import Profile from './Profile'; +import ProfileRedirect from './ProfileRedirect'; +import SettingRedirect from './Settings/SettingRedirect'; import './Topcoder/styles.scss'; @@ -163,7 +164,12 @@ function Routes({ communityId }) { path={config.START_PAGE_PATH} /> +