Skip to content

Commit

Permalink
chore: #1997 add redirect modal for legacy routes - marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined committed Jul 12, 2020
1 parent fd90c8e commit ac87e80
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import routes from '@/constants/routes'
import { history } from '@/core/router'
import React from 'react'
import { Button, Modal } from '@reapit/elements'

export const handleBtnBackToMarketplace = () => {
history.push(routes.APPS)
}

export const handleBtnGoTherNow = () => {
window.open(window.reapit.config.developerPortalUrl, '_self')
}

const HandleLegacyRoutesModal: React.FC<{}> = () => {
return (
<Modal
visible
title="Looking for the developer portal?"
footerItems={
<>
<Button type="button" variant="primary" onClick={handleBtnGoTherNow}>
Go there now
</Button>
<Button type="button" variant="primary" onClick={handleBtnBackToMarketplace}>
Back to Marketplace
</Button>
</>
}
>
The developer portal has permanently moved to https://developers.reapit.com Please remove any bookmarks to this
page and in future visit the developer portal direct. Thankyou.
</Modal>
)
}

export default HandleLegacyRoutesModal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './handle-legacy-routes-modal'
1 change: 1 addition & 0 deletions packages/marketplace/src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Routes = {
HELP: '/help',
LOGIN: '/login',
FOUR_O_FOUR: '/404',
DEVELOPER_ROUTES: '/developer/*',
}

export const developerRoutes = {
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ window.reapit = {
developerEditionDownloadUrl: '',
urlSchemeUrl: '',
apiDocDesktop: '',
developerPortalUrl: '',
},
}

Expand Down
9 changes: 9 additions & 0 deletions packages/marketplace/src/core/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const InstalledApps = React.lazy(() => catchChunkError(() => import('../componen
const Setting = React.lazy(() => catchChunkError(() => import('../components/pages/settings')))
const AppsManagement = React.lazy(() => catchChunkError(() => import('../components/pages/app-management')))
const Help = React.lazy(() => catchChunkError(() => import('../components/pages/help')))
const HandleLegacyRoutes = React.lazy(() => catchChunkError(() => import('../components/pages/handle-legacy-routes')))

const Router = () => {
return (
Expand All @@ -28,6 +29,14 @@ const Router = () => {
<Route path={Routes.LOGIN} exact render={() => <Login />} />
<Route path={Routes.FOUR_O_FOUR} exact render={() => <Info infoType="404" />} />

<PrivateRouteWrapper showMenu={false} path="/client">
<PrivateRoute allow="CLIENT" path="*" component={HandleLegacyRoutes} />
</PrivateRouteWrapper>

<PrivateRouteWrapper showMenu={false} path="/developer">
<PrivateRoute allow="DEVELOPER" path="*" component={HandleLegacyRoutes} />
</PrivateRouteWrapper>

<PrivateRouteWrapper path="/">
<Switch>
<PrivateRoute allow="CLIENT" path={Routes.AUTHENTICATION_LOGIN_TYPE} component={Authentication} />
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Config = {
developerEditionDownloadUrl: string
urlSchemeUrl: string
apiDocDesktop: string
developerPortalUrl: string
}

declare global {
Expand Down

0 comments on commit ac87e80

Please sign in to comment.