Export template source from 6474fe2323dd3e4aae2e5c53c490f9b5d92f4f3c:quixos-instance/packages/agent-presentation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { LoadPresentation, useCaminoClient } from "@quixos/camino-react";
|
||||
import type { Item } from "./protocol.js";
|
||||
|
||||
export function AgentWidget({ item }: { item: Item }) {
|
||||
const client = useCaminoClient();
|
||||
const record = (value: unknown): Record<string, unknown> | undefined =>
|
||||
value && typeof value === "object" && !Array.isArray(value) ? (value as Record<string, unknown>) : undefined;
|
||||
const selected = client.catalog.presentations.map(record).find((value) => value?.id === item.data.presentation);
|
||||
const subject = item.subject?._camino.ref,
|
||||
mount = item.presentationMount?._camino.ref;
|
||||
if (!subject || !mount || typeof selected?.packageRevision !== "string" || typeof selected.component !== "string")
|
||||
return (
|
||||
<p role="alert">
|
||||
This widget is unavailable.{" "}
|
||||
{subject && <a href={`/entity/${encodeURIComponent(subject.object)}`}>Open object</a>}
|
||||
</p>
|
||||
);
|
||||
return (
|
||||
<LoadPresentation
|
||||
subject={subject}
|
||||
provider={{ packageRevision: selected.packageRevision, id: selected.component }}
|
||||
presentationMount={mount}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user