Skip to content

Commit c715dd3

Browse files
committed
Animate the helpful next steps panel
1 parent c4929c7 commit c715dd3

File tree

3 files changed

+47
-27
lines changed
  • apps/webapp/app/routes
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam._index
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam

3 files changed

+47
-27
lines changed

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

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import {
1010
VideoCameraIcon,
1111
} from "@heroicons/react/20/solid";
1212
import { json, type MetaFunction } from "@remix-run/node";
13-
import { Link, useRevalidator, useSubmit } from "@remix-run/react";
13+
import { Link, useFetcher, useRevalidator } from "@remix-run/react";
1414
import { type ActionFunctionArgs, type LoaderFunctionArgs } from "@remix-run/server-runtime";
1515
import { DiscordIcon } from "@trigger.dev/companyicons";
1616
import { formatDurationMilliseconds } from "@trigger.dev/core/v3";
1717
import type { TaskRunStatus } from "@trigger.dev/database";
18-
import { Fragment, Suspense, useEffect, useState } from "react";
18+
import { Fragment, Suspense, useCallback, useEffect, useRef, useState } from "react";
19+
import type { PanelHandle } from "react-window-splitter";
1920
import { Bar, BarChart, ResponsiveContainer, Tooltip, type TooltipProps } from "recharts";
2021
import { TypedAwait, typeddefer, useTypedLoaderData } from "remix-typedjson";
2122
import { ExitIcon } from "~/assets/icons/ExitIcon";
@@ -42,9 +43,11 @@ import { Paragraph } from "~/components/primitives/Paragraph";
4243
import { PopoverMenuItem } from "~/components/primitives/Popover";
4344
import * as Property from "~/components/primitives/PropertyTable";
4445
import {
46+
RESIZABLE_PANEL_ANIMATION,
4547
ResizableHandle,
4648
ResizablePanel,
4749
ResizablePanelGroup,
50+
collapsibleHandleClassName,
4851
} from "~/components/primitives/Resizable";
4952
import { Spinner } from "~/components/primitives/Spinner";
5053
import { StepNumber } from "~/components/primitives/StepNumber";
@@ -192,14 +195,20 @@ export default function Page() {
192195
}, [streamedEvents]); // eslint-disable-line react-hooks/exhaustive-deps
193196

194197
const [showUsefulLinks, setShowUsefulLinks] = useState(usefulLinksPreference ?? true);
198+
const usefulLinksPanelRef = useRef<PanelHandle>(null);
199+
const fetcher = useFetcher();
200+
const fetcherRef = useRef(fetcher);
201+
fetcherRef.current = fetcher;
195202

196-
// Create a submit handler to save the preference
197-
const submit = useSubmit();
198-
199-
const handleUsefulLinksToggle = (show: boolean) => {
203+
const toggleUsefulLinks = useCallback((show: boolean) => {
200204
setShowUsefulLinks(show);
201-
submit({ showUsefulLinks: show.toString() }, { method: "post" });
202-
};
205+
if (show) {
206+
usefulLinksPanelRef.current?.expand();
207+
} else {
208+
usefulLinksPanelRef.current?.collapse();
209+
}
210+
fetcherRef.current.submit({ showUsefulLinks: show.toString() }, { method: "post" });
211+
}, []);
203212

204213
return (
205214
<PageContainer>
@@ -226,7 +235,7 @@ export default function Page() {
226235
</NavBar>
227236
<PageBody scrollable={false}>
228237
<ResizablePanelGroup orientation="horizontal" className="max-h-full">
229-
<ResizablePanel id="tasks-main" className="max-h-full">
238+
<ResizablePanel id="tasks-main" min="100px" className="max-h-full">
230239
<div className={cn("grid h-full grid-rows-1")}>
231240
{hasTasks ? (
232241
<div className="flex min-w-0 max-w-full flex-col">
@@ -244,9 +253,9 @@ export default function Page() {
244253
/>
245254
{!showUsefulLinks && (
246255
<Button
247-
variant="minimal/small"
256+
variant="secondary/small"
248257
TrailingIcon={LightBulbIcon}
249-
onClick={() => handleUsefulLinksToggle(true)}
258+
onClick={() => toggleUsefulLinks(true)}
250259
className="px-2.5"
251260
/>
252261
)}
@@ -417,20 +426,31 @@ export default function Page() {
417426
)}
418427
</div>
419428
</ResizablePanel>
420-
{hasTasks && showUsefulLinks ? (
421-
<>
422-
<ResizableHandle id="tasks-handle" />
423-
<ResizablePanel
424-
id="tasks-inspector"
425-
min="200px"
426-
default="400px"
427-
max="500px"
428-
className="w-full"
429-
>
430-
<HelpfulInfoHasTasks onClose={() => handleUsefulLinksToggle(false)} />
431-
</ResizablePanel>
432-
</>
433-
) : null}
429+
<ResizableHandle
430+
id="tasks-handle"
431+
className={collapsibleHandleClassName(hasTasks && showUsefulLinks)}
432+
/>
433+
<ResizablePanel
434+
id="tasks-inspector"
435+
handle={usefulLinksPanelRef}
436+
default="400px"
437+
min="400px"
438+
max="500px"
439+
className="overflow-hidden"
440+
collapsible
441+
collapsed={!hasTasks || !showUsefulLinks}
442+
onCollapseChange={(isCollapsed) => {
443+
if (isCollapsed) setShowUsefulLinks(false);
444+
}}
445+
collapsedSize="0px"
446+
collapseAnimation={RESIZABLE_PANEL_ANIMATION}
447+
>
448+
<div className="h-full" style={{ minWidth: 400 }}>
449+
{hasTasks && (
450+
<HelpfulInfoHasTasks onClose={() => toggleUsefulLinks(false)} />
451+
)}
452+
</div>
453+
</ResizablePanel>
434454
</ResizablePanelGroup>
435455
</PageBody>
436456
</PageContainer>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ function LogsList({
408408
const frozenLogId = useFrozenValue(selectedLogId);
409409
const frozenLog = useFrozenValue(selectedLog);
410410
const displayLogId = selectedLogId ?? frozenLogId;
411-
const displayLog = selectedLog ?? frozenLog;
411+
const displayLog = selectedLog ?? frozenLog ?? undefined;
412412

413413
const updateUrlWithLog = useCallback((logId: string | undefined) => {
414414
const url = new URL(window.location.href);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ function TraceView({
512512
? linkedRunIdBySpanId?.[selectedSpanId]
513513
: undefined;
514514
const frozenLinkedRunId = useFrozenValue(selectedSpanLinkedRunId);
515-
const displayLinkedRunId = selectedSpanId ? selectedSpanLinkedRunId : frozenLinkedRunId;
515+
const displayLinkedRunId = (selectedSpanId ? selectedSpanLinkedRunId : frozenLinkedRunId) ?? undefined;
516516

517517
return (
518518
<div className={cn("grid h-full max-h-full grid-cols-1 overflow-hidden")}>

0 commit comments

Comments
 (0)