mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
prepare admin for astro: inject clientprovider props directly from admin component
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -17,6 +17,8 @@ packages/media/.env
|
||||
**/*/vite.config.ts.timestamp*
|
||||
.history
|
||||
**/*/.db/*
|
||||
**/*/*.db-shm
|
||||
**/*/*.db-wal
|
||||
.npmrc
|
||||
/.verdaccio
|
||||
.idea
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Client, type InStatement, createClient } from "@libsql/client/web";
|
||||
import { type Client, type Config, type InStatement, createClient } from "@libsql/client/web";
|
||||
import { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
||||
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
||||
@@ -8,9 +8,7 @@ import { SqliteConnection } from "./SqliteConnection";
|
||||
import { SqliteIntrospector } from "./SqliteIntrospector";
|
||||
|
||||
export const LIBSQL_PROTOCOLS = ["wss", "https", "libsql"] as const;
|
||||
export type LibSqlCredentials = {
|
||||
url: string;
|
||||
authToken?: string;
|
||||
export type LibSqlCredentials = Config & {
|
||||
protocol?: (typeof LIBSQL_PROTOCOLS)[number];
|
||||
};
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ export {
|
||||
type ModuleSchemas
|
||||
} from "modules/ModuleManager";
|
||||
|
||||
export * from "./adapter";
|
||||
export type * from "./adapter";
|
||||
export { Api, type ApiOptions } from "./Api";
|
||||
|
||||
@@ -2,14 +2,14 @@ import { MantineProvider } from "@mantine/core";
|
||||
import { Notifications } from "@mantine/notifications";
|
||||
import React from "react";
|
||||
import { FlashMessage } from "ui/modules/server/FlashMessage";
|
||||
import { BkndProvider, ClientProvider, useBknd } from "./client";
|
||||
import { BkndProvider, ClientProvider, type ClientProviderProps, useBknd } from "./client";
|
||||
import { createMantineTheme } from "./lib/mantine/theme";
|
||||
import { BkndModalsProvider } from "./modals";
|
||||
import { Routes } from "./routes";
|
||||
|
||||
export type BkndAdminProps = {
|
||||
baseUrl?: string;
|
||||
withProvider?: boolean;
|
||||
withProvider?: boolean | ClientProviderProps;
|
||||
// @todo: add admin config override
|
||||
};
|
||||
|
||||
@@ -20,7 +20,12 @@ export default function Admin({ baseUrl: baseUrlOverride, withProvider = false }
|
||||
</BkndProvider>
|
||||
);
|
||||
return withProvider ? (
|
||||
<ClientProvider baseUrl={baseUrlOverride}>{Component}</ClientProvider>
|
||||
<ClientProvider
|
||||
baseUrl={baseUrlOverride}
|
||||
{...(typeof withProvider === "object" ? withProvider : {})}
|
||||
>
|
||||
{Component}
|
||||
</ClientProvider>
|
||||
) : (
|
||||
Component
|
||||
);
|
||||
|
||||
@@ -17,11 +17,13 @@ export const queryClient = new QueryClient({
|
||||
}
|
||||
});
|
||||
|
||||
export const ClientProvider = ({
|
||||
children,
|
||||
baseUrl,
|
||||
user
|
||||
}: { children?: any; baseUrl?: string; user?: TApiUser | null }) => {
|
||||
export type ClientProviderProps = {
|
||||
children?: any;
|
||||
baseUrl?: string;
|
||||
user?: TApiUser | null | undefined;
|
||||
};
|
||||
|
||||
export const ClientProvider = ({ children, baseUrl, user }: ClientProviderProps) => {
|
||||
const [actualBaseUrl, setActualBaseUrl] = useState<string | null>(null);
|
||||
const winCtx = useBkndWindowContext();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { ClientProvider, useClient, useBaseUrl } from "./ClientProvider";
|
||||
export { ClientProvider, type ClientProviderProps, useClient, useBaseUrl } from "./ClientProvider";
|
||||
export { BkndProvider, useBknd } from "./BkndProvider";
|
||||
|
||||
export { useAuth } from "./schema/auth/use-auth";
|
||||
|
||||
Binary file not shown.
@@ -12,9 +12,11 @@ const config = {
|
||||
};
|
||||
|
||||
serve(config, {
|
||||
relativeDistPath: "../../node_modules/bknd/dist",
|
||||
port: 1337,
|
||||
listener: ({ port }) => {
|
||||
console.log(`Server is running on http://localhost:${port}`);
|
||||
}
|
||||
},
|
||||
// this is only required to run inside the same workspace
|
||||
// leave blank if you're running this from a different project
|
||||
relativeDistPath: "../../app/dist"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user