Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: front-end cloud admin flag for clickhouse (#3666)

Max Deichmannb1357a0bae3c
diff --git a/web/src/components/layouts/ClickhouseAdminToggle.tsx b/web/src/components/layouts/ClickhouseAdminToggle.tsx
new file mode 100644
index 0000000000..fb37f6f9e7
--- /dev/null
+++ b/web/src/components/layouts/ClickhouseAdminToggle.tsx
@@ -0,0 +1,40 @@
+import { Switch } from "@/src/components/ui/switch";
+import useLocalStorage from "@/src/components/useLocalStorage";
+import { useSession } from "next-auth/react";
+
+export const useClickhouse = () => {
+ const session = useSession();
+ const [isEnabled] = useLocalStorage<boolean>("useClickhouseQueries", false);
+
+ return isEnabled && session.data?.user?.admin === true;
+};
+
+export function ClickhouseAdminToggle() {
+ const [isEnabled, setIsEnabled] = useLocalStorage<boolean>(
+ "useClickhouseQueries",
+ false,
+ );
+
+ const handleToggle = () => {
+ setIsEnabled((prev) => !prev);
+ // You can add any additional logic here, such as API calls or analytics tracking
+ };
+
+ return (
+ <div className="ml-auto flex items-center space-x-1">
+ <div
+ title={
+ isEnabled ? "Disable Clickhouse Queries" : "Enable Clickhouse Queries"
+ }
+ >
+ <Switch
+ id="clickhouse-toggle"
+ checked={isEnabled}
+ onCheckedChange={() => {
+ handleToggle();
+ }}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsx
index b3f73ee268..5fd9a99eca 100644
--- a/web/src/components/layouts/layout.tsx
+++ b/web/src/components/layouts/layout.tsx
@@ -34,6 +34,7 @@ import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
import { useOrgEntitlements } from "@/src/features/entitlements/hooks";
import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
+import { ClickhouseAdminToggle } from "@/src/components/layouts/ClickhouseAdminToggle";
const signOutUser = async () => {
localStorage.clear();
@@ -42,17 +43,30 @@ const signOutUser = async () => {
await signOut();
};
-const userNavigation = [
- {
- name: "Theme",
- onClick: () => {},
- content: <ThemeToggle />,
- },
- {
- name: "Sign out",
- onClick: signOutUser,
- },
-];
+const getUserNavigation = (isAdmin: boolean) => {
+ const navigationItems = [
+ {
+ name: "Theme",
+ onClick: () => {},
+ content: <ThemeToggle />,
+ },
+ {
+ name: "Sign out",
+ onClick: signOutUser,
+ },
+ ];
+
+ return isAdmin
+ ? [
+ {
+ name: "CH Query",
+ onClick: () => {},
+ content: <ClickhouseAdminToggle />,
+ },
+ ...navigationItems,
+ ]
+ : navigationItems;
+};
const pathsWithoutNavigation: string[] = [
"/onboarding",
@@ -186,7 +200,7 @@ export default function Layout(props: PropsWithChildren) {
const href = (
route.customizableHref
- ? uiCustomization?.[route.customizableHref] ?? route.pathname
+ ? (uiCustomization?.[route.customizableHref] ?? route.pathname)
: route.pathname
)
?.replace("[projectId]", routerProjectId ?? "")
@@ -441,14 +455,14 @@ export default function Layout(props: PropsWithChildren) {
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
- <Menu.Items className="absolute -top-full bottom-1 right-0 z-10 overflow-hidden rounded-md bg-background py-2 shadow-lg ring-1 ring-border focus:outline-none">
+ <Menu.Items className="absolute bottom-1 right-0 z-10 overflow-hidden rounded-md bg-background py-2 shadow-lg ring-1 ring-border focus:outline-none">
<span
className="block max-w-52 overflow-hidden truncate border-b px-3 pb-2 text-sm leading-6 text-muted-foreground"
title={session.data?.user?.email ?? undefined}
>
{session.data?.user?.email}
</span>
- {userNavigation.map((item) => (
+ {getUserNavigation(cloudAdmin).map((item) => (
<Menu.Item key={item.name}>
{({ active }) => (
<a
@@ -516,7 +530,7 @@ export default function Layout(props: PropsWithChildren) {
>
{session.data?.user?.email}
</span>
- {userNavigation.map((item) => (
+ {getUserNavigation(cloudAdmin).map((item) => (
<Menu.Item key={item.name}>
{({ active }) => (
<a
diff --git a/web/src/pages/support.tsx b/web/src/pages/support.tsx
index a73c938088..fc8a98a4c0 100644
--- a/web/src/pages/support.tsx
+++ b/web/src/pages/support.tsx
@@ -5,6 +5,7 @@ export default function SupportPage() {
return (
<div className="md:container">
<Header title="Support" />
+
<div className="flex flex-col gap-10">
<p>
We are here to help in case of questions or issues. Pick the channel