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:
dswbx
2025-09-16 16:04:09 +02:00
parent 70eaa22327
commit a0b2dde034
6 changed files with 23 additions and 18 deletions

View File

@@ -252,6 +252,8 @@ async function buildAdapters() {
platform: "neutral",
entry: ["src/adapter/index.ts"],
outDir: "dist/adapter",
// only way to keep @vite-ignore comments
minify: false,
}),
// specific adatpers

View File

@@ -98,9 +98,6 @@ export type AppOptions = {
readonly?: boolean;
};
export type CreateAppConfig = {
/**
* bla
*/
connection?: Connection | { url: string };
config?: InitialModuleConfigs;
options?: AppOptions;

View File

@@ -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) {

View File

@@ -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>

View File

@@ -68,11 +68,11 @@ function AuthRolesEditInternal({ params }) {
>
<IconButton Icon={TbDots} />
</Dropdown>
!readonly && (
{!readonly && (
<Button variant="primary" onClick={handleUpdate}>
Update
</Button>
)
)}
</>
}
className="pl-3"

View File

@@ -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