diff --git a/gui/src/components/schema-sidebar.tsx b/gui/src/components/schema-sidebar.tsx index b31c1317..f162e3e1 100644 --- a/gui/src/components/schema-sidebar.tsx +++ b/gui/src/components/schema-sidebar.tsx @@ -4,9 +4,11 @@ import SchemaList from "./schema-sidebar-list"; import ListButtonItem from "./list-button-item"; import { Separator } from "./ui/separator"; import { openTab } from "@gui/messages/open-tab"; +import { useConfig } from "@gui/contexts/config-provider"; export default function SchemaView() { const [search, setSearch] = useState(""); + const { sideBarFooterComponent } = useConfig(); const onNewTable = useCallback(() => { openTab({ @@ -46,31 +48,17 @@ export default function SchemaView() { -
- LibStudio Studio is open-source GUI for serverless - database. We are new and need your feedback - + {sideBarFooterComponent} +
+ Powered by{" "} + + LibSQL Studio +
diff --git a/gui/src/contexts/config-provider.tsx b/gui/src/contexts/config-provider.tsx index 19f2738a..4e92fa4e 100644 --- a/gui/src/contexts/config-provider.tsx +++ b/gui/src/contexts/config-provider.tsx @@ -1,10 +1,11 @@ -import type { PropsWithChildren } from "react"; +import type { PropsWithChildren, ReactElement } from "react"; import { createContext, useContext, useMemo } from "react"; interface ConfigContextProps { color: string; name: string; onBack: () => void; + sideBarFooterComponent?: ReactElement; } const ConfigContext = createContext({ @@ -24,8 +25,12 @@ export function ConfigProvider({ color, name, onBack, + sideBarFooterComponent, }: PropsWithChildren) { - const memo = useMemo(() => ({ color, name, onBack }), [name, color, onBack]); + const memo = useMemo( + () => ({ color, name, onBack, sideBarFooterComponent }), + [name, color, onBack, sideBarFooterComponent] + ); return ( {children} diff --git a/gui/src/studio.tsx b/gui/src/studio.tsx index 605b9141..869042d3 100644 --- a/gui/src/studio.tsx +++ b/gui/src/studio.tsx @@ -6,6 +6,7 @@ import { DriverProvider } from "./contexts/driver-provider"; import ThemeProvider from "./contexts/theme-provider"; import type { BaseDriver } from "./drivers/base-driver"; import { CollaborationDriver } from "./drivers/collaboration-driver"; +import { ReactElement } from "react"; interface StudioProps { driver: BaseDriver; @@ -14,6 +15,8 @@ interface StudioProps { color: string; defaultTheme?: "dark" | "light"; onBack: () => void; + + sideBarFooterComponent?: ReactElement; } export function Studio({ @@ -22,12 +25,18 @@ export function Studio({ collaboration, name, color, + sideBarFooterComponent, onBack, }: Readonly) { return ( - + diff --git a/studio/src/app/client/[[...driver]]/page-client.tsx b/studio/src/app/client/[[...driver]]/page-client.tsx index 4ae26905..de42e6b4 100644 --- a/studio/src/app/client/[[...driver]]/page-client.tsx +++ b/studio/src/app/client/[[...driver]]/page-client.tsx @@ -1,17 +1,16 @@ "use client"; import TursoDriver from "@studio/drivers/turso-driver"; -import { useCallback, useMemo } from "react"; +import { useMemo } from "react"; import { SavedConnectionItemConfigConfig, SupportedDriver, } from "../../connect/saved-connection-storage"; import RqliteDriver from "@studio/drivers/rqlite-driver"; import ValtownDriver from "@studio/drivers/valtown-driver"; -import { Studio } from "@libsqlstudio/gui"; -import { useRouter } from "next/navigation"; + +import MyStudio from "@studio/components/my-studio"; export default function ClientPageBody() { - const router = useRouter(); const driver = useMemo(() => { const config: SavedConnectionItemConfigConfig & { driver: SupportedDriver; @@ -25,11 +24,5 @@ export default function ClientPageBody() { return new TursoDriver(config.url, config.token as string, true); }, []); - const goBack = useCallback(() => { - router.push("/connect"); - }, [router]); - - return ( - - ); + return ; } diff --git a/studio/src/app/client/layout.tsx b/studio/src/app/client/layout.tsx new file mode 100644 index 00000000..c283e7a3 --- /dev/null +++ b/studio/src/app/client/layout.tsx @@ -0,0 +1,10 @@ +import "@libsqlstudio/gui/css"; +import { Fragment } from "react"; + +export default async function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { + return {children}; +} diff --git a/studio/src/app/client/r/page-client.tsx b/studio/src/app/client/r/page-client.tsx index e7ec4d53..7febf5b9 100644 --- a/studio/src/app/client/r/page-client.tsx +++ b/studio/src/app/client/r/page-client.tsx @@ -1,12 +1,10 @@ "use client"; - import { SavedConnectionItem } from "@studio/app/connect/saved-connection-storage"; -import { useTheme } from "@studio/context/theme-provider"; import CollaborationDriver from "@studio/drivers/collaboration-driver"; import RemoteDriver from "@studio/drivers/remote-driver"; -import { Studio } from "@libsqlstudio/gui"; -import { useRouter, useSearchParams } from "next/navigation"; -import { useCallback, useMemo } from "react"; +import { useSearchParams } from "next/navigation"; +import { useMemo } from "react"; +import MyStudio from "@studio/components/my-studio"; export default function ClientPageBody({ token, @@ -15,9 +13,7 @@ export default function ClientPageBody({ token: string; config: SavedConnectionItem; }>) { - const { theme } = useTheme(); const params = useSearchParams(); - const router = useRouter(); const { driver, collaborator } = useMemo(() => { const databaseId = params.get("p"); @@ -29,22 +25,16 @@ export default function ClientPageBody({ }; }, [params, token]); - const goBack = useCallback(() => { - router.push("/connect"); - }, [router]); - if (!driver) { return
Something wrong
; } return ( - ); } diff --git a/studio/src/app/client/s/[[...driver]]/page-client.tsx b/studio/src/app/client/s/[[...driver]]/page-client.tsx index 3309de01..6ed00596 100644 --- a/studio/src/app/client/s/[[...driver]]/page-client.tsx +++ b/studio/src/app/client/s/[[...driver]]/page-client.tsx @@ -1,20 +1,13 @@ "use client"; - import { SavedConnectionLocalStorage } from "@studio/app/connect/saved-connection-storage"; import RqliteDriver from "@studio/drivers/rqlite-driver"; import TursoDriver from "@studio/drivers/turso-driver"; import ValtownDriver from "@studio/drivers/valtown-driver"; -import { Studio } from "@libsqlstudio/gui"; -import { useRouter, useSearchParams } from "next/navigation"; -import { useCallback, useMemo } from "react"; - -// TODO: might have a way to include this in the Studio component -import "@libsqlstudio/gui/css"; -import { useTheme } from "@studio/context/theme-provider"; +import { useSearchParams } from "next/navigation"; +import { useMemo } from "react"; +import MyStudio from "@studio/components/my-studio"; export default function ClientPageBody() { - const { theme } = useTheme(); - const router = useRouter(); const params = useSearchParams(); const conn = useMemo(() => { const connectionParams = params.get("p"); @@ -39,21 +32,11 @@ export default function ClientPageBody() { return new TursoDriver(conn.config.url, conn.config.token, true); }, [conn]); - const goBack = useCallback(() => { - router.push("/connect"); - }, [router]); - if (!driver || !conn) { return
Something wrong
; } return ( - + ); } diff --git a/studio/src/components/my-studio.tsx b/studio/src/components/my-studio.tsx new file mode 100644 index 00000000..8efa5658 --- /dev/null +++ b/studio/src/components/my-studio.tsx @@ -0,0 +1,68 @@ +import { BaseDriver, CollaborationDriver } from "@libsqlstudio/gui/driver"; +import { Studio } from "@libsqlstudio/gui"; +import { useTheme } from "@studio/context/theme-provider"; +import { useRouter } from "next/navigation"; +import { useCallback, useMemo } from "react"; + +interface MyStudioProps { + name: string; + color: string; + driver: BaseDriver; + collabarator?: CollaborationDriver; +} + +export default function MyStudio({ + name, + color, + driver, + collabarator, +}: MyStudioProps) { + const router = useRouter(); + const { theme } = useTheme(); + + const goBack = useCallback(() => { + router.push("/connect"); + }, [router]); + + const sideBanner = useMemo(() => { + return ( +
+ LibStudio Studio is open-source database GUI. + +
+ ); + }, []); + + return ( + + ); +}