From d79c2f26888b512faaa0526936b8752cfb6c8b28 Mon Sep 17 00:00:00 2001
From: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Mon, 3 Jun 2024 11:20:53 +0200
Subject: [feature/frontend] Add debug sections to settings panel (#2950)

* [feature/frontend] Add debug sections to settings panel

* max-width

* swagger
---
 web/source/settings/index.tsx | 43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

(limited to 'web/source/settings/index.tsx')

diff --git a/web/source/settings/index.tsx b/web/source/settings/index.tsx
index 25e3d1f3c..5317658d2 100644
--- a/web/source/settings/index.tsx
+++ b/web/source/settings/index.tsx
@@ -27,7 +27,7 @@ import { store, persistor } from "./redux/store";
 import { Authorization } from "./components/authorization";
 import Loading from "./components/loading";
 import { Account } from "./lib/types/account";
-import { BaseUrlContext, RoleContext } from "./lib/navigation/util";
+import { BaseUrlContext, RoleContext, InstanceDebugContext } from "./lib/navigation/util";
 import { SidebarMenu } from "./lib/navigation/menu";
 import { Redirect, Route, Router } from "wouter";
 import AdminMenu from "./views/admin/menu";
@@ -37,6 +37,7 @@ import UserRouter from "./views/user/router";
 import { ErrorBoundary } from "./lib/navigation/error";
 import ModerationRouter from "./views/moderation/router";
 import AdminRouter from "./views/admin/router";
+import { useInstanceV1Query } from "./lib/query/gts-api";
 
 interface AppProps {
 	account: Account;
@@ -44,29 +45,33 @@ interface AppProps {
 
 export function App({ account }: AppProps) {
 	const roles: string[] = useMemo(() => [ account.role.name ], [account]);
+	const { data: instance } = useInstanceV1Query();
+	
 	return (
 		<RoleContext.Provider value={roles}>
-			<BaseUrlContext.Provider value={"/settings"}>
-				<SidebarMenu>
-					<UserMenu />
-					<ModerationMenu />
-					<AdminMenu />
-				</SidebarMenu>
-				<section className="with-sidebar">
-					<Router base="/settings">
-						<ErrorBoundary>
-							<UserRouter />
-							<ModerationRouter />
-							<AdminRouter />
-							{/*
+			<InstanceDebugContext.Provider value={instance?.debug ?? false}>
+				<BaseUrlContext.Provider value={"/settings"}>
+					<SidebarMenu>
+						<UserMenu />
+						<ModerationMenu />
+						<AdminMenu />
+					</SidebarMenu>
+					<section className="with-sidebar">
+						<Router base="/settings">
+							<ErrorBoundary>
+								<UserRouter />
+								<ModerationRouter />
+								<AdminRouter />
+								{/*
 								Ensure user ends up somewhere
 								if they just open /settings.
 							*/}
-							<Route path="/"><Redirect to="/user" /></Route>
-						</ErrorBoundary>
-					</Router>
-				</section>
-			</BaseUrlContext.Provider>
+								<Route path="/"><Redirect to="/user" /></Route>
+							</ErrorBoundary>
+						</Router>
+					</section>
+				</BaseUrlContext.Provider>
+			</InstanceDebugContext.Provider>
 		</RoleContext.Provider>
 	);
 }
-- 
cgit v1.2.3

