Skip to content

Commit

Permalink
PORTALS-2836: redirect the ELITE program page to the ELITE portal
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Oct 27, 2023
1 parent 2e1c9c1 commit 6a6e016
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/portals/src/configurations/adknowledgeportal/routesConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ const routes: GenericRoute[] = [
},
],
},
{
// PORTALS-2836: redirect /Explore/Programs/DetailsPage?Program=ELITE to the ELITE portal
exact: true,
path: 'Explore/Programs/DetailsPage',
hideRouteFromNavbar: true,
synapseConfigArray: [
{
name: 'RedirectToURL',
props: {
toURL: 'https://eliteportal.synapse.org/',
search: 'Program=ELITE',
},
},
],
},
{
path: 'Explore',
routes: [
Expand Down
23 changes: 23 additions & 0 deletions apps/portals/src/portal-components/RedirectToURL.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useLocation } from 'react-router-dom'

export type RedirectToURLProps = {
toURL: string
search?: string
}

/**
* Allows us to use react-router's Redirect as a portal component without losing the query params.
* @param props
* @returns
*/
export default function RedirectToURL(props: RedirectToURLProps) {
const { search: currentSearch } = useLocation()

const { toURL, search } = props
const isSearchMatch =
search == undefined ? true : `?${search}` == currentSearch

if (isSearchMatch) {
window.location.replace(toURL)
}
}
2 changes: 2 additions & 0 deletions apps/portals/src/portal-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import StatusLineChart from './crc-researcher/StatusLineChart'
import SurveysCompletedPlots from './crc-researcher/SurveysCompletedPlots'
import Image from './Image'
import RedirectWithQuery from './RedirectWithQuery'
import RedirectToURL from './RedirectToURL'
import { Redirect } from 'react-router-dom'
import Header from './Header'
import ChallengeParticipantGoogleMap from './challengeportal/ChallengeParticipantGoogleMap'
Expand All @@ -34,6 +35,7 @@ const PortalComponents = {
StatusLineChart,
SurveysCompletedPlots,
Image,
RedirectToURL,
RedirectWithQuery,
Redirect,
BrowseToolsPage,
Expand Down
7 changes: 7 additions & 0 deletions apps/portals/src/types/portal-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ToggleSynapseObjectsProps } from '../portal-components/ToggleSynapseObj
import { CSSProperties } from 'react'
import { TabbedSynapseObjectsProps } from 'portal-components/TabbedSynapseObjects'
import { ChallengeSubmissionWrapperProps } from 'portal-components/challengeportal/ChallengeSubmissionWrapper'
import { RedirectToURLProps } from 'portal-components/RedirectToURL'

// For styling the header on the home page -- the main title and the summary text
export type HomePageHeaderConfig = {
Expand Down Expand Up @@ -292,6 +293,11 @@ type RedirectWithQuery = {
props: RedirectProps
}

type RedirectToURL = {
name: 'RedirectToURL'
props: RedirectToURLProps
}

type Redirect = {
name: 'Redirect'
props: RedirectProps
Expand All @@ -303,6 +309,7 @@ type Header = {
}

export type SynapseConfig = (
| RedirectToURL
| RedirectWithQuery
| Redirect
| RouteControl
Expand Down

0 comments on commit 6a6e016

Please sign in to comment.