Skip to content

Commit

Permalink
Merge pull request #4341 from omnivore-app/feat/web-maintenance-banner
Browse files Browse the repository at this point in the history
Add a maintenance mode banner
  • Loading branch information
jacksonh authored Aug 28, 2024
2 parents 47dc66b + a900fcc commit 760443b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
42 changes: 42 additions & 0 deletions packages/web/components/elements/MaintenanceBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { usePersistedState } from '../../lib/hooks/usePersistedState'
import { CloseButton } from './CloseButton'
import { HStack, SpanBox } from './LayoutPrimitives'

export const MaintenanceBanner = () => {
const [
showMaintenanceMode,
setShowMaintenanceMode,
isLoadingShowMaintenanceMode,
] = usePersistedState({
key: 'show-maintenance-mode',
isSessionStorage: false,
initialValue: true,
})
return (
<>
{!isLoadingShowMaintenanceMode && showMaintenanceMode && (
<HStack
css={{
p: '5px',
width: '100%',
position: 'fixed',
bg: '#FF5733',
color: '#FFFFFF',
zIndex: '100',
}}
alignment="center"
distribution="center"
>
Omnivore will be undergoing maintenance for 30 minutes at 04:00 UTC,
during that time the website and APIs will be unavailable.
<SpanBox css={{ width: '50px' }} />
<CloseButton
close={() => {
setShowMaintenanceMode(false)
}}
/>
</HStack>
)}
</>
)
}
5 changes: 3 additions & 2 deletions packages/web/components/nav-containers/HomeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ type NavigationContextType = {
dispatch: React.Dispatch<Action>
}

const NavigationContext =
createContext<NavigationContextType | undefined>(undefined)
const NavigationContext = createContext<NavigationContextType | undefined>(
undefined
)

export const useNavigation = (): NavigationContextType => {
const context = useContext(NavigationContext)
Expand Down
2 changes: 2 additions & 0 deletions packages/web/components/templates/AuthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, VStack, HStack } from '../elements/LayoutPrimitives'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'
import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo'
import { theme } from '../tokens/stitches.config'
import { GoogleReCaptchaProvider } from '@google-recaptcha/react'
Expand All @@ -11,6 +12,7 @@ type ProfileLayoutProps = {
export function AuthLayout(props: ProfileLayoutProps): JSX.Element {
return (
<>
<MaintenanceBanner />
<VStack
alignment="center"
distribution="center"
Expand Down
2 changes: 2 additions & 0 deletions packages/web/components/templates/LoginLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import type { LoginFormProps } from './LoginForm'
import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo'

import featureFullWidthImage from '../../public/static/images/login/login-feature-image-full.png'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'

export function LoginLayout(props: LoginFormProps): JSX.Element {
return (
<>
<MaintenanceBanner />
<MediumBreakpointBox
smallerLayoutNode={<MobileLoginLayout {...props} />}
largerLayoutNode={<MediumLoginLayout {...props} />}
Expand Down
15 changes: 4 additions & 11 deletions packages/web/components/templates/NavigationLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PageMetaData, PageMetaDataProps } from '../patterns/PageMetaData'
import { HStack, SpanBox, VStack } from '../elements/LayoutPrimitives'
import { ReactNode, useEffect, useState, useCallback } from 'react'
import { useGetViewerQuery } from '../../lib/networking/queries/useGetViewerQuery'
import { navigationCommands } from '../../lib/keyboardShortcuts/navigationShortcuts'
import { useKeyboardShortcuts } from '../../lib/keyboardShortcuts/useKeyboardShortcuts'
import { useRouter } from 'next/router'
Expand All @@ -19,10 +18,12 @@ import { List } from '@phosphor-icons/react'
import { LIBRARY_LEFT_MENU_WIDTH } from './navMenu/LibraryLegacyMenu'
import { AddLinkModal } from './AddLinkModal'
import useWindowDimensions from '../../lib/hooks/useGetWindowDimensions'
import { useAddItem } from '../../lib/networking/library_items/useLibraryItems'
import { useHandleAddUrl } from '../../lib/hooks/useHandleAddUrl'
import { useGetViewer } from '../../lib/networking/viewer/useGetViewer'
import { useQueryClient } from '@tanstack/react-query'
import { usePersistedState } from '../../lib/hooks/usePersistedState'
import { CloseButton } from '../elements/CloseButton'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'

export type NavigationSection =
| 'home'
Expand Down Expand Up @@ -109,15 +110,6 @@ export function NavigationLayout(props: NavigationLayoutProps): JSX.Element {
}, [showLogout])

const { logout } = useLogout()
// if (isLoading) {
// return (
// <HStack
// css={{ width: '100vw', height: '100vh' }}
// distribution="start"
// alignment="start"
// ></HStack>
// )
// }

return (
<HStack
Expand All @@ -126,6 +118,7 @@ export function NavigationLayout(props: NavigationLayoutProps): JSX.Element {
alignment="start"
>
<PageMetaData path={props.section} title={props.title} />
<MaintenanceBanner />
<Header
menuOpen={props.showNavigationMenu}
toggleMenu={() => {
Expand Down

0 comments on commit 760443b

Please sign in to comment.