-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6899 from topcoder-platform/develop
Prod deploy - Redirects for new apps and show reminder for all challenges
- Loading branch information
Showing
12 changed files
with
142 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Helmet> | ||
<meta httpEquiv="Refresh" content={`0; url='${externalRedirectUrl}'`} /> | ||
</Helmet> | ||
); | ||
} | ||
|
||
RedirectExternalUrlPage.propTypes = { | ||
externalRedirectUrl: PT.string.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<RedirectExternalUrlPage | ||
externalRedirectUrl={handle ? `${config.MEMBER_PROFILE_REDIRECT_URL}/${handle}` : null} | ||
/> | ||
); | ||
} | ||
|
||
ProfileRedirect.propTypes = { | ||
match: PT.shape({ | ||
params: PT.shape({ | ||
handle: PT.string, | ||
}), | ||
}).isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <RedirectExternalUrlPage externalRedirectUrl={externalUrl} />; | ||
} | ||
|
||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters