Skip to content

Commit 611a5e6

Browse files
committed
Replaces many props with a single ‘accessory’ React node on the Info Panel component
1 parent 3b4d9d6 commit 611a5e6

File tree

9 files changed

+116
-70
lines changed

9 files changed

+116
-70
lines changed

apps/webapp/app/components/BlankStatePanels.tsx

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ export function HasNoTasksDeployed({ environment }: { environment: MinimumEnviro
8282
icon={TaskIcon}
8383
iconClassName="text-blue-500"
8484
panelClassName="max-w-full"
85-
to={docsPath("deployment/overview")}
86-
buttonLabel="How to deploy tasks"
87-
buttonVariant="docs/small"
88-
buttonLeadingIcon={BookOpenIcon}
85+
accessory={
86+
<LinkButton
87+
to={docsPath("deployment/overview")}
88+
variant="docs/small"
89+
LeadingIcon={BookOpenIcon}
90+
>
91+
How to deploy tasks
92+
</LinkButton>
93+
}
8994
>
9095
<Paragraph spacing variant="small">
9196
Run the <TextLink to={docsPath("deployment/overview")}>CLI deploy command</TextLink> to
@@ -102,10 +107,15 @@ export function SchedulesNoPossibleTaskPanel() {
102107
icon={ClockIcon}
103108
iconClassName="text-sun-500"
104109
panelClassName="max-w-full"
105-
to={docsPath("v3/tasks-scheduled")}
106-
buttonLabel="How to schedule tasks"
107-
buttonVariant="docs/small"
108-
buttonLeadingIcon={BookOpenIcon}
110+
accessory={
111+
<LinkButton
112+
to={docsPath("v3/tasks-scheduled")}
113+
variant="docs/small"
114+
LeadingIcon={BookOpenIcon}
115+
>
116+
How to schedule tasks
117+
</LinkButton>
118+
}
109119
>
110120
<Paragraph spacing variant="small">
111121
You have no scheduled tasks in your project. Before you can schedule a task you need to
@@ -135,15 +145,16 @@ export function SchedulesNoneAttached() {
135145
<div className="flex gap-2">
136146
<LinkButton
137147
to={`${v3NewSchedulePath(organization, project, environment)}${location.search}`}
138-
variant="primary/small"
148+
variant="secondary/medium"
139149
LeadingIcon={RectangleGroupIcon}
140150
className="inline-flex"
151+
leadingIconClassName="text-sun-500"
141152
>
142153
Use the dashboard
143154
</LinkButton>
144155
<LinkButton
145156
to={docsPath("v3/tasks-scheduled")}
146-
variant="primary/small"
157+
variant="docs/medium"
147158
LeadingIcon={BookOpenIcon}
148159
className="inline-flex"
149160
>
@@ -161,10 +172,11 @@ export function BatchesNone() {
161172
icon={Squares2X2Icon}
162173
iconClassName="text-blue-500"
163174
panelClassName="max-w-full"
164-
to={docsPath("triggering")}
165-
buttonLabel="How to trigger batches"
166-
buttonVariant="docs/small"
167-
buttonLeadingIcon={BookOpenIcon}
175+
accessory={
176+
<LinkButton to={docsPath("triggering")} variant="docs/small" LeadingIcon={BookOpenIcon}>
177+
How to trigger batches
178+
</LinkButton>
179+
}
168180
>
169181
<Paragraph spacing variant="small">
170182
You have no batches in this environment. You can trigger batches from your backend or from
@@ -184,8 +196,15 @@ export function TestHasNoTasks() {
184196
icon={BeakerIcon}
185197
iconClassName="text-lime-500"
186198
panelClassName="max-w-full"
187-
to={v3EnvironmentPath(organization, project, environment)}
188-
buttonLabel="Create a task"
199+
accessory={
200+
<LinkButton
201+
to={v3EnvironmentPath(organization, project, environment)}
202+
variant="secondary/small"
203+
LeadingIcon={PlusIcon}
204+
>
205+
Create a task
206+
</LinkButton>
207+
}
189208
>
190209
<Paragraph spacing variant="small">
191210
Before testing a task, you must first create one. Follow the instructions on the{" "}
@@ -373,8 +392,15 @@ export function QueuesHasNoTasks() {
373392
icon={RectangleStackIcon}
374393
iconClassName="text-blue-500"
375394
panelClassName="max-w-md"
376-
to={v3EnvironmentPath(organization, project, environment)}
377-
buttonLabel="Create a task"
395+
accessory={
396+
<LinkButton
397+
to={v3EnvironmentPath(organization, project, environment)}
398+
variant="secondary/small"
399+
LeadingIcon={PlusIcon}
400+
>
401+
Create a task
402+
</LinkButton>
403+
}
378404
>
379405
<Paragraph spacing variant="small">
380406
Queues will appear here when you have created a task in this environment. Follow the

apps/webapp/app/components/primitives/InfoPanel.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cn } from "~/utils/cn";
2-
import { LinkButton } from "./Buttons";
32
import { Header2 } from "./Headers";
43
import { Paragraph } from "./Paragraph";
4+
import { type ReactNode } from "react";
55

66
const variants = {
77
info: {
@@ -20,10 +20,7 @@ type InfoPanelVariant = keyof typeof variants;
2020
type Props = {
2121
title?: string;
2222
children: React.ReactNode;
23-
to?: string;
24-
buttonLabel?: string;
25-
buttonVariant?: React.ComponentProps<typeof LinkButton>["variant"];
26-
buttonLeadingIcon?: React.ComponentProps<typeof LinkButton>["LeadingIcon"];
23+
accessory?: ReactNode;
2724
icon: React.ComponentType<any>;
2825
iconClassName?: string;
2926
variant?: InfoPanelVariant;
@@ -33,10 +30,7 @@ type Props = {
3330
export function InfoPanel({
3431
title,
3532
children,
36-
to,
37-
buttonLabel,
38-
buttonVariant = "secondary/small",
39-
buttonLeadingIcon,
33+
accessory,
4034
icon,
4135
iconClassName,
4236
variant = "info",
@@ -54,14 +48,10 @@ export function InfoPanel({
5448
panelClassName
5549
)}
5650
>
57-
<div className={cn("flex items-center gap-2", to ? "w-full justify-between" : "")}>
51+
<div className={cn("flex items-center gap-2", accessory ? "w-full justify-between" : "")}>
5852
<Icon className={cn("size-5", iconClassName)} />
5953

60-
{to && (
61-
<LinkButton to={to} variant={buttonVariant} LeadingIcon={buttonLeadingIcon}>
62-
{buttonLabel}
63-
</LinkButton>
64-
)}
54+
{accessory}
6555
</div>
6656
<div className="flex flex-col gap-1">
6757
{title && <Header2 className="text-text-bright">{title}</Header2>}

apps/webapp/app/presenters/v3/ScheduleListPresenter.server.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ export class ScheduleListPresenter extends BasePresenter {
5050
pageSize = DEFAULT_PAGE_SIZE,
5151
}: ScheduleListOptions) {
5252
const hasFilters =
53-
type !== undefined ||
54-
tasks !== undefined ||
55-
environments !== undefined ||
56-
(search !== undefined && search !== "");
53+
type !== undefined || tasks !== undefined || (search !== undefined && search !== "");
5754

5855
const filterType =
5956
type === "declarative" ? "DECLARATIVE" : type === "imperative" ? "IMPERATIVE" : undefined;

apps/webapp/app/routes/_app.orgs.$organizationSlug.invite/route.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ export default function Page() {
153153
icon={LockOpenIcon}
154154
iconClassName="text-indigo-500"
155155
title="Unlock more team members"
156-
to={v3BillingPath(organization)}
157-
buttonLabel="Upgrade"
156+
accessory={
157+
<LinkButton to={v3BillingPath(organization)} variant="secondary/small">
158+
Upgrade
159+
</LinkButton>
160+
}
158161
panelClassName="mb-4"
159162
>
160163
<Paragraph variant="small">

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ import { type RuntimeEnvironmentType } from "@trigger.dev/database";
2323
import { motion } from "framer-motion";
2424
import { useCallback, useEffect, useRef, useState } from "react";
2525
import { useHotkeys } from "react-hotkeys-hook";
26+
import { DisconnectedIcon } from "~/assets/icons/ConnectionIcons";
2627
import { ShowParentIcon, ShowParentIconSelected } from "~/assets/icons/ShowParentIcon";
2728
import tileBgPath from "~/assets/images/[email protected]";
29+
import { useDevPresence } from "~/components/DevPresence";
2830
import { AdminDebugTooltip } from "~/components/admin/debugTooltip";
29-
import { InlineCode } from "~/components/code/InlineCode";
30-
import { EnvironmentCombo } from "~/components/environments/EnvironmentLabel";
3131
import { PageBody } from "~/components/layout/AppLayout";
3232
import { Badge } from "~/components/primitives/Badge";
3333
import { Button, LinkButton } from "~/components/primitives/Buttons";
3434
import { Callout } from "~/components/primitives/Callout";
35+
import { ClipboardField } from "~/components/primitives/ClipboardField";
3536
import { DateTimeShort } from "~/components/primitives/DateTime";
3637
import { Dialog, DialogTrigger } from "~/components/primitives/Dialog";
3738
import { Header3 } from "~/components/primitives/Headers";
@@ -93,9 +94,6 @@ import {
9394
} from "~/utils/pathBuilder";
9495
import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route";
9596
import { SpanView } from "../resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route";
96-
import { useDevPresence } from "~/components/DevPresence";
97-
import { DisconnectedIcon } from "~/assets/icons/ConnectionIcons";
98-
import { ClipboardField } from "~/components/primitives/ClipboardField";
9997

10098
const resizableSettings = {
10199
parent: {
@@ -404,8 +402,11 @@ function NoLogsView({ run, resizable }: LoaderData) {
404402
icon={LockOpenIcon}
405403
iconClassName="text-indigo-500"
406404
title="Unlock longer log retention"
407-
to={v3BillingPath(organization)}
408-
buttonLabel="Upgrade"
405+
accessory={
406+
<LinkButton to={v3BillingPath(organization)} variant="secondary/small">
407+
Upgrade
408+
</LinkButton>
409+
}
409410
>
410411
<Paragraph variant="small">
411412
The logs for this run have been deleted because the run completed{" "}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ import { TextLink } from "~/components/primitives/TextLink";
3333
import { RunsFilters, TaskRunListSearchFilters } from "~/components/runs/v3/RunFilters";
3434
import { TaskRunsTable } from "~/components/runs/v3/TaskRunsTable";
3535
import { BULK_ACTION_RUN_LIMIT } from "~/consts";
36+
import { useEnvironment } from "~/hooks/useEnvironment";
3637
import { useOrganization } from "~/hooks/useOrganizations";
3738
import { useProject } from "~/hooks/useProject";
3839
import { findProjectBySlug } from "~/models/project.server";
40+
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
3941
import { RunListPresenter } from "~/presenters/v3/RunListPresenter.server";
4042
import {
4143
getRootOnlyFilterPreference,
@@ -47,15 +49,11 @@ import { cn } from "~/utils/cn";
4749
import {
4850
docsPath,
4951
EnvironmentParamSchema,
50-
ProjectParamSchema,
5152
v3ProjectPath,
5253
v3RunsPath,
5354
v3TestPath,
5455
} from "~/utils/pathBuilder";
5556
import { ListPagination } from "../../components/ListPagination";
56-
import { prisma } from "~/db.server";
57-
import { useEnvironment } from "~/hooks/useEnvironment";
58-
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
5957

6058
export const meta: MetaFunction = () => {
6159
return [
@@ -438,8 +436,11 @@ function CreateFirstTaskInstructions() {
438436
iconClassName="text-blue-500"
439437
panelClassName="max-full"
440438
title="Create your first task"
441-
to={v3ProjectPath(organization, project)}
442-
buttonLabel="Create a task"
439+
accessory={
440+
<LinkButton to={v3ProjectPath(organization, project)} variant="primary/small">
441+
Create a task
442+
</LinkButton>
443+
}
443444
>
444445
<Paragraph variant="small">
445446
Before running a task, you must first create one. Follow the instructions on the{" "}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,11 @@ export default function Page() {
357357
icon={BookOpenIcon}
358358
iconClassName="text-indigo-500"
359359
variant="info"
360-
buttonLabel="Docs"
361-
to="https://trigger.dev/docs/v3/tasks-scheduled"
360+
accessory={
361+
<LinkButton to="https://trigger.dev/docs/v3/tasks-scheduled" variant="docs/small">
362+
Docs
363+
</LinkButton>
364+
}
362365
panelClassName="max-w-full"
363366
>
364367
You can only edit a declarative schedule by updating your schedules.task and then

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.team/route.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,11 @@ export default function Page() {
226226
icon={LockOpenIcon}
227227
iconClassName="text-indigo-500"
228228
title="Unlock more team members"
229-
to={v3BillingPath(organization)}
230-
buttonLabel="Upgrade"
229+
accessory={
230+
<LinkButton to={v3BillingPath(organization)} variant="secondary/small">
231+
Upgrade
232+
</LinkButton>
233+
}
231234
panelClassName="mt-4"
232235
>
233236
<Paragraph variant="small">

0 commit comments

Comments
 (0)