diff --git a/client/public/env.js b/client/public/env.js index 92cd34980..9c6c7c9a2 100644 --- a/client/public/env.js +++ b/client/public/env.js @@ -2,6 +2,6 @@ window.__ENV = { GLOBAL_REFRESH: "60000", APP_HOST: "http://localhost:5173", APP_API_BASE_URL: "http://localhost:52345/api/v1", - // APP_DEPLOYMENT_MODE: "self_hosted", - APP_DEPLOYMENT_MODE: "saas", + APP_DEPLOYMENT_MODE: "self_hosted", + // APP_DEPLOYMENT_MODE: "saas", }; diff --git a/client/src/components/protected-route/index.tsx b/client/src/components/protected-route/index.tsx index f9f4f732a..ce0741d67 100644 --- a/client/src/components/protected-route/index.tsx +++ b/client/src/components/protected-route/index.tsx @@ -1,5 +1,6 @@ import { useAppSelector } from "@/hooks/AppHooks"; import { Navigate } from "react-router"; +import NotFound from "@/pages/errors/NotFound"; export const ProtectedRoute: React.FC = ({ children, @@ -20,3 +21,24 @@ export const ProtectedRoute: React.FC = ({ return <>{children}; }; + +export const MasterRoute: React.FC = ({ + children, +}) => { + const user = useAppSelector((state) => state.auth.user); + + if (user?.teams.length === 0) { + return ; + } + + const perms: string[] = (user?.org?.permissions || []).map((p: any) => + (p ?? "").toString().trim().toLowerCase() + ); + const hasMaster = perms.includes("master"); + + if (!hasMaster) { + return ; + } + + return <>{children}; +}; diff --git a/client/src/pages/diagnostic/DiagnosticsConfigTab.tsx b/client/src/pages/diagnostic/DiagnosticsConfigTab.tsx index 4cab8a6d5..d3bc1fd66 100644 --- a/client/src/pages/diagnostic/DiagnosticsConfigTab.tsx +++ b/client/src/pages/diagnostic/DiagnosticsConfigTab.tsx @@ -1,5 +1,11 @@ -import { Box, Typography, Paper, Stack, Divider } from "@mui/material"; +import Stack from "@mui/material/Stack"; +import Typography from "@mui/material/Typography"; +import Divider from "@mui/material/Divider"; +import Box from "@mui/material/Box"; +import { useTheme } from "@mui/material/styles"; import { useGet } from "@/hooks/UseApi"; +import { StatBox } from "@/components/design-elements"; +import { config as clientConfig } from "@/config"; type EnvConfig = { NODE_ENV: string; @@ -18,26 +24,24 @@ type EnvConfig = { }; export default function DiagnosticsConfigTab() { + const theme = useTheme(); const { response, loading, error } = useGet<{ message: string; data: EnvConfig; - }>("/diagnostic/env"); + }>("/diagnostic/env", {}, { refreshInterval: clientConfig.GLOBAL_REFRESH }); const data = response?.data; + const clientEntries = Object.entries(clientConfig as Record); + + if (!data && !loading && !error) return null; + + const totalKeys = data ? Object.keys(data).length : 0; return ( - - - Environment Configuration - - {loading && Loading…} - {error && ( - - {error} - - )} + {data && ( - + + Server environment }> {Object.entries(data).map(([key, value]) => ( @@ -50,8 +54,24 @@ export default function DiagnosticsConfigTab() { ))} - + )} - + + + Client runtime config + }> + {clientEntries.map(([key, value]) => ( + + + {key} + + + {String(value)} + + + ))} + + + ); } diff --git a/client/src/routes/Router.tsx b/client/src/routes/Router.tsx index 01a063f84..80c4e33cd 100644 --- a/client/src/routes/Router.tsx +++ b/client/src/routes/Router.tsx @@ -57,7 +57,7 @@ import BillingPage from "@/pages/billing/Billing"; import BillingSuccessPage from "@/pages/billing/Success"; import RootLayout from "@/components/layouts/RootLayout"; -import { ProtectedRoute } from "@/components/protected-route"; +import { ProtectedRoute, MasterRoute } from "@/components/protected-route"; const Router = () => { return ( @@ -84,7 +84,14 @@ const Router = () => { } /> } /> } /> - } /> + + + + } + /> } /> { element={} /> - } /> + + + + } + /> } /> } />