From aa5b4269b2bacea16eb6ed5555cfa5cd40e62ed3 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Mon, 6 Jun 2022 17:35:09 +0800 Subject: [PATCH] Add incident banner --- .../interfaces/App/AppBannerWrapper.tsx | 29 +++++++++++++++++++ studio/components/interfaces/App/index.ts | 3 +- .../layouts/AccountLayout/AccountLayout.tsx | 8 +++-- .../layouts/AccountLayout/WithSidebar.tsx | 20 +++++++------ .../NavigationBar/NavigationBar.tsx | 25 +++++++--------- .../layouts/ProjectLayout/ProductMenuBar.tsx | 11 +++++-- .../layouts/ProjectLayout/ProjectLayout.tsx | 6 ++-- studio/pages/_app.tsx | 9 ++++-- 8 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 studio/components/interfaces/App/AppBannerWrapper.tsx diff --git a/studio/components/interfaces/App/AppBannerWrapper.tsx b/studio/components/interfaces/App/AppBannerWrapper.tsx new file mode 100644 index 00000000000..18f3620840f --- /dev/null +++ b/studio/components/interfaces/App/AppBannerWrapper.tsx @@ -0,0 +1,29 @@ +import { FC } from 'react' +import Link from 'next/link' +import { useFlag } from 'hooks' +import { IconExternalLink } from '@supabase/ui' + +const AppBannerWrapper: FC = ({ children }) => { + const ongoingIncident = useFlag('ongoingIncident') + + return ( +
+ {ongoingIncident && ( + + +
+

+ We are currently investigating a technical issue, follow status.supabase.com for + updates +

+ +
+
+ + )} + {children} +
+ ) +} + +export default AppBannerWrapper diff --git a/studio/components/interfaces/App/index.ts b/studio/components/interfaces/App/index.ts index f65fabe0209..4e92356a261 100644 --- a/studio/components/interfaces/App/index.ts +++ b/studio/components/interfaces/App/index.ts @@ -1,5 +1,6 @@ import PortalToast from './PortalToast' import GoTrueWrapper from './GoTrueWrapper/GoTrueWrapper' import RouteValidationWrapper from './RouteValidationWrapper' +import AppBannerWrapper from './AppBannerWrapper' -export { PortalToast, GoTrueWrapper, RouteValidationWrapper } +export { PortalToast, GoTrueWrapper, RouteValidationWrapper, AppBannerWrapper } diff --git a/studio/components/layouts/AccountLayout/AccountLayout.tsx b/studio/components/layouts/AccountLayout/AccountLayout.tsx index 0c0e347967f..98822e64257 100644 --- a/studio/components/layouts/AccountLayout/AccountLayout.tsx +++ b/studio/components/layouts/AccountLayout/AccountLayout.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { observer } from 'mobx-react-lite' import { API_URL, IS_PLATFORM } from 'lib/constants' -import { useStore, withAuth } from 'hooks' +import { useStore, withAuth, useFlag } from 'hooks' import WithSidebar from './WithSidebar' import { auth } from 'lib/gotrue' @@ -17,9 +17,11 @@ import { auth } from 'lib/gotrue' const AccountLayout = ({ children, title, breadcrumbs }: any) => { const router = useRouter() - const { app, ui } = useStore() + const ongoingIncident = useFlag('ongoingIncident') + const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh' + const onClickLogout = async () => { await auth.signOut() router.reload() @@ -117,7 +119,7 @@ const AccountLayout = ({ children, title, breadcrumbs }: any) => {
diff --git a/studio/components/layouts/AccountLayout/WithSidebar.tsx b/studio/components/layouts/AccountLayout/WithSidebar.tsx index c36c6388f51..8ac03d40866 100644 --- a/studio/components/layouts/AccountLayout/WithSidebar.tsx +++ b/studio/components/layouts/AccountLayout/WithSidebar.tsx @@ -1,7 +1,8 @@ import Link from 'next/link' -import { CSSProperties, FC, ReactNode } from 'react' -import { Menu, Typography, IconArrowUpRight, Badge } from '@supabase/ui' +import { FC, ReactNode } from 'react' import { isUndefined } from 'lodash' +import { Menu, Typography, IconArrowUpRight, Badge } from '@supabase/ui' +import { useFlag } from 'hooks' import LayoutHeader from '../ProjectLayout/LayoutHeader' interface Props { @@ -11,7 +12,6 @@ interface Props { header?: ReactNode subitems?: any[] subitemsParentKey?: number - sidebarStyle?: CSSProperties hideSidebar?: boolean customSidebarContent?: ReactNode children: ReactNode @@ -22,7 +22,6 @@ const WithSidebar: FC = ({ header, breadcrumbs = [], children, - sidebarStyle, links, subitems, subitemsParentKey, @@ -32,16 +31,19 @@ const WithSidebar: FC = ({ const noContent = !links && !customSidebarContent const linksHaveHeaders = links && links[0].heading + const ongoingIncident = useFlag('ongoingIncident') + const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh' + return ( -
+
{!hideSidebar && !noContent && (
{title && (
@@ -74,7 +76,7 @@ const WithSidebar: FC = ({
)} -
+
{children}
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx index 335b31fd207..dd8f38a36dd 100644 --- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx +++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx @@ -6,7 +6,7 @@ import { isUndefined } from 'lodash' import { Button, IconHome, Dropdown, IconUser, IconSettings } from '@supabase/ui' import { IS_PLATFORM } from 'lib/constants' -import { useStore } from 'hooks' +import { useStore, useFlag } from 'hooks' import { generateProductRoutes, generateOtherRoutes } from './NavigationBar.utils' import NavigationIconButton from './NavigationIconButton' @@ -18,22 +18,19 @@ const NavigationBar: FC = ({}) => { const projectRef = ui.selectedProjectRef as string const projectBaseInfo = ui.selectedProjectBaseInfo + const ongoingIncident = useFlag('ongoingIncident') + const activeRoute = router.pathname.split('/')[3] const productRoutes = generateProductRoutes(projectRef, projectBaseInfo) const otherRoutes = generateOtherRoutes(projectRef, projectBaseInfo) return (
    @@ -41,7 +38,7 @@ const NavigationBar: FC = ({}) => { Supabase @@ -54,7 +51,7 @@ const NavigationBar: FC = ({}) => { link: `/project/${projectRef}`, }} /> -
    +
    {productRoutes.map((route) => ( = ({}) => { isActive={activeRoute === route.key} /> ))} -
    +
    {otherRoutes.map((route) => ( = ({ title, children }) => { + const ongoingIncident = useFlag('ongoingIncident') + const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh' + return (
    {title}
    -
    {children}
    +
    {children}
    ) } diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx index c646ddc0887..366bff4e7ed 100644 --- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx +++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx @@ -2,7 +2,7 @@ import Head from 'next/head' import { FC, ReactNode, PropsWithChildren } from 'react' import { observer } from 'mobx-react-lite' import { useRouter } from 'next/router' -import { useStore, withAuth } from 'hooks' +import { useStore, withAuth, useFlag } from 'hooks' import { PROJECT_STATUS } from 'lib/constants' import Connecting from 'components/ui/Loading' @@ -30,6 +30,8 @@ const ProjectLayout = ({ hideHeader = false, hideIconBar = false, }: PropsWithChildren) => { + const ongoingIncident = useFlag('ongoingIncident') + return ( <> @@ -47,8 +49,8 @@ const ProjectLayout = ({
    {!hideHeader && } {children} diff --git a/studio/pages/_app.tsx b/studio/pages/_app.tsx index 5b97a48d507..9420bc43e17 100644 --- a/studio/pages/_app.tsx +++ b/studio/pages/_app.tsx @@ -26,7 +26,12 @@ import { StoreProvider } from 'hooks' import { getParameterByName } from 'lib/common/fetch' import { GOTRUE_ERRORS } from 'lib/constants' -import { PortalToast, GoTrueWrapper, RouteValidationWrapper } from 'components/interfaces/App' +import { + PortalToast, + GoTrueWrapper, + RouteValidationWrapper, + AppBannerWrapper, +} from 'components/interfaces/App' import PageTelemetry from 'components/ui/PageTelemetry' import FlagProvider from 'components/ui/Flag/FlagProvider' @@ -62,7 +67,7 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) { - {getLayout()} + {getLayout()}