mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-08-31 16:49:24 +00:00
c9b8fb7809
* Introduced tsconfig.app.json and tsconfig.base.json * yarn.lock * Introduced tsconfig.app.json, tsconfig.base.jsonfig. * Refactored eslint.config.js to latest structure * Returned previous recommended rules. * More rules * Force import rules * Check * Check * Cleanup ESLint configuration and plugins * Cleanup heap: "writable",DD_RUM: "writable" from ESLint configuration * "scripts" moved to the top of package.json
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { type FC, useState, lazy } from "react";
|
|
import { ErrorBoundary } from "react-error-boundary";
|
|
import { HashRouter, Outlet, Route, Routes, useParams } from "react-router";
|
|
|
|
import apiService from "./API/apiService";
|
|
import ErrorFallback from "./components/ErrorFallback";
|
|
import GlobalErrorModal from "./components/modal/GlobalErrorModal";
|
|
import { AppContextProvider } from "./context/AppContext";
|
|
import {
|
|
ErrorModalContext,
|
|
type ErrorAlert,
|
|
} from "./context/ErrorModalContext";
|
|
import Header from "./layout/Header";
|
|
import Installed from "./pages/Installed";
|
|
import RepositoryPage from "./pages/Repository";
|
|
import Revision from "./pages/Revision";
|
|
|
|
const DocsPage = lazy(() => import("./pages/DocsPage"));
|
|
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
},
|
|
},
|
|
});
|
|
|
|
const PageLayout = () => {
|
|
return (
|
|
<div className="flex h-screen flex-col">
|
|
<Header />
|
|
<div className="flex-1 bg-body-background bg-[url('./assets/body-background.svg')] bg-no-repeat">
|
|
<Outlet />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const SyncContext: FC = () => {
|
|
const { context } = useParams();
|
|
if (context) {
|
|
apiService.setCluster(decodeURIComponent(context));
|
|
}
|
|
|
|
return <Outlet />;
|
|
};
|
|
|
|
export default function App() {
|
|
const [shouldShowErrorModal, setShowErrorModal] = useState<
|
|
ErrorAlert | undefined
|
|
>(undefined);
|
|
const value = { shouldShowErrorModal, setShowErrorModal };
|
|
|
|
return (
|
|
<AppContextProvider>
|
|
<ErrorModalContext.Provider value={value}>
|
|
<QueryClientProvider client={queryClient}>
|
|
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
|
<HashRouter>
|
|
<Routes>
|
|
<Route path="docs/*" element={<DocsPage />} />
|
|
<Route path="*" element={<PageLayout />}>
|
|
<Route path=":context?/*" element={<SyncContext />}>
|
|
<Route
|
|
path="repository/:selectedRepo?/*"
|
|
element={<RepositoryPage />}
|
|
/>
|
|
<Route path="installed/?" element={<Installed />} />
|
|
<Route
|
|
path=":namespace/:chart/installed/revision/:revision"
|
|
element={<Revision />}
|
|
/>
|
|
<Route path="*" element={<Installed />} />
|
|
</Route>
|
|
</Route>
|
|
</Routes>
|
|
</HashRouter>
|
|
</ErrorBoundary>
|
|
<GlobalErrorModal
|
|
isOpen={!!shouldShowErrorModal}
|
|
onClose={() => setShowErrorModal(undefined)}
|
|
titleText={shouldShowErrorModal?.title || ""}
|
|
contentText={shouldShowErrorModal?.msg || ""}
|
|
/>
|
|
</QueryClientProvider>
|
|
</ErrorModalContext.Provider>
|
|
</AppContextProvider>
|
|
);
|
|
}
|