@flanksource/clicky-ui
Version:
Flanksource Clicky UI — React component library built on shadcn/ui with light/dark and density theming.
52 lines (51 loc) • 2.05 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { parseClickyData, Clicky } from "../data/Clicky.js";
import { cn } from "../lib/utils.js";
import { parseJsonBody } from "./classify.js";
function ExecutionResult({
response,
emptyMessage = "No response yet.",
ariaLabel = "Response body",
className,
commandRuntime,
onTableRowClick,
getTableRowHref,
isTableRowClickable
}) {
if (!response) {
return /* @__PURE__ */ jsx("p", { className: cn("mt-3 text-sm text-muted-foreground", className), children: emptyMessage });
}
const rawText = response.stdout || response.output || response.message || "";
const parsedPayload = response.parsed ?? parseJsonBody(response);
const clickyPayload = typeof parsedPayload === "string" || parsedPayload != null && typeof parsedPayload === "object" ? parsedPayload : rawText;
const parsedClicky = clickyPayload === "" ? null : parseClickyData(clickyPayload);
if (parsedClicky == null ? void 0 : parsedClicky.ok) {
return /* @__PURE__ */ jsx("div", { role: "region", "aria-label": ariaLabel, className: cn("mt-3", className), children: /* @__PURE__ */ jsx(
Clicky,
{
data: parsedClicky.document,
...response.requestUrl ? { url: response.requestUrl } : {},
...commandRuntime ? { commandRuntime } : {},
...onTableRowClick ? { onTableRowClick } : {},
...getTableRowHref ? { getTableRowHref } : {},
...isTableRowClickable ? { isTableRowClickable } : {}
}
) });
}
const renderedText = parsedPayload != null ? JSON.stringify(parsedPayload, null, 2) : rawText;
if (!renderedText) {
return /* @__PURE__ */ jsx("p", { className: cn("mt-3 text-sm text-muted-foreground", className), children: "Response completed with no body." });
}
return /* @__PURE__ */ jsx(
"pre",
{
"aria-label": ariaLabel,
className: cn("mt-3 overflow-auto rounded-md bg-muted p-4 text-xs", className),
children: renderedText
}
);
}
export {
ExecutionResult
};
//# sourceMappingURL=ExecutionResult.js.map