Skip to content

Commit 4f48b07

Browse files
committed
Tidied the sidebar layout up a lot
1 parent e7453fe commit 4f48b07

File tree

2 files changed

+37
-74
lines changed
  • apps/webapp/app

2 files changed

+37
-74
lines changed

apps/webapp/app/components/code/AIQueryInput.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PencilSquareIcon, SparklesIcon } from "@heroicons/react/20/solid";
1+
import { PencilSquareIcon, PlusIcon, SparklesIcon } from "@heroicons/react/20/solid";
22
import { AnimatePresence, motion } from "framer-motion";
33
import { Suspense, lazy, useCallback, useEffect, useRef, useState } from "react";
44
import { AISparkleIcon } from "~/assets/icons/AISparkleIcon";
@@ -274,8 +274,7 @@ export function AIQueryInput({
274274
type="button"
275275
variant="tertiary/small"
276276
disabled={!prompt.trim()}
277-
LeadingIcon={SparklesIcon}
278-
className="pl-1.5"
277+
LeadingIcon={PlusIcon}
279278
iconSpacing="gap-1.5"
280279
onClick={() => {
281280
setMode("new");
@@ -289,8 +288,8 @@ export function AIQueryInput({
289288
variant="tertiary/small"
290289
disabled={!prompt.trim() || !canEdit}
291290
LeadingIcon={PencilSquareIcon}
292-
className={cn("pl-1.5", !canEdit && "opacity-50")}
293-
iconSpacing="gap-1.5"
291+
className={cn(!canEdit && "opacity-50")}
292+
iconSpacing="gap-2"
294293
tooltip={!canEdit ? "Write a query first to enable editing" : undefined}
295294
onClick={() => {
296295
setMode("edit");

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { useCallback, useEffect, useState } from "react";
1616
import { typedjson, useTypedActionData, useTypedLoaderData } from "remix-typedjson";
1717
import { z } from "zod";
18+
import { AISparkleIcon } from "~/assets/icons/AISparkleIcon";
1819
import { ClockRotateLeftIcon } from "~/assets/icons/ClockRotateLeftIcon";
1920
import { ExitIcon } from "~/assets/icons/ExitIcon";
2021
import { AlphaTitle } from "~/components/AlphaBadge";
@@ -248,7 +249,6 @@ export default function Page() {
248249
const [query, setQuery] = useState(defaultQuery);
249250
const [scope, setScope] = useState<QueryScope>("environment");
250251
const [prettyFormatting, setPrettyFormatting] = useState(true);
251-
const [showHelpSidebar, setShowHelpSidebar] = useState(true);
252252
const [resultsView, setResultsView] = useState<"table" | "graph">("table");
253253
const [chartConfig, setChartConfig] = useState<ChartConfiguration>(defaultChartConfig);
254254

@@ -296,27 +296,12 @@ export default function Page() {
296296
showClearButton={true}
297297
minHeight="200px"
298298
className="min-h-[200px]"
299-
additionalActions={
300-
showHelpSidebar ? null : (
301-
<Button variant="minimal/small" onClick={() => setShowHelpSidebar(true)}>
302-
Help
303-
</Button>
304-
)
305-
}
306299
/>
307300
<Form method="post" className="flex items-center justify-between gap-2 px-2">
308301
<input type="hidden" name="query" value={query} />
309302
<input type="hidden" name="scope" value={scope} />
310303
<QueryHistoryPopover history={history} onQuerySelected={handleHistorySelected} />
311304
<div className="flex items-center gap-2">
312-
{!showHelpSidebar && (
313-
<Button
314-
variant="minimal/small"
315-
TrailingIcon={LightBulbIcon}
316-
onClick={() => setShowHelpSidebar(true)}
317-
className="px-2.5"
318-
/>
319-
)}
320305
<Select
321306
value={scope}
322307
setValue={(value) => setScope(value as QueryScope)}
@@ -446,28 +431,23 @@ export default function Page() {
446431
</div>
447432
</div>
448433
</ResizablePanel>
449-
{showHelpSidebar && (
450-
<>
451-
<ResizableHandle id="query-handle" />
452-
<ResizablePanel
453-
id="query-help"
454-
min="200px"
455-
default="400px"
456-
max="500px"
457-
className="w-full"
458-
>
459-
<QueryHelpSidebar
460-
onClose={() => setShowHelpSidebar(false)}
461-
onTryExample={(exampleQuery, exampleScope) => {
462-
setQuery(exampleQuery);
463-
setScope(exampleScope);
464-
}}
465-
onQueryGenerated={setQuery}
466-
currentQuery={query}
467-
/>
468-
</ResizablePanel>
469-
</>
470-
)}
434+
<ResizableHandle id="query-handle" />
435+
<ResizablePanel
436+
id="query-help"
437+
min="200px"
438+
default="400px"
439+
max="500px"
440+
className="w-full"
441+
>
442+
<QueryHelpSidebar
443+
onTryExample={(exampleQuery, exampleScope) => {
444+
setQuery(exampleQuery);
445+
setScope(exampleScope);
446+
}}
447+
onQueryGenerated={setQuery}
448+
currentQuery={query}
449+
/>
450+
</ResizablePanel>
471451
</ResizablePanelGroup>
472452
</PageBody>
473453
</PageContainer>
@@ -583,36 +563,22 @@ LIMIT 100`,
583563
];
584564

585565
function QueryHelpSidebar({
586-
onClose,
587566
onTryExample,
588567
onQueryGenerated,
589568
currentQuery,
590569
}: {
591-
onClose: () => void;
592570
onTryExample: (query: string, scope: QueryScope) => void;
593571
onQueryGenerated: (query: string) => void;
594572
currentQuery: string;
595573
}) {
596574
return (
597575
<div className="grid h-full max-h-full grid-rows-[auto_1fr] overflow-hidden bg-background-bright">
598-
<div className="flex items-center justify-between gap-2 border-b border-grid-dimmed p-3 pt-2">
599-
<Header2 className="flex items-center gap-2">
600-
<LightBulbIcon className="size-4 min-w-4 text-sun-500" />
601-
Query help
602-
</Header2>
603-
<Button
604-
onClick={onClose}
605-
variant="minimal/small"
606-
TrailingIcon={ExitIcon}
607-
shortcut={{ key: "esc" }}
608-
shortcutPosition="before-trailing-icon"
609-
className="pl-[0.375rem]"
610-
/>
611-
</div>
612-
<ClientTabs defaultValue="ai" className="flex min-h-0 flex-col overflow-hidden">
576+
<ClientTabs defaultValue="ai" className="flex min-h-0 flex-col overflow-hidden pt-1">
613577
<ClientTabsList variant="underline" className="mx-3 shrink-0">
614578
<ClientTabsTrigger value="ai" variant="underline" layoutId="query-help-tabs">
615-
AI
579+
<div className="flex items-center gap-0.5">
580+
<AISparkleIcon className="size-4" /> AI
581+
</div>
616582
</ClientTabsTrigger>
617583
<ClientTabsTrigger value="guide" variant="underline" layoutId="query-help-tabs">
618584
Writing TRQL
@@ -671,20 +637,14 @@ function AITabContent({
671637
];
672638

673639
return (
674-
<div className="space-y-4">
675-
<div>
676-
<Header3 className="mb-2 text-text-bright">Generate query with AI</Header3>
677-
<Paragraph variant="small" className="mb-3 text-text-dimmed">
678-
Describe the data you want to query in natural language, or edit the existing query.
679-
</Paragraph>
680-
<AIQueryInput
681-
onQueryGenerated={onQueryGenerated}
682-
autoSubmitPrompt={autoSubmitPrompt}
683-
currentQuery={currentQuery}
684-
/>
685-
</div>
640+
<div className="space-y-2">
641+
<AIQueryInput
642+
onQueryGenerated={onQueryGenerated}
643+
autoSubmitPrompt={autoSubmitPrompt}
644+
currentQuery={currentQuery}
645+
/>
686646

687-
<div className="border-t border-grid-dimmed pt-4">
647+
<div className="pt-4">
688648
<Header3 className="mb-2 text-text-bright">Example prompts</Header3>
689649
<div className="space-y-2">
690650
{examplePrompts.map((example) => (
@@ -744,6 +704,10 @@ function TRQLGuideContent({
744704
}) {
745705
return (
746706
<div className="space-y-6">
707+
<Paragraph variant="small/bright">
708+
TRQL is a query language for the Trigger platform. It is based on ClickHouse SQL and extends
709+
it with additional features.
710+
</Paragraph>
747711
{/* Table of contents */}
748712
<nav className="space-y-1 text-sm">
749713
<a href="#basic" className="block text-text-link hover:underline">

0 commit comments

Comments
 (0)