mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix: improve asset handling, logging, and ui conditions
Refactored asset handling to support multiple CSS entries and fixed context handling in authenticator when executed through mcp. Adjusted UI readonly conditions.
This commit is contained in:
@@ -98,9 +98,6 @@ export type AppOptions = {
|
||||
readonly?: boolean;
|
||||
};
|
||||
export type CreateAppConfig = {
|
||||
/**
|
||||
* bla
|
||||
*/
|
||||
connection?: Connection | { url: string };
|
||||
config?: InitialModuleConfigs;
|
||||
options?: AppOptions;
|
||||
|
||||
@@ -278,7 +278,9 @@ export class Authenticator<
|
||||
}
|
||||
|
||||
return payload as any;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
$console.debug("Authenticator jwt verify error", String(e));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -396,8 +398,9 @@ export class Authenticator<
|
||||
if (headers.has("Authorization")) {
|
||||
const bearerHeader = String(headers.get("Authorization"));
|
||||
token = bearerHeader.replace("Bearer ", "");
|
||||
} else if (is_context) {
|
||||
token = await this.getAuthCookie(c as Context);
|
||||
} else {
|
||||
const context = is_context ? (c as Context) : ({ req: { raw: { headers } } } as Context);
|
||||
token = await this.getAuthCookie(context);
|
||||
}
|
||||
|
||||
if (token) {
|
||||
|
||||
@@ -192,7 +192,7 @@ export class AdminController extends Controller {
|
||||
|
||||
const assets = {
|
||||
js: "main.js",
|
||||
css: "styles.css",
|
||||
css: ["styles.css"],
|
||||
};
|
||||
|
||||
if (isProd) {
|
||||
@@ -213,9 +213,12 @@ export class AdminController extends Controller {
|
||||
}
|
||||
|
||||
try {
|
||||
// @todo: load all marked as entry (incl. css)
|
||||
assets.js = manifest["src/ui/main.tsx"]?.file!;
|
||||
assets.css = manifest["src/ui/main.tsx"]?.css?.[0] as any;
|
||||
const entry = Object.values(manifest).find((m) => m.isEntry);
|
||||
if (!entry) {
|
||||
throw new Error("No entry found in manifest");
|
||||
}
|
||||
assets.js = entry?.file;
|
||||
assets.css = entry?.css ?? [];
|
||||
} catch (e) {
|
||||
$console.warn("Couldn't find assets in manifest", e);
|
||||
}
|
||||
@@ -245,7 +248,9 @@ export class AdminController extends Controller {
|
||||
{isProd ? (
|
||||
<Fragment>
|
||||
<script type="module" src={this.options.assetsPath + assets?.js} />
|
||||
<link rel="stylesheet" href={this.options.assetsPath + assets?.css} />
|
||||
{assets?.css.map((css, i) => (
|
||||
<link key={i} rel="stylesheet" href={this.options.assetsPath + css} />
|
||||
))}
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
|
||||
@@ -68,11 +68,11 @@ function AuthRolesEditInternal({ params }) {
|
||||
>
|
||||
<IconButton Icon={TbDots} />
|
||||
</Dropdown>
|
||||
!readonly && (
|
||||
<Button variant="primary" onClick={handleUpdate}>
|
||||
Update
|
||||
</Button>
|
||||
)
|
||||
{!readonly && (
|
||||
<Button variant="primary" onClick={handleUpdate}>
|
||||
Update
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
className="pl-3"
|
||||
|
||||
@@ -169,8 +169,6 @@ function EntityCreateButton({ entity }: { entity: Entity }) {
|
||||
media: b.app.config.media.entity_name,
|
||||
};
|
||||
if (system.users === entity.name) {
|
||||
if (b.readonly) return null;
|
||||
|
||||
return (
|
||||
<Button onClick={createUserModal.open} variant="primary">
|
||||
New User
|
||||
|
||||
Reference in New Issue
Block a user