mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-20 23:21:06 +02:00
refactor(playground): improve API reference and playground runner UI
- Adjusted text formatting in the API reference for better readability. - Simplified import statements in PlaygroundRunner for cleaner code. - Enhanced button styling and layout in PlaygroundRunner for improved user experience. - Streamlined output display logic in PlaygroundRunner for better clarity.
This commit is contained in:
parent
33e685c6ed
commit
53d3b304d3
2 changed files with 9 additions and 20 deletions
|
|
@ -91,12 +91,13 @@ export function ApiReference({
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-base font-semibold">API reference</h2>
|
<h2 className="text-base font-semibold">API reference</h2>
|
||||||
<p className="mt-1 text-sm text-muted-foreground">
|
<p className="mt-1 text-sm text-muted-foreground">
|
||||||
Create an API key, enable API access for this workspace, then use the examples below to call this endpoint.
|
Create an API key, enable API access for this workspace, then use the examples below to
|
||||||
|
call this endpoint.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Tabs defaultValue="curl">
|
<Tabs defaultValue="curl">
|
||||||
<TabsList className="h-auto flex-wrap">
|
<TabsList className="flex h-auto w-full flex-nowrap justify-start overflow-x-auto overflow-y-hidden">
|
||||||
{snippets.map((snippet) => (
|
{snippets.map((snippet) => (
|
||||||
<TabsTrigger key={snippet.id} value={snippet.id}>
|
<TabsTrigger key={snippet.id} value={snippet.id}>
|
||||||
{snippet.label}
|
{snippet.label}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { Check, Coins, Copy, Hash, Info, Timer } from "lucide-react";
|
||||||
Check,
|
|
||||||
Copy,
|
|
||||||
Hash,
|
|
||||||
Info,
|
|
||||||
Coins,
|
|
||||||
Timer,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
@ -99,9 +92,9 @@ function EndpointCopyButton({ endpoint }: { endpoint: string }) {
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
className="h-auto justify-start gap-2 rounded bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground hover:bg-muted hover:text-foreground"
|
className="h-auto max-w-full items-start justify-start gap-2 whitespace-normal rounded bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground hover:bg-muted hover:text-foreground sm:whitespace-nowrap"
|
||||||
>
|
>
|
||||||
<code>{endpoint}</code>
|
<code className="min-w-0 break-all text-left sm:break-normal">{endpoint}</code>
|
||||||
{copied ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
|
{copied ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
|
||||||
<span className="sr-only">{copied ? "Copied endpoint" : "Copy endpoint"}</span>
|
<span className="sr-only">{copied ? "Copied endpoint" : "Copy endpoint"}</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -243,8 +236,8 @@ export function PlaygroundRunner({ workspaceId, platform, verb }: PlaygroundRunn
|
||||||
className="font-medium text-foreground underline-offset-4 hover:underline"
|
className="font-medium text-foreground underline-offset-4 hover:underline"
|
||||||
>
|
>
|
||||||
Read docs
|
Read docs
|
||||||
</Link>
|
</Link>{" "}
|
||||||
{" "}for more info.
|
for more info.
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -280,17 +273,12 @@ export function PlaygroundRunner({ workspaceId, platform, verb }: PlaygroundRunn
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h2 className="text-sm font-medium text-muted-foreground">Output</h2>
|
<h2 className="text-sm font-medium text-muted-foreground">Output</h2>
|
||||||
{isRunning ? (
|
{isRunning ? (
|
||||||
<RunProgressPanel
|
<RunProgressPanel latest={run.latest} events={run.events} elapsedMs={run.elapsedMs} />
|
||||||
latest={run.latest}
|
|
||||||
events={run.events}
|
|
||||||
elapsedMs={run.elapsedMs}
|
|
||||||
/>
|
|
||||||
) : run.status === "cancelled" ? (
|
) : run.status === "cancelled" ? (
|
||||||
<div className="flex h-64 items-center justify-center rounded-md border border-border/60 px-4 text-center text-sm text-muted-foreground">
|
<div className="flex h-64 items-center justify-center rounded-md border border-border/60 px-4 text-center text-sm text-muted-foreground">
|
||||||
Run cancelled.
|
Run cancelled.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue