From 86fc3e09a3d73cdbbdc981452a4b13a9b37b65eb Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Wed, 2 Nov 2022 17:17:14 -0300 Subject: [PATCH] refactor: Better colocate suspense (#4863) --- site/src/components/AuthAndFrame/AuthAndFrame.tsx | 8 +++++--- .../DeploySettingsLayout/DeploySettingsLayout.tsx | 3 ++- site/src/components/TemplateLayout/TemplateLayout.tsx | 11 +++++++++-- site/src/pages/WorkspacePage/WorkspacePage.tsx | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/site/src/components/AuthAndFrame/AuthAndFrame.tsx b/site/src/components/AuthAndFrame/AuthAndFrame.tsx index 2473ef6472..b8b4cbdcd8 100644 --- a/site/src/components/AuthAndFrame/AuthAndFrame.tsx +++ b/site/src/components/AuthAndFrame/AuthAndFrame.tsx @@ -1,6 +1,7 @@ import { makeStyles } from "@material-ui/core/styles" import { useActor } from "@xstate/react" -import { FC, useContext } from "react" +import { Loader } from "components/Loader/Loader" +import { FC, Suspense, useContext } from "react" import { XServiceContext } from "../../xServices/StateContext" import { Footer } from "../Footer/Footer" import { Navbar } from "../Navbar/Navbar" @@ -16,14 +17,15 @@ interface AuthAndFrameProps { export const AuthAndFrame: FC = ({ children }) => { const styles = useStyles() const xServices = useContext(XServiceContext) - const [buildInfoState] = useActor(xServices.buildInfoXService) return (
-
{children}
+
+ }>{children} +
diff --git a/site/src/components/DeploySettingsLayout/DeploySettingsLayout.tsx b/site/src/components/DeploySettingsLayout/DeploySettingsLayout.tsx index f9294d4108..33d8db4d57 100644 --- a/site/src/components/DeploySettingsLayout/DeploySettingsLayout.tsx +++ b/site/src/components/DeploySettingsLayout/DeploySettingsLayout.tsx @@ -5,6 +5,7 @@ import { Sidebar } from "./Sidebar" import React, { createContext, PropsWithChildren, + Suspense, useContext, useEffect, } from "react" @@ -52,7 +53,7 @@ export const DeploySettingsLayout: React.FC = ({ - {children} + }>{children} ) : ( diff --git a/site/src/components/TemplateLayout/TemplateLayout.tsx b/site/src/components/TemplateLayout/TemplateLayout.tsx index f7df905260..c348ed6a38 100644 --- a/site/src/components/TemplateLayout/TemplateLayout.tsx +++ b/site/src/components/TemplateLayout/TemplateLayout.tsx @@ -15,7 +15,13 @@ import { PageHeaderTitle, } from "components/PageHeader/PageHeader" import { useOrganizationId } from "hooks/useOrganizationId" -import { createContext, FC, PropsWithChildren, useContext } from "react" +import { + createContext, + FC, + PropsWithChildren, + Suspense, + useContext, +} from "react" import { Link as RouterLink, Navigate, @@ -33,6 +39,7 @@ import { import { Margins } from "../../components/Margins/Margins" import { Stack } from "../../components/Stack/Stack" import { Permissions } from "xServices/auth/authXService" +import { Loader } from "components/Loader/Loader" const Language = { settingsButton: "Settings", @@ -224,7 +231,7 @@ export const TemplateLayout: FC = ({ children }) => { - {children} + }>{children} diff --git a/site/src/pages/WorkspacePage/WorkspacePage.tsx b/site/src/pages/WorkspacePage/WorkspacePage.tsx index 6e47a4dda0..46fb48d620 100644 --- a/site/src/pages/WorkspacePage/WorkspacePage.tsx +++ b/site/src/pages/WorkspacePage/WorkspacePage.tsx @@ -4,7 +4,7 @@ import { AlertBanner } from "components/AlertBanner/AlertBanner" import { ChooseOne, Cond } from "components/Conditionals/ChooseOne" import { FC, useEffect } from "react" import { useParams } from "react-router-dom" -import { FullScreenLoader } from "components/Loader/FullScreenLoader" +import { Loader } from "components/Loader/Loader" import { firstOrItem } from "util/array" import { workspaceMachine } from "xServices/workspace/workspaceXService" import { WorkspaceReadyPage } from "./WorkspaceReadyPage" @@ -55,7 +55,7 @@ export const WorkspacePage: FC = () => { /> - + )