Refactor renamed the component groups to something less obtuse:
Elements -> Groups -> Screens -> Views
This commit is contained in:
parent
ca6de91a96
commit
dd46acba87
1 changed files with 151 additions and 144 deletions
|
|
@ -1,131 +0,0 @@
|
|||
import { Button, Divider, Group, Stack, Text } from "@mantine/core";
|
||||
import { AnnotationBadge } from "../../atoms/AnnotationBadge/AnnotationBadge";
|
||||
import { ProgressDisplay } from "../../atoms/ProgressDisplay/ProgressDisplay";
|
||||
import { SchemaForm } from "../SchemaForm/SchemaForm";
|
||||
import type { JsonSchema } from "../SchemaForm/SchemaForm";
|
||||
|
||||
export interface ToolAnnotations {
|
||||
audience?: string;
|
||||
readOnly?: boolean;
|
||||
destructive?: boolean;
|
||||
longRunning?: boolean;
|
||||
hints?: string;
|
||||
}
|
||||
|
||||
export interface ToolDetailPanelProps {
|
||||
name: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
annotations?: ToolAnnotations;
|
||||
schema: JsonSchema;
|
||||
formValues: Record<string, unknown>;
|
||||
isExecuting: boolean;
|
||||
progress?: { percent: number; description?: string };
|
||||
onFormChange: (values: Record<string, unknown>) => void;
|
||||
onExecute: () => void;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
const ToolTitle = Text.withProps({
|
||||
fw: 700,
|
||||
size: "lg",
|
||||
truncate: "end",
|
||||
});
|
||||
|
||||
const HintsText = Text.withProps({
|
||||
size: "xs",
|
||||
c: "dimmed",
|
||||
fs: "italic",
|
||||
});
|
||||
|
||||
const DescriptionText = Text.withProps({
|
||||
size: "sm",
|
||||
c: "dimmed",
|
||||
});
|
||||
|
||||
const CancelButton = Button.withProps({
|
||||
variant: "light",
|
||||
color: "red",
|
||||
});
|
||||
|
||||
function resolveTitle(name: string, title?: string): string {
|
||||
return title ?? name;
|
||||
}
|
||||
|
||||
function hasAnyAnnotation(annotations?: ToolAnnotations): boolean {
|
||||
return !!(
|
||||
annotations &&
|
||||
(annotations.audience ||
|
||||
annotations.readOnly ||
|
||||
annotations.destructive ||
|
||||
annotations.longRunning ||
|
||||
annotations.hints)
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolDetailPanel({
|
||||
name,
|
||||
title,
|
||||
description,
|
||||
annotations,
|
||||
schema,
|
||||
formValues,
|
||||
isExecuting,
|
||||
progress,
|
||||
onFormChange,
|
||||
onExecute,
|
||||
onCancel,
|
||||
}: ToolDetailPanelProps) {
|
||||
return (
|
||||
<Stack gap="md" miw={0}>
|
||||
<ToolTitle>{resolveTitle(name, title)}</ToolTitle>
|
||||
{hasAnyAnnotation(annotations) && annotations && (
|
||||
<Group gap="xs">
|
||||
{annotations.audience && (
|
||||
<AnnotationBadge label={annotations.audience} variant="audience" />
|
||||
)}
|
||||
{annotations.readOnly && (
|
||||
<AnnotationBadge label="read-only" variant="readOnly" />
|
||||
)}
|
||||
{annotations.destructive && (
|
||||
<AnnotationBadge label="destructive" variant="destructive" />
|
||||
)}
|
||||
{annotations.longRunning && (
|
||||
<AnnotationBadge label="long-run" variant="longRun" />
|
||||
)}
|
||||
{annotations.hints && <HintsText>{annotations.hints}</HintsText>}
|
||||
</Group>
|
||||
)}
|
||||
|
||||
{description && <DescriptionText>{description}</DescriptionText>}
|
||||
|
||||
<Divider />
|
||||
|
||||
<SchemaForm
|
||||
schema={schema}
|
||||
values={formValues}
|
||||
onChange={onFormChange}
|
||||
disabled={isExecuting}
|
||||
/>
|
||||
|
||||
{progress && (
|
||||
<ProgressDisplay
|
||||
progress={progress.percent}
|
||||
description={progress.description}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Group>
|
||||
<Button
|
||||
fullWidth
|
||||
onClick={onExecute}
|
||||
disabled={isExecuting}
|
||||
loading={isExecuting}
|
||||
>
|
||||
Execute Tool
|
||||
</Button>
|
||||
{isExecuting && <CancelButton onClick={onCancel}>Cancel</CancelButton>}
|
||||
</Group>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue