mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
Merge pull request #191 from bknd-io/feat/admin-add-options-for-static
admin: add options such as logo return path when served static
This commit is contained in:
@@ -16,6 +16,8 @@ export type AdminBkndWindowContext = {
|
|||||||
user?: TApiUser;
|
user?: TApiUser;
|
||||||
logout_route: string;
|
logout_route: string;
|
||||||
admin_basepath: string;
|
admin_basepath: string;
|
||||||
|
logo_return_path?: string;
|
||||||
|
theme?: "dark" | "light" | "system";
|
||||||
};
|
};
|
||||||
|
|
||||||
// @todo: add migration to remove admin path from config
|
// @todo: add migration to remove admin path from config
|
||||||
@@ -26,6 +28,8 @@ export type AdminControllerOptions = {
|
|||||||
html?: string;
|
html?: string;
|
||||||
forceDev?: boolean | { mainPath: string };
|
forceDev?: boolean | { mainPath: string };
|
||||||
debugRerenders?: boolean;
|
debugRerenders?: boolean;
|
||||||
|
theme?: "dark" | "light" | "system";
|
||||||
|
logoReturnPath?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class AdminController extends Controller {
|
export class AdminController extends Controller {
|
||||||
@@ -46,6 +50,8 @@ export class AdminController extends Controller {
|
|||||||
basepath: this._options.basepath ?? "/",
|
basepath: this._options.basepath ?? "/",
|
||||||
adminBasepath: this._options.adminBasepath ?? "",
|
adminBasepath: this._options.adminBasepath ?? "",
|
||||||
assetsPath: this._options.assetsPath ?? config.server.assets_path,
|
assetsPath: this._options.assetsPath ?? config.server.assets_path,
|
||||||
|
theme: this._options.theme ?? "system",
|
||||||
|
logo_return_path: this._options.logoReturnPath ?? "/",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +114,12 @@ export class AdminController extends Controller {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const obj = {
|
const obj: AdminBkndWindowContext = {
|
||||||
user: c.get("auth")?.user,
|
user: c.get("auth")?.user,
|
||||||
logout_route: authRoutes.logout,
|
logout_route: authRoutes.logout,
|
||||||
admin_basepath: this.options.adminBasepath,
|
admin_basepath: this.options.adminBasepath,
|
||||||
|
theme: this.options.theme,
|
||||||
|
logo_return_path: this.options.logoReturnPath,
|
||||||
};
|
};
|
||||||
const html = await this.getHtml(obj);
|
const html = await this.getHtml(obj);
|
||||||
if (!html) {
|
if (!html) {
|
||||||
@@ -172,7 +180,6 @@ export class AdminController extends Controller {
|
|||||||
return this.options.html as string;
|
return this.options.html as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const configs = this.app.modules.configs();
|
|
||||||
const isProd = !isDebug() && !this.options.forceDev;
|
const isProd = !isDebug() && !this.options.forceDev;
|
||||||
const mainPath =
|
const mainPath =
|
||||||
typeof this.options.forceDev === "object" && "mainPath" in this.options.forceDev
|
typeof this.options.forceDev === "object" && "mainPath" in this.options.forceDev
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { BkndProvider, type BkndAdminOptions } from "ui/client/bknd";
|
|||||||
import { useTheme } from "ui/client/use-theme";
|
import { useTheme } from "ui/client/use-theme";
|
||||||
import { Logo } from "ui/components/display/Logo";
|
import { Logo } from "ui/components/display/Logo";
|
||||||
import * as AppShell from "ui/layouts/AppShell/AppShell";
|
import * as AppShell from "ui/layouts/AppShell/AppShell";
|
||||||
import { ClientProvider, type ClientProviderProps } from "./client";
|
import { ClientProvider, useBkndWindowContext, type ClientProviderProps } from "./client";
|
||||||
import { createMantineTheme } from "./lib/mantine/theme";
|
import { createMantineTheme } from "./lib/mantine/theme";
|
||||||
import { Routes } from "./routes";
|
import { Routes } from "./routes";
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export type BkndAdminProps = {
|
|||||||
export default function Admin({
|
export default function Admin({
|
||||||
baseUrl: baseUrlOverride,
|
baseUrl: baseUrlOverride,
|
||||||
withProvider = false,
|
withProvider = false,
|
||||||
config,
|
config: _config = {},
|
||||||
}: BkndAdminProps) {
|
}: BkndAdminProps) {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const Provider = ({ children }: any) =>
|
const Provider = ({ children }: any) =>
|
||||||
@@ -32,6 +32,10 @@ export default function Admin({
|
|||||||
) : (
|
) : (
|
||||||
children
|
children
|
||||||
);
|
);
|
||||||
|
const config = {
|
||||||
|
..._config,
|
||||||
|
...useBkndWindowContext(),
|
||||||
|
};
|
||||||
|
|
||||||
const BkndWrapper = ({ children }: { children: ReactNode }) => (
|
const BkndWrapper = ({ children }: { children: ReactNode }) => (
|
||||||
<BkndProvider options={config} fallback={<Skeleton theme={config?.theme} />}>
|
<BkndProvider options={config} fallback={<Skeleton theme={config?.theme} />}>
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { Message } from "ui/components/display/Message";
|
|||||||
import { useNavigate } from "ui/lib/routes";
|
import { useNavigate } from "ui/lib/routes";
|
||||||
|
|
||||||
export type BkndAdminOptions = {
|
export type BkndAdminOptions = {
|
||||||
logo_return_path?: string;
|
|
||||||
basepath?: string;
|
basepath?: string;
|
||||||
|
logo_return_path?: string;
|
||||||
theme?: AppTheme;
|
theme?: AppTheme;
|
||||||
};
|
};
|
||||||
type BkndContext = {
|
type BkndContext = {
|
||||||
|
|||||||
Reference in New Issue
Block a user