🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
refactor(web): Migrate web callout settings table to design system (#17933)
Ben Bachemc3deae3a4e83
diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsxindex 861f4c01ee..ab53a88af8 100644--- a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx+++ b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx@@ -1,35 +1,22 @@-/* eslint-disable no-nested-ternary */import { showErrorToast, showSuccessToast } from "@/src/features/notifications";import { zodResolver } from "@hookform/resolvers/zod";-import { Pencil, Plus, Trash2, Webhook, X } from "lucide-react";-import {- type ReactNode,- useCallback,- useEffect,- useMemo,- useState,-} from "react";+import { Plus, Webhook, X } from "lucide-react";+import { useState } from "react";import { useFieldArray, useForm } from "react-hook-form";import { z } from "zod";import { ActionButton } from "@/src/components/ActionButton";-import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";-import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";-import { SimpleDataTable } from "@/src/components/table/simple-data-table";-import { type LangfuseColumnDef } from "@/src/components/table/types";+import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Alert } from "@/src/components/design-system/Alert/Alert";import { Button } from "@/src/components/ui/button";import { Card } from "@/src/components/ui/card";import {- Dialog,DialogBody,DialogContent,DialogDescription,DialogFooter,DialogHeader,DialogTitle,- DialogTrigger,} from "@/src/components/ui/dialog";import {Form,@@ -53,6 +40,7 @@ import {WEB_CALLOUT_HEADER_NAME_PATTERN,} from "@/src/features/web-callouts/headerRules";import { api, type RouterOutputs } from "@/src/utils/api";+import { ConnectedWebCalloutSettingsTable } from "./WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable";type WebCalloutEndpoint = RouterOutputs["webCallouts"]["all"][number];@@ -113,113 +101,13 @@ const webCalloutFormSchema = ztype WebCalloutFormValues = z.infer<typeof webCalloutFormSchema>;export function WebCalloutSettingsPage(props: { projectId: string }) {- const [dialogOpen, setDialogOpen] = useState(false);- const [editingEndpoint, setEditingEndpoint] =- useState<WebCalloutEndpoint | null>(null);+ const [formKey, setFormKey] = useState(0);const hasAccess = useHasProjectAccess({projectId: props.projectId,scope: "integrations:CRUD",});- const endpoints = api.webCallouts.all.useQuery(- { projectId: props.projectId },- { enabled: hasAccess },- );-- const configuredEndpoint = endpoints.data?.[0];- const canCreateEndpoint = !configuredEndpoint;- const addEndpointDisabledReason = endpoints.isLoading- ? "Loading callout endpoint configuration."- : endpoints.isError- ? "Could not load the callout endpoint configuration."- : !canCreateEndpoint- ? "Currently you can only create one callout per project."- : undefined;-- const openCreateDialog = () => {- setEditingEndpoint(null);- setDialogOpen(true);- };-- const openEditDialog = useCallback((endpoint: WebCalloutEndpoint) => {- setEditingEndpoint(endpoint);- setDialogOpen(true);- }, []);-- const columns = useMemo<LangfuseColumnDef<WebCalloutEndpoint>[]>(- () => [- createTextTableColumn<WebCalloutEndpoint>({- accessorKey: "name",- header: "Name",- }),- {- accessorKey: "url",- header: "Endpoint",- size: 576,- cell: ({ getValue }) => {- const url = getValue<string>();- return (- <span className="font-mono break-all" title={url}>- {url}- </span>- );- },- },- {- accessorKey: "toastMessage",- header: "Toast Message",- cell: ({ row }) => <ToastMessageCell endpoint={row.original} />,- },- {- accessorKey: "requestHeaderKeys",- header: "Headers",- cell: ({ row }) => <HeaderList endpoint={row.original} />,- },- createStatusTableColumn<WebCalloutEndpoint, boolean>({- accessorKey: "enabled",- header: "Status",- getStatus: (enabled) => (enabled ? "active" : "disabled"),- }),- {- accessorKey: "id",- header: "",- cell: ({ row }) => (- <div className="flex justify-end gap-1">- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="ghost"- size="icon"- onClick={() => openEditDialog(row.original)}- >- <Pencil className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>Edit endpoint</TooltipContent>- </Tooltip>- <DeleteEndpointDialogController- projectId={props.projectId}- endpoint={row.original}- >- {({ openDialog }) => (- <Tooltip>- <TooltipTrigger asChild>- <Button variant="ghost" size="icon" onClick={openDialog}>- <Trash2 className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>Delete endpoint</TooltipContent>- </Tooltip>- )}- </DeleteEndpointDialogController>- </div>- ),- },- ],- [openEditDialog, props.projectId],- );-if (!hasAccess) {return (<div>@@ -250,96 +138,30 @@ export function WebCalloutSettingsPage(props: { projectId: string }) {for more info.</p>- <div className="mb-4 flex justify-end">- <WebCalloutEndpointDialog- projectId={props.projectId}- endpoint={editingEndpoint}- open={dialogOpen}- onOpenChange={(open) => {- setDialogOpen(open);- if (!open) {- setEditingEndpoint(null);- }- }}- trigger={- <AddEndpointButton- disabledReason={addEndpointDisabledReason}- onClick={openCreateDialog}- />- }- />- </div>-- <Card className="overflow-auto">- <SimpleDataTable- columns={columns}- data={endpoints.data ?? []}- isLoading={endpoints.isLoading}- noResults={- endpoints.isError ? (- <span className="text-destructive">- Failed to load the callout endpoint. Please try again.- </span>- ) : (- <span className="text-muted-foreground">- No callout endpoint configured.- </span>- )- }- />- </Card>- </div>- );-}--function AddEndpointButton(props: {- disabledReason?: string;- onClick: () => void;-}) {- const button = (- <Button- disabled={Boolean(props.disabledReason)}- className={props.disabledReason ? "pointer-events-none" : undefined}- onClick={props.onClick}- >- <Plus className="mr-1 h-4 w-4" />- Add endpoint- </Button>- );-- if (!props.disabledReason) {- return <DialogTrigger asChild>{button}</DialogTrigger>;- }-- return (- <Tooltip>- <TooltipTrigger asChild>- <span className="inline-flex cursor-not-allowed">{button}</span>- </TooltipTrigger>- <TooltipContent>{props.disabledReason}</TooltipContent>- </Tooltip>- );-}--function HeaderList(props: { endpoint: WebCalloutEndpoint }) {- const headers = props.endpoint.requestHeaderKeys;-- if (headers.length === 0) {- return <span className="text-muted-foreground">None</span>;- }-- return (- <span className="font-mono text-sm break-words">{headers.join(", ")}</span>- );-}--function ToastMessageCell(props: { endpoint: WebCalloutEndpoint }) {- return (- <div- className="max-w-xs truncate text-sm"- title={props.endpoint.toastMessage}- >- {props.endpoint.toastMessage}+ <DialogController<{ endpoint: WebCalloutEndpoint | null }>+ renderDialog={({ state, closeDialog }) => (+ <WebCalloutEndpointDialog+ key={formKey}+ projectId={props.projectId}+ endpoint={state.endpoint}+ closeDialog={closeDialog}+ />+ )}+ >+ {({ openDialog }) => (+ <ConnectedWebCalloutSettingsTable+ projectId={props.projectId}+ onCreate={() => {+ setFormKey((key) => key + 1);+ openDialog({ endpoint: null });+ }}+ onEdit={(endpoint) => {+ setFormKey((key) => key + 1);+ openDialog({ endpoint });+ }}+ />+ )}+ </DialogController></div>);}@@ -347,9 +169,7 @@ function ToastMessageCell(props: { endpoint: WebCalloutEndpoint }) {function WebCalloutEndpointDialog(props: {projectId: string;endpoint: WebCalloutEndpoint | null;- open: boolean;- onOpenChange: (open: boolean) => void;- trigger: ReactNode;+ closeDialog: () => void;}) {const utils = api.useUtils();const upsertMutation = api.webCallouts.upsert.useMutation({@@ -361,7 +181,7 @@ function WebCalloutEndpointDialog(props: {: "Callout endpoint created",description: "Web callout configuration was saved.",});- props.onOpenChange(false);+ props.closeDialog();},onError: (error) => {showErrorToast("Failed to save callout endpoint", error.message);@@ -378,12 +198,6 @@ function WebCalloutEndpointDialog(props: {name: "headers",});- useEffect(() => {- if (props.open) {- form.reset(endpointToFormValues(props.endpoint));- }- }, [form, props.endpoint, props.open]);-const onSubmit = (values: WebCalloutFormValues) => {upsertMutation.mutate({projectId: props.projectId,@@ -397,250 +211,203 @@ function WebCalloutEndpointDialog(props: {};return (- <Dialog open={props.open} onOpenChange={props.onOpenChange}>- {props.trigger}- <DialogContent size="lg">- <DialogHeader>- <DialogTitle>- {props.endpoint ? "Edit Callout Endpoint" : "Add Callout Endpoint"}- </DialogTitle>- <DialogDescription>- Langfuse sends a backend JSON POST when a user clicks a web callout- action.{" "}- <a- href="https://langfuse.com/docs/observability/features/web-callouts"- target="_blank"- rel="noreferrer"- className="underline underline-offset-2"- >- View docs- </a>- .- </DialogDescription>- </DialogHeader>-- <Form {...form}>- <form- onSubmit={form.handleSubmit(onSubmit)}- className="flex min-h-0 flex-1 flex-col overflow-hidden"+ <DialogContent size="lg">+ <DialogHeader>+ <DialogTitle>+ {props.endpoint ? "Edit Callout Endpoint" : "Add Callout Endpoint"}+ </DialogTitle>+ <DialogDescription>+ Langfuse sends a backend JSON POST when a user clicks a web callout+ action.{" "}+ <a+ href="https://langfuse.com/docs/observability/features/web-callouts"+ target="_blank"+ rel="noreferrer"+ className="underline underline-offset-2">- <DialogBody className="min-h-0">- <FormField- control={form.control}- name="name"- render={({ field }) => (- <FormItem>- <FormLabel>Name</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- <FormField- control={form.control}- name="url"- render={({ field }) => (- <FormItem>- <FormLabel>Endpoint URL</FormLabel>- <FormControl>- <Input- placeholder="https://example.com/langfuse/callout"- {...field}- />- </FormControl>+ View docs+ </a>+ .+ </DialogDescription>+ </DialogHeader>++ <Form {...form}>+ <form+ onSubmit={form.handleSubmit(onSubmit)}+ className="flex min-h-0 flex-1 flex-col overflow-hidden"+ >+ <DialogBody className="min-h-0">+ <FormField+ control={form.control}+ name="name"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Name</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="url"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Endpoint URL</FormLabel>+ <FormControl>+ <Input+ placeholder="https://example.com/langfuse/callout"+ {...field}+ />+ </FormControl>+ <FormDescription>+ HTTP or HTTPS URL. Custom ports are allowed. The endpoint is+ called from the Langfuse backend.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="enabled"+ render={({ field }) => (+ <FormItem className="flex items-center justify-between rounded-md border p-3">+ <div>+ <FormLabel>Enabled</FormLabel><FormDescription>- HTTP or HTTPS URL. Custom ports are allowed. The endpoint- is called from the Langfuse backend.+ Shows the callout action in trace, observation, and+ session detail headers.</FormDescription>- <FormMessage />- </FormItem>- )}- />-- <FormField- control={form.control}- name="enabled"- render={({ field }) => (- <FormItem className="flex items-center justify-between rounded-md border p-3">- <div>- <FormLabel>Enabled</FormLabel>- <FormDescription>- Shows the callout action in trace, observation, and- session detail headers.- </FormDescription>- </div>- <FormControl>- <Switch- checked={field.value}- onCheckedChange={field.onChange}+ </div>+ <FormControl>+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ />+ </FormControl>+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="toastMessage"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Toast message</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormDescription>+ Shown after the backend callout succeeds.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />++ <div>+ <FormLabel>Headers</FormLabel>+ <FormDescription className="mb-2">+ Optional headers added to the backend POST. Content-Type is set+ automatically. Leave values empty for existing header names to+ keep encrypted values.+ </FormDescription>+ <div className="space-y-2">+ {fields.map((field, index) => {+ const currentHeaderName = form.watch(`headers.${index}.name`);+ const preservesExistingValue = hasExistingHeaderName(+ props.endpoint,+ currentHeaderName,+ );++ return (+ <div+ key={field.id}+ className="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-start gap-2"+ >+ <FormField+ control={form.control}+ name={`headers.${index}.name`}+ render={({ field }) => (+ <FormItem>+ <FormControl>+ <Input placeholder="Header name" {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}/>- </FormControl>- </FormItem>- )}- />-- <FormField- control={form.control}- name="toastMessage"- render={({ field }) => (- <FormItem>- <FormLabel>Toast message</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormDescription>- Shown after the backend callout succeeds.- </FormDescription>- <FormMessage />- </FormItem>- )}- />-- <div>- <FormLabel>Headers</FormLabel>- <FormDescription className="mb-2">- Optional headers added to the backend POST. Content-Type is- set automatically. Leave values empty for existing header- names to keep encrypted values.- </FormDescription>- <div className="space-y-2">- {fields.map((field, index) => {- const currentHeaderName = form.watch(- `headers.${index}.name`,- );- const preservesExistingValue = hasExistingHeaderName(- props.endpoint,- currentHeaderName,- );-- return (- <div- key={field.id}- className="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-start gap-2"- >- <FormField- control={form.control}- name={`headers.${index}.name`}- render={({ field }) => (- <FormItem>- <FormControl>- <Input placeholder="Header name" {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- <FormField- control={form.control}- name={`headers.${index}.value`}- render={({ field }) => (- <FormItem>- <FormControl>- <Input- placeholder={- preservesExistingValue- ? "***"- : "Header value"- }- type="password"- {...field}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />- <Tooltip>- <TooltipTrigger asChild>- <Button- type="button"- variant="ghost"- size="icon"- onClick={() => remove(index)}- >- <X className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>Remove header</TooltipContent>- </Tooltip>- </div>- );- })}- </div>- <Button- type="button"- variant="outline"- className="mt-2"- onClick={() =>- append({- name: "",- value: "",- })- }- >- <Plus className="mr-1 h-4 w-4" />- Add header- </Button>+ <FormField+ control={form.control}+ name={`headers.${index}.value`}+ render={({ field }) => (+ <FormItem>+ <FormControl>+ <Input+ placeholder={+ preservesExistingValue+ ? "***"+ : "Header value"+ }+ type="password"+ {...field}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => remove(index)}+ >+ <X className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>Remove header</TooltipContent>+ </Tooltip>+ </div>+ );+ })}</div>- </DialogBody>-- <DialogFooter><Buttontype="button"- variant="ghost"- onClick={() => props.onOpenChange(false)}+ variant="outline"+ className="mt-2"+ onClick={() =>+ append({+ name: "",+ value: "",+ })+ }>- Cancel+ <Plus className="mr-1 h-4 w-4" />+ Add header</Button>- <Button type="submit" loading={upsertMutation.isPending}>- Save endpoint- </Button>- </DialogFooter>- </form>- </Form>- </DialogContent>- </Dialog>- );-}--function DeleteEndpointDialogController(props: {- projectId: string;- endpoint: WebCalloutEndpoint;- children: (control: { openDialog: () => void }) => ReactNode;-}) {- const utils = api.useUtils();- const deleteMutation = api.webCallouts.delete.useMutation({- onSuccess: async () => {- await utils.webCallouts.invalidate();- showSuccessToast({- title: "Callout endpoint deleted",- description: "The endpoint was removed from this project.",- });- },- onError: (error) => {- showErrorToast("Failed to delete callout endpoint", error.message);- },- });-- return (- <ConfirmationDialogController- title="Delete Callout Endpoint"- text="This removes the configured endpoint and hides the web callout action."- confirmLabel="Delete endpoint"- variant="destructive"- loading={deleteMutation.isPending}- onConfirm={() =>- deleteMutation.mutateAsync({- projectId: props.projectId,- id: props.endpoint.id,- })- }- >- {props.children}- </ConfirmationDialogController>+ </div>+ </DialogBody>++ <DialogFooter>+ <Button type="button" variant="ghost" onClick={props.closeDialog}>+ Cancel+ </Button>+ <Button type="submit" loading={upsertMutation.isPending}>+ Save endpoint+ </Button>+ </DialogFooter>+ </form>+ </Form>+ </DialogContent>);}diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsxnew file mode 100644index 0000000000..51df903d7c--- /dev/null+++ b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx@@ -0,0 +1,82 @@+import { useMemo } from "react";++import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";+import { type AsyncTableData } from "@/src/components/design-system/table/Table";+import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { api } from "@/src/utils/api";+import {+ WebCalloutSettingsTable,+ type WebCalloutEndpoint,+} from "./WebCalloutSettingsTable";++export function ConnectedWebCalloutSettingsTable({+ projectId,+ onCreate,+ onEdit,+}: {+ projectId: string;+ onCreate: () => void;+ onEdit: (endpoint: WebCalloutEndpoint) => void;+}) {+ const utils = api.useUtils();+ const endpoints = api.webCallouts.all.useQuery({ projectId });+ const deleteMutation = api.webCallouts.delete.useMutation({+ onSuccess: async () => {+ await utils.webCallouts.invalidate();+ showSuccessToast({+ title: "Callout endpoint deleted",+ description: "The endpoint was removed from this project.",+ });+ },+ onError: (error) => {+ showErrorToast("Failed to delete callout endpoint", error.message);+ },+ });++ const data = useMemo<AsyncTableData<WebCalloutEndpoint[]>>(() => {+ if (endpoints.isLoading) return { status: "loading" };+ if (endpoints.isError) {+ return {+ status: "error",+ error: "Failed to load the callout endpoint. Please try again.",+ };+ }+ return { status: "success", data: endpoints.data ?? [] };+ }, [endpoints.data, endpoints.isError, endpoints.isLoading]);++ const disabledReason = useMemo(() => {+ if (endpoints.isLoading) {+ return "Loading callout endpoint configuration.";+ }+ if (endpoints.isError) {+ return "Could not load the callout endpoint configuration.";+ }+ if (endpoints.data?.length) {+ return "Currently you can only create one callout per project.";+ }+ return undefined;+ }, [endpoints.data, endpoints.isError, endpoints.isLoading]);++ return (+ <ConfirmationDialogController<WebCalloutEndpoint>+ title="Delete Callout Endpoint"+ text="This removes the configured endpoint and hides the web callout action."+ confirmLabel="Delete endpoint"+ variant="destructive"+ loading={deleteMutation.isPending}+ onConfirm={(endpoint) =>+ deleteMutation.mutateAsync({ projectId, id: endpoint.id })+ }+ >+ {({ openDialog }) => (+ <WebCalloutSettingsTable+ data={data}+ noResultsMessage="No callout endpoint configured."+ createAction={{ disabledReason, onClick: onCreate }}+ onEdit={onEdit}+ onDelete={openDialog}+ />+ )}+ </ConfirmationDialogController>+ );+}diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.stories.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.stories.tsxnew file mode 100644index 0000000000..555a9180ec--- /dev/null+++ b/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.stories.tsx@@ -0,0 +1,53 @@+import { fn } from "storybook/test";++import preview from "../../../../../.storybook/preview";+import {+ WebCalloutSettingsTable,+ type WebCalloutEndpoint,+} from "./WebCalloutSettingsTable";++const meta = preview.meta({ component: WebCalloutSettingsTable });++const endpoint = {+ id: "endpoint-1",+ projectId: "project-1",+ name: "Deploy",+ url: "https://example.com/callout",+ enabled: true,+ toastMessage: "Deployment started",+ requestHeaderKeys: ["Authorization"],+ createdAt: new Date("2026-09-01"),+ updatedAt: new Date("2026-09-01"),+} satisfies WebCalloutEndpoint;++export const Default = meta.story({+ args: {+ data: { status: "success", data: [endpoint] },+ noResultsMessage: "No callout endpoint configured.",+ createAction: {+ disabledReason: "Currently you can only create one callout per project.",+ onClick: fn(),+ },+ onEdit: fn(),+ onDelete: fn(),+ },+});++export const Empty = meta.story({+ args: {+ ...Default.input.args,+ data: { status: "success", data: [] },+ createAction: { onClick: fn() },+ },+});++export const Loading = meta.story({+ args: {+ ...Default.input.args,+ data: { status: "loading" },+ createAction: {+ disabledReason: "Loading callout endpoint configuration.",+ onClick: fn(),+ },+ },+});diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.tsxnew file mode 100644index 0000000000..5cd8ab3ba9--- /dev/null+++ b/web/src/features/web-callouts/components/WebCalloutSettingsTable/WebCalloutSettingsTable.tsx@@ -0,0 +1,100 @@+import { useCallback, useMemo } from "react";+import { Pencil, Plus, Trash2 } from "lucide-react";++import {+ SettingsTable,+ type SettingsTableProps,+} from "@/src/components/SettingsTable/SettingsTable";+import { type TableProps } from "@/src/components/design-system/table/Table";+import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";+import { type LangfuseColumnDef } from "@/src/components/table/types";+import { type RouterOutputs } from "@/src/utils/api";++export type WebCalloutEndpoint = RouterOutputs["webCallouts"]["all"][number];++export function WebCalloutSettingsTable({+ createAction,+ onEdit,+ onDelete,+ ...tableProps+}: Pick<TableProps<WebCalloutEndpoint>, "data" | "noResultsMessage"> & {+ createAction: { disabledReason?: string; onClick: () => void };+ onEdit: (endpoint: WebCalloutEndpoint) => void;+ onDelete: (endpoint: WebCalloutEndpoint) => void;+}) {+ const columns = useMemo<LangfuseColumnDef<WebCalloutEndpoint>[]>(+ () => [+ createTextTableColumn<WebCalloutEndpoint>({+ accessorKey: "name",+ header: "Name",+ }),+ createTextTableColumn<WebCalloutEndpoint>({+ accessorKey: "url",+ header: "Endpoint",+ size: 576,+ }),+ createTextTableColumn<WebCalloutEndpoint>({+ accessorKey: "toastMessage",+ header: "Toast Message",+ }),+ createTextTableColumn<WebCalloutEndpoint, string[]>({+ accessorKey: "requestHeaderKeys",+ header: "Headers",+ mapValue: (headers) => (headers?.length ? headers.join(", ") : "None"),+ }),+ createStatusTableColumn<WebCalloutEndpoint, boolean>({+ accessorKey: "enabled",+ header: "Status",+ getStatus: (enabled) => (enabled ? "active" : "disabled"),+ }),+ ],+ [],+ );++ const actions = useCallback<+ NonNullable<TableProps<WebCalloutEndpoint>["actions"]>+ >(+ (endpoint) => [+ {+ id: "edit",+ type: "item",+ title: "Edit endpoint",+ icon: Pencil,+ onClick: () => onEdit(endpoint),+ },+ {+ id: "delete",+ type: "item",+ title: "Delete endpoint",+ icon: Trash2,+ variant: "destructive",+ onClick: () => onDelete(endpoint),+ },+ ],+ [onEdit, onDelete],+ );++ const toolbarActions: SettingsTableProps<WebCalloutEndpoint>["toolbarActions"] =+ [+ {+ id: "add-endpoint",+ label: "Add endpoint",+ variant: "secondary",+ icon: <Plus className="size-4" aria-hidden="true" />,+ disabled: Boolean(createAction.disabledReason),+ title: createAction.disabledReason,+ onClick: createAction.onClick,+ },+ ];++ return (+ <SettingsTable+ tableName="Web callout endpoints"+ columns={columns}+ actions={actions}+ toolbarActions={toolbarActions}+ {...tableProps}+ />+ );+}