@@ -12,7 +12,13 @@ import {
1212 JustifyContent ,
1313 Panel ,
1414} from '@influxdata/clockface'
15- import React , { FC } from 'react'
15+ import React , { Component , FC } from 'react'
16+ import { connect } from 'react-redux'
17+ import { getOrg } from 'src/organizations/selectors'
18+
19+ import { withRouter , RouteComponentProps } from 'react-router-dom'
20+
21+ import { AppState , Organization } from 'src/types'
1622
1723// Utils
1824import { isFlagEnabled } from 'src/shared/utils/featureFlag'
@@ -21,6 +27,12 @@ import {isFlagEnabled} from 'src/shared/utils/featureFlag'
2127import LogoWithCubo from 'src/checkout/LogoWithCubo'
2228import GetInfluxButton from 'src/shared/components/GetInfluxButton'
2329
30+ interface StateProps {
31+ org : Organization
32+ }
33+
34+ type Props = RouteComponentProps & StateProps
35+
2436const NotFoundNew : FC = ( ) => (
2537 < AppWrapper type = "funnel" className = "page-not-found" >
2638 < FunnelPage enableGraphic = { true } className = "page-not-found-funnel" >
@@ -129,12 +141,40 @@ const NotFoundOld: FC = () => (
129141 </ div >
130142)
131143
132- const NotFound : FC = ( ) => {
133- if ( isFlagEnabled ( 'newNotFoundPage' ) ) {
134- return < NotFoundNew />
144+ class NotFound extends Component < Props > {
145+ componentDidMount ( ) {
146+ if ( isFlagEnabled ( 'deepLinking' ) ) {
147+ const deepLinkingMap = {
148+ '/me/alerts' : `/orgs/${ this . props . org . id } /alerting` ,
149+ '/me/billing' : `/orgs/${ this . props . org . id } /billing` ,
150+ '/me/dashboards' : `/orgs/${ this . props . org . id } /dashboards-list` ,
151+ '/me/notebooks' : `/orgs/${ this . props . org . id } /notebooks` ,
152+ '/me/tasks' : `/orgs/${ this . props . org . id } /tasks` ,
153+ '/me/usage' : `/orgs/${ this . props . org . id } /usage` ,
154+ }
155+
156+ if ( deepLinkingMap . hasOwnProperty ( this . props . location . pathname ) ) {
157+ this . props . history . replace ( deepLinkingMap [ this . props . location . pathname ] )
158+ return
159+ }
160+ }
135161 }
136162
137- return < NotFoundOld />
163+ render ( ) {
164+ if ( isFlagEnabled ( 'newNotFoundPage' ) ) {
165+ return < NotFoundNew />
166+ }
167+
168+ return < NotFoundOld />
169+ }
170+ }
171+
172+ const mstp = ( state : AppState ) => {
173+ return {
174+ org : getOrg ( state ) ,
175+ }
138176}
139177
140- export default NotFound
178+ const connector = connect ( mstp )
179+
180+ export default connector ( withRouter ( NotFound ) )
0 commit comments