diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 0f52d3d0b..0c5acda83 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo } from "react"; +import { useEffect } from "react"; import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; import { CustomScrollbarDiv, defaultBorderRadius } from "."; @@ -19,8 +19,10 @@ import { loadLastSession, saveCurrentSession } from "../redux/thunks/session"; import { fontSize, isMetaEquivalentKeyPressed } from "../util"; import { incrementFreeTrialCount } from "../util/freeTrial"; import { ROUTES } from "../util/navigation"; +import { FatalErrorIndicator } from "./config/FatalErrorNotice"; import TextDialog from "./dialogs"; import Footer from "./Footer"; +import { LumpProvider } from "./mainInput/Lump/LumpContext"; import { isNewUserOnboarding, useOnboardingCard } from "./OnboardingCard"; import OSRContextMenu from "./OSRContextMenu"; import PostHogPageView from "./PosthogPageView"; @@ -44,13 +46,6 @@ const Layout = () => { const location = useLocation(); const dispatch = useAppDispatch(); const onboardingCard = useOnboardingCard(); - const { pathname } = useLocation(); - - const configError = useAppSelector((state) => state.config.configError); - - const hasFatalErrors = useMemo(() => { - return configError?.some((error) => error.fatal); - }, [configError]); const dialogMessage = useAppSelector((state) => state.ui.dialogMessage); @@ -238,45 +233,36 @@ const Layout = () => { - -
- { - dispatch(setShowDialog(false)); + + +
{ - dispatch(setShowDialog(false)); - }} - message={dialogMessage} - /> + > + { + dispatch(setShowDialog(false)); + }} + onClose={() => { + dispatch(setShowDialog(false)); + }} + message={dialogMessage} + /> - - - - - {hasFatalErrors && pathname !== ROUTES.CONFIG_ERROR && ( -
navigate(ROUTES.CONFIG_ERROR)} - > - Error!{" "} - Could not load config -
Learn More
-
- )} -
- -
-
+ + + + +
+ +
+
+ diff --git a/gui/src/components/config/FatalErrorNotice.tsx b/gui/src/components/config/FatalErrorNotice.tsx new file mode 100644 index 000000000..6c03d23b6 --- /dev/null +++ b/gui/src/components/config/FatalErrorNotice.tsx @@ -0,0 +1,32 @@ +import { useMemo } from "react"; +import { useAppSelector } from "../../redux/hooks"; +import { useLump } from "../mainInput/Lump/LumpContext"; + +export const FatalErrorIndicator = () => { + const configError = useAppSelector((store) => store.config.configError); + + const hasFatalErrors = useMemo(() => { + return configError?.some((error) => error.fatal); + }, [configError]); + + const { setSelectedSection } = useLump(); + + const showLumpErrorSection = () => { + setSelectedSection("error"); + }; + + if (!hasFatalErrors) { + return null; + } + return ( +
+ Error!{" "} + Could not load config +
Learn More
+
+ ); +}; diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index de432f1d1..32222af65 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -4,7 +4,7 @@ import { vscCommandCenterInactiveBorder, vscInputBackground, } from "../.."; -import { LumpProvider, useLump } from "./LumpContext"; +import { useLump } from "./LumpContext"; import { LumpToolbar } from "./LumpToolbar"; import { SelectedSection } from "./sections/SelectedSection"; @@ -29,21 +29,10 @@ const ContentDiv = styled.div<{ hasSection: boolean; isVisible: boolean }>` overflow-y: auto; `; -/** - * Main component that displays the toolbar and selected content section - */ -export function Lump() { - return ( - - - - ); -} - /** * Internal component that consumes the LumpContext */ -function LumpContent() { +export function Lump() { const { isLumpVisible, selectedSection } = useLump(); return ( diff --git a/gui/src/pages/gui/ConfigError.tsx b/gui/src/pages/gui/ConfigError.tsx deleted file mode 100644 index ee85046f1..000000000 --- a/gui/src/pages/gui/ConfigError.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; -import { useLocation, useNavigate } from "react-router-dom"; -import HeaderButtonWithToolTip from "../../components/gui/HeaderButtonWithToolTip"; -import { useAppSelector } from "../../redux/hooks"; -import { ROUTES } from "../../util/navigation"; - -const ConfigErrorIndicator = () => { - const configError = useAppSelector((store) => store.config.configError); - - const navigate = useNavigate(); - const { pathname } = useLocation(); - - function onClickError() { - navigate(pathname === ROUTES.CONFIG_ERROR ? "/" : ROUTES.CONFIG_ERROR); - } - - if (!configError?.length) { - return null; - } - - // TODO: add a tooltip - return ( - - - - ); -}; - -export default ConfigErrorIndicator; diff --git a/gui/src/util/navigation.ts b/gui/src/util/navigation.ts index 8a7693b32..0f145b6cd 100644 --- a/gui/src/util/navigation.ts +++ b/gui/src/util/navigation.ts @@ -1,7 +1,6 @@ // TODO: Move all the routes here export const ROUTES = { HOME: "/", - CONFIG_ERROR: "/config-error", CONFIG: "/config", // EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`, };