fix config error bugs
This commit is contained in:
parent
3b78cf211c
commit
ae7900bebe
5 changed files with 65 additions and 92 deletions
|
|
@ -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 = () => {
|
|||
<LocalStorageProvider>
|
||||
<AuthProvider>
|
||||
<LayoutTopDiv>
|
||||
<OSRContextMenu />
|
||||
<div
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
}}
|
||||
>
|
||||
<TextDialog
|
||||
showDialog={showDialog}
|
||||
onEnter={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
<LumpProvider>
|
||||
<OSRContextMenu />
|
||||
<div
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
}}
|
||||
onClose={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
message={dialogMessage}
|
||||
/>
|
||||
>
|
||||
<TextDialog
|
||||
showDialog={showDialog}
|
||||
onEnter={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
onClose={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
message={dialogMessage}
|
||||
/>
|
||||
|
||||
<GridDiv className="">
|
||||
<PostHogPageView />
|
||||
<Outlet />
|
||||
|
||||
{hasFatalErrors && pathname !== ROUTES.CONFIG_ERROR && (
|
||||
<div
|
||||
className="z-50 cursor-pointer bg-red-600 p-4 text-center text-white"
|
||||
role="alert"
|
||||
onClick={() => navigate(ROUTES.CONFIG_ERROR)}
|
||||
>
|
||||
<strong className="font-bold">Error!</strong>{" "}
|
||||
<span className="block sm:inline">Could not load config</span>
|
||||
<div className="mt-2 underline">Learn More</div>
|
||||
</div>
|
||||
)}
|
||||
<Footer />
|
||||
</GridDiv>
|
||||
</div>
|
||||
<div style={{ fontSize: fontSize(-4) }} id="tooltip-portal-div" />
|
||||
<GridDiv className="">
|
||||
<PostHogPageView />
|
||||
<Outlet />
|
||||
<FatalErrorIndicator />
|
||||
<Footer />
|
||||
</GridDiv>
|
||||
</div>
|
||||
<div style={{ fontSize: fontSize(-4) }} id="tooltip-portal-div" />
|
||||
</LumpProvider>
|
||||
</LayoutTopDiv>
|
||||
</AuthProvider>
|
||||
</LocalStorageProvider>
|
||||
|
|
|
|||
32
gui/src/components/config/FatalErrorNotice.tsx
Normal file
32
gui/src/components/config/FatalErrorNotice.tsx
Normal file
|
|
@ -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 (
|
||||
<div
|
||||
className="z-50 cursor-pointer bg-red-600 p-4 text-center text-white"
|
||||
role="alert"
|
||||
onClick={showLumpErrorSection}
|
||||
>
|
||||
<strong className="font-bold">Error!</strong>{" "}
|
||||
<span className="block sm:inline">Could not load config</span>
|
||||
<div className="mt-2 underline">Learn More</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -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 (
|
||||
<LumpProvider>
|
||||
<LumpContent />
|
||||
</LumpProvider>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal component that consumes the LumpContext
|
||||
*/
|
||||
function LumpContent() {
|
||||
export function Lump() {
|
||||
const { isLumpVisible, selectedSection } = useLump();
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<HeaderButtonWithToolTip
|
||||
tooltipPlacement="top-end"
|
||||
text="Config error"
|
||||
onClick={onClickError}
|
||||
>
|
||||
<ExclamationTriangleIcon className="h-[13px] w-[13px] flex-shrink-0 text-red-600 hover:brightness-125" />
|
||||
</HeaderButtonWithToolTip>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConfigErrorIndicator;
|
||||
|
|
@ -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}`,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue