Skip to content

Commit 834675f

Browse files
authored
fix: dont show header on 404 page (#6003)
1 parent 442aef4 commit 834675f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import {UserAccountProvider} from 'src/accounts/context/userAccount'
5050
const App: FC = () => {
5151
const {theme, presentationMode} = useContext(AppSettingContext)
5252
const currentPage = useSelector((state: AppState) => state.currentPage)
53+
const shouldShowCloudHeader =
54+
CLOUD && isFlagEnabled('multiOrg') && currentPage !== 'not found'
5355

5456
const appWrapperClass = classnames('', {
5557
'dashboard-light-mode': currentPage === 'dashboard' && theme === 'light',
@@ -123,7 +125,7 @@ const App: FC = () => {
123125
<TreeSidebar />
124126
<Suspense fallback={<PageSpinner />}>
125127
<Page>
126-
{CLOUD && isFlagEnabled('multiOrg') && <GlobalHeader />}
128+
{shouldShowCloudHeader && <GlobalHeader />}
127129
<Switch>
128130
<Route path="/orgs/new" component={CreateOrgOverlay} />
129131
<Route path="/orgs/:orgID" component={SetOrg} />

src/shared/components/NotFound.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ import {
1313
Panel,
1414
} from '@influxdata/clockface'
1515
import React, {useState, FC, useCallback, useEffect, useRef} from 'react'
16-
import {useSelector} from 'react-redux'
16+
import {useDispatch, useSelector} from 'react-redux'
1717
import {useHistory, useLocation} from 'react-router-dom'
1818
import {getOrg} from 'src/organizations/selectors'
1919
import {getOrg as fetchOrg} from 'src/organizations/apis'
2020

21+
// Actions
22+
import {setCurrentPage} from 'src/shared/reducers/currentPage'
23+
2124
// Utils
2225
import {buildDeepLinkingMap} from 'src/utils/deepLinks'
2326
import {event} from 'src/cloud/utils/reporting'
@@ -135,6 +138,8 @@ const NotFound: FC = () => {
135138
const location = useLocation()
136139
const history = useHistory()
137140
const reduxOrg = useSelector(getOrg)
141+
const dispatch = useDispatch()
142+
138143
const org = useRef<Organization>(reduxOrg)
139144

140145
const handleDeepLink = useCallback(async () => {
@@ -169,6 +174,13 @@ const NotFound: FC = () => {
169174
}
170175
}, [handleDeepLink])
171176

177+
useEffect(() => {
178+
dispatch(setCurrentPage('not found'))
179+
return () => {
180+
dispatch(setCurrentPage('not set'))
181+
}
182+
}, [dispatch])
183+
172184
if (isFetchingOrg) {
173185
// don't render anything if this component is actively fetching org id
174186
// this prevents popping in a 404 page then redirecting

src/shared/reducers/currentPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type CurrentPage = 'dashboard' | 'not set'
1+
export type CurrentPage = 'dashboard' | 'not found' | 'not set'
22

33
export type Action = ReturnType<typeof setCurrentPage>
44

0 commit comments

Comments
 (0)