mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +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*
|
**/*/vite.config.ts.timestamp*
|
||||||
.history
|
.history
|
||||||
**/*/.db/*
|
**/*/.db/*
|
||||||
|
**/*/*.db-shm
|
||||||
|
**/*/*.db-wal
|
||||||
.npmrc
|
.npmrc
|
||||||
/.verdaccio
|
/.verdaccio
|
||||||
.idea
|
.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 { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||||
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
||||||
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
||||||
@@ -8,9 +8,7 @@ import { SqliteConnection } from "./SqliteConnection";
|
|||||||
import { SqliteIntrospector } from "./SqliteIntrospector";
|
import { SqliteIntrospector } from "./SqliteIntrospector";
|
||||||
|
|
||||||
export const LIBSQL_PROTOCOLS = ["wss", "https", "libsql"] as const;
|
export const LIBSQL_PROTOCOLS = ["wss", "https", "libsql"] as const;
|
||||||
export type LibSqlCredentials = {
|
export type LibSqlCredentials = Config & {
|
||||||
url: string;
|
|
||||||
authToken?: string;
|
|
||||||
protocol?: (typeof LIBSQL_PROTOCOLS)[number];
|
protocol?: (typeof LIBSQL_PROTOCOLS)[number];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ export {
|
|||||||
type ModuleSchemas
|
type ModuleSchemas
|
||||||
} from "modules/ModuleManager";
|
} from "modules/ModuleManager";
|
||||||
|
|
||||||
export * from "./adapter";
|
export type * from "./adapter";
|
||||||
export { Api, type ApiOptions } from "./Api";
|
export { Api, type ApiOptions } from "./Api";
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { MantineProvider } from "@mantine/core";
|
|||||||
import { Notifications } from "@mantine/notifications";
|
import { Notifications } from "@mantine/notifications";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FlashMessage } from "ui/modules/server/FlashMessage";
|
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 { createMantineTheme } from "./lib/mantine/theme";
|
||||||
import { BkndModalsProvider } from "./modals";
|
import { BkndModalsProvider } from "./modals";
|
||||||
import { Routes } from "./routes";
|
import { Routes } from "./routes";
|
||||||
|
|
||||||
export type BkndAdminProps = {
|
export type BkndAdminProps = {
|
||||||
baseUrl?: string;
|
baseUrl?: string;
|
||||||
withProvider?: boolean;
|
withProvider?: boolean | ClientProviderProps;
|
||||||
// @todo: add admin config override
|
// @todo: add admin config override
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,7 +20,12 @@ export default function Admin({ baseUrl: baseUrlOverride, withProvider = false }
|
|||||||
</BkndProvider>
|
</BkndProvider>
|
||||||
);
|
);
|
||||||
return withProvider ? (
|
return withProvider ? (
|
||||||
<ClientProvider baseUrl={baseUrlOverride}>{Component}</ClientProvider>
|
<ClientProvider
|
||||||
|
baseUrl={baseUrlOverride}
|
||||||
|
{...(typeof withProvider === "object" ? withProvider : {})}
|
||||||
|
>
|
||||||
|
{Component}
|
||||||
|
</ClientProvider>
|
||||||
) : (
|
) : (
|
||||||
Component
|
Component
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ export const queryClient = new QueryClient({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ClientProvider = ({
|
export type ClientProviderProps = {
|
||||||
children,
|
children?: any;
|
||||||
baseUrl,
|
baseUrl?: string;
|
||||||
user
|
user?: TApiUser | null | undefined;
|
||||||
}: { children?: any; baseUrl?: string; user?: TApiUser | null }) => {
|
};
|
||||||
|
|
||||||
|
export const ClientProvider = ({ children, baseUrl, user }: ClientProviderProps) => {
|
||||||
const [actualBaseUrl, setActualBaseUrl] = useState<string | null>(null);
|
const [actualBaseUrl, setActualBaseUrl] = useState<string | null>(null);
|
||||||
const winCtx = useBkndWindowContext();
|
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 { BkndProvider, useBknd } from "./BkndProvider";
|
||||||
|
|
||||||
export { useAuth } from "./schema/auth/use-auth";
|
export { useAuth } from "./schema/auth/use-auth";
|
||||||
|
|||||||
Binary file not shown.
@@ -12,9 +12,11 @@ const config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
serve(config, {
|
serve(config, {
|
||||||
relativeDistPath: "../../node_modules/bknd/dist",
|
|
||||||
port: 1337,
|
port: 1337,
|
||||||
listener: ({ port }) => {
|
listener: ({ port }) => {
|
||||||
console.log(`Server is running on http://localhost:${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