-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathBlankStatePanels.tsx
More file actions
688 lines (658 loc) · 22.5 KB
/
BlankStatePanels.tsx
File metadata and controls
688 lines (658 loc) · 22.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
import {
BeakerIcon,
BellAlertIcon,
BookOpenIcon,
ChatBubbleLeftRightIcon,
ClockIcon,
PlusIcon,
QuestionMarkCircleIcon,
RectangleGroupIcon,
RectangleStackIcon,
ServerStackIcon,
Squares2X2Icon,
} from "@heroicons/react/20/solid";
import { useLocation } from "react-use";
import { BranchEnvironmentIconSmall } from "~/assets/icons/EnvironmentIcons";
import { WaitpointTokenIcon } from "~/assets/icons/WaitpointTokenIcon";
import openBulkActionsPanel from "~/assets/images/open-bulk-actions-panel.png";
import selectRunsIndividually from "~/assets/images/select-runs-individually.png";
import selectRunsUsingFilters from "~/assets/images/select-runs-using-filters.png";
import { useEnvironment } from "~/hooks/useEnvironment";
import { useFeatures } from "~/hooks/useFeatures";
import { useOrganization } from "~/hooks/useOrganizations";
import { useProject } from "~/hooks/useProject";
import { type MinimumEnvironment } from "~/presenters/SelectBestEnvironmentPresenter.server";
import { NewBranchPanel } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.branches/route";
import {
docsPath,
v3BillingPath,
v3CreateBulkActionPath,
v3EnvironmentPath,
v3EnvironmentVariablesPath,
v3NewProjectAlertPath,
v3NewSchedulePath,
} from "~/utils/pathBuilder";
import { AskAI } from "./AskAI";
import { InlineCode } from "./code/InlineCode";
import { environmentFullTitle, EnvironmentIcon } from "./environments/EnvironmentLabel";
import { Feedback } from "./Feedback";
import { EnvironmentSelector } from "./navigation/EnvironmentSelector";
import { Button, LinkButton } from "./primitives/Buttons";
import { Header1 } from "./primitives/Headers";
import { InfoPanel } from "./primitives/InfoPanel";
import { Paragraph } from "./primitives/Paragraph";
import { StepNumber } from "./primitives/StepNumber";
import { TextLink } from "./primitives/TextLink";
import { SimpleTooltip } from "./primitives/Tooltip";
import {
InitCommandV3,
PackageManagerProvider,
TriggerDeployStep,
TriggerDevStepV3,
} from "./SetupCommands";
import { StepContentContainer } from "./StepContentContainer";
import { V4Badge } from "./V4Badge";
import {
ClientTabs,
ClientTabsContent,
ClientTabsList,
ClientTabsTrigger,
} from "./primitives/ClientTabs";
import { GitHubSettingsPanel } from "~/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.github";
export function HasNoTasksDev() {
return (
<PackageManagerProvider>
<div>
<div className="mb-6 flex items-center justify-between border-b">
<Header1 spacing>Get setup in 3 minutes</Header1>
<div className="flex items-center gap-2">
<Feedback
button={
<Button variant="minimal/small" LeadingIcon={ChatBubbleLeftRightIcon}>
I'm stuck!
</Button>
}
defaultValue="help"
/>
</div>
</div>
<StepNumber stepNumber="1" title="Run the CLI 'init' command in an existing project" />
<StepContentContainer>
<InitCommandV3 />
<Paragraph spacing>
You'll notice a new folder in your project called{" "}
<InlineCode variant="small">trigger</InlineCode>. We've added a few simple example tasks
in there to help you get started.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="2" title="Run the CLI 'dev' command" />
<StepContentContainer>
<TriggerDevStepV3 />
</StepContentContainer>
<StepNumber stepNumber="3" title="Waiting for tasks" displaySpinner />
<StepContentContainer>
<Paragraph>This page will automatically refresh.</Paragraph>
</StepContentContainer>
</div>
</PackageManagerProvider>
);
}
export function HasNoTasksDeployed({ environment }: { environment: MinimumEnvironment }) {
return <DeploymentOnboardingSteps />;
}
export function SchedulesNoPossibleTaskPanel() {
return (
<InfoPanel
title="Create your first scheduled task"
icon={ClockIcon}
iconClassName="text-schedules"
panelClassName="max-w-full"
accessory={
<LinkButton
to={docsPath("v3/tasks-scheduled")}
variant="docs/small"
LeadingIcon={BookOpenIcon}
>
How to schedule tasks
</LinkButton>
}
>
<Paragraph spacing variant="small">
You have no scheduled tasks in your project. Before you can schedule a task you need to
create a <InlineCode>schedules.task</InlineCode>.
</Paragraph>
</InfoPanel>
);
}
export function SchedulesNoneAttached() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
const location = useLocation();
return (
<InfoPanel
title="Attach your first schedule"
icon={ClockIcon}
iconClassName="text-schedules"
panelClassName="max-w-full"
>
<Paragraph spacing variant="small">
Scheduled tasks will only run automatically if you connect a schedule to them, you can do
this in the dashboard or using the SDK.
</Paragraph>
<div className="flex gap-2">
<LinkButton
to={`${v3NewSchedulePath(organization, project, environment)}${location.search}`}
variant="secondary/medium"
LeadingIcon={RectangleGroupIcon}
className="inline-flex"
leadingIconClassName="text-blue-500"
>
Use the dashboard
</LinkButton>
<LinkButton
to={docsPath("v3/tasks-scheduled")}
variant="docs/medium"
LeadingIcon={BookOpenIcon}
className="inline-flex"
>
Use the SDK
</LinkButton>
</div>
</InfoPanel>
);
}
export function BatchesNone() {
return (
<InfoPanel
title="Triggering batches"
icon={Squares2X2Icon}
iconClassName="text-batches"
panelClassName="max-w-full"
accessory={
<LinkButton to={docsPath("triggering")} variant="docs/small" LeadingIcon={BookOpenIcon}>
How to trigger batches
</LinkButton>
}
>
<Paragraph spacing variant="small">
You have no batches in this environment. You can trigger batches from your backend or from
inside other tasks.
</Paragraph>
</InfoPanel>
);
}
export function TestHasNoTasks() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<InfoPanel
title="You don't have any tasks to test"
icon={BeakerIcon}
iconClassName="text-tests"
panelClassName="max-w-full"
accessory={
<LinkButton
to={v3EnvironmentPath(organization, project, environment)}
variant="primary/small"
>
Create a task
</LinkButton>
}
>
<Paragraph spacing variant="small">
Before testing a task, you must first create one. Follow the instructions on the{" "}
<TextLink to={v3EnvironmentPath(organization, project, environment)}>Tasks page</TextLink>{" "}
to create a task, then return here to test it.
</Paragraph>
</InfoPanel>
);
}
export function DeploymentsNone() {
return <DeploymentOnboardingSteps />;
}
export function DeploymentsNoneDev() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<>
<div className="mb-6 flex items-center justify-between border-b">
<div className="mb-2 flex items-center gap-2">
<EnvironmentIcon environment={environment} className="-ml-1 size-8" />
<Header1>Deploy your tasks</Header1>
</div>
<div className="flex items-center">
<SimpleTooltip
button={
<LinkButton
variant="small-menu-item"
LeadingIcon={BookOpenIcon}
leadingIconClassName="text-blue-500"
to={docsPath("deployment/overview")}
/>
}
content="Deploy docs"
/>
<SimpleTooltip
button={
<LinkButton
variant="small-menu-item"
LeadingIcon={QuestionMarkCircleIcon}
leadingIconClassName="text-blue-500"
to={docsPath("troubleshooting#deployment")}
/>
}
content="Troubleshooting docs"
/>
<AskAI />
</div>
</div>
<StepNumber stepNumber="→" title="Switch to a deployed environment" />
<StepContentContainer className="mb-4 flex flex-col gap-4">
<Paragraph>
This is the Development environment. When you're ready to deploy your tasks, switch to a
different environment.
</Paragraph>
<EnvironmentSelector
organization={organization}
project={project}
environment={environment}
className="w-fit border border-charcoal-600 bg-secondary hover:border-charcoal-550 hover:bg-charcoal-600"
/>
</StepContentContainer>
</>
);
}
export function AlertsNoneDev() {
return (
<div className="space-y-8">
<InfoPanel
icon={BellAlertIcon}
iconClassName="text-alerts"
title="Adding alerts"
panelClassName="max-w-full"
>
<Paragraph spacing variant="small">
You can get alerted when deployed runs fail.
</Paragraph>
<Paragraph spacing variant="small">
We don't support alerts in the Development environment. Switch to a deployed environment
to setup alerts.
</Paragraph>
<div className="flex gap-3">
<LinkButton
to={docsPath("troubleshooting-alerts")}
variant="docs/medium"
LeadingIcon={BookOpenIcon}
className="inline-flex"
>
How to setup alerts
</LinkButton>
</div>
</InfoPanel>
<SwitcherPanel />
</div>
);
}
export function AlertsNoneDeployed() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<div className="space-y-8">
<InfoPanel
icon={BellAlertIcon}
iconClassName="text-alerts"
title="Adding alerts"
panelClassName="max-w-full"
>
<Paragraph spacing variant="small">
You can get alerted when deployed runs fail. We currently support sending Slack, Email,
and webhooks.
</Paragraph>
<div className="flex items-center justify-between gap-3">
<LinkButton
to={docsPath("troubleshooting-alerts")}
variant="docs/medium"
LeadingIcon={BookOpenIcon}
className="inline-flex"
>
Alerts docs
</LinkButton>
<LinkButton
to={v3NewProjectAlertPath(organization, project, environment)}
variant="primary/medium"
LeadingIcon={PlusIcon}
shortcut={{ key: "n" }}
>
New alert
</LinkButton>
</div>
</InfoPanel>
</div>
);
}
export function QueuesHasNoTasks() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<InfoPanel
title="You don't have any queues"
icon={RectangleStackIcon}
iconClassName="text-queues"
panelClassName="max-w-md"
accessory={
<LinkButton
to={v3EnvironmentPath(organization, project, environment)}
variant="primary/small"
>
Create a task
</LinkButton>
}
>
<Paragraph spacing variant="small">
Queues will appear here when you have created a task in this environment. Follow the
instructions on the{" "}
<TextLink to={v3EnvironmentPath(organization, project, environment)}>Tasks page</TextLink>{" "}
to create a task, then return here to see its queue.
</Paragraph>
</InfoPanel>
);
}
export function NoWaitpointTokens() {
return (
<InfoPanel
title="You don't have any waitpoint tokens"
icon={WaitpointTokenIcon}
iconClassName="text-sky-500"
panelClassName="max-w-md"
accessory={
<LinkButton to={docsPath("wait-for-token")} variant="docs/small" LeadingIcon={BookOpenIcon}>
Waitpoint docs
</LinkButton>
}
>
<Paragraph spacing variant="small">
Waitpoint tokens pause task runs until you complete the token. They're commonly used for
approval workflows and other scenarios where you need to wait for external confirmation,
such as human-in-the-loop processes.
</Paragraph>
</InfoPanel>
);
}
export function BranchesNoBranchableEnvironment() {
const { isManagedCloud } = useFeatures();
const organization = useOrganization();
if (!isManagedCloud) {
return (
<InfoPanel
title="Create a preview environment"
icon={BranchEnvironmentIconSmall}
iconClassName="text-preview"
panelClassName="max-w-full"
>
<Paragraph spacing variant="small">
To add branches you need to have a <InlineCode>RuntimeEnvironment</InlineCode> where{" "}
<InlineCode>isBranchableEnvironment</InlineCode> is true. We recommend creating a
dedicated one using the "PREVIEW" type.
</Paragraph>
</InfoPanel>
);
}
return (
<InfoPanel
title="Upgrade to get preview branches"
icon={BranchEnvironmentIconSmall}
iconClassName="text-preview"
panelClassName="max-w-full"
accessory={
<LinkButton variant="primary/small" to={v3BillingPath(organization)}>
Upgrade
</LinkButton>
}
>
<Paragraph spacing variant="small">
Preview branches in AirTrigger create isolated environments for testing new features before
production.
</Paragraph>
<Paragraph variant="small">
You must be on <V4Badge inline /> to access preview branches. Read our{" "}
<TextLink to={docsPath("upgrade-to-v4")}>upgrade to v4 guide</TextLink> to learn more.
</Paragraph>
</InfoPanel>
);
}
export function BranchesNoBranches({
parentEnvironment,
limits,
canUpgrade,
}: {
parentEnvironment: { id: string };
limits: { used: number; limit: number };
canUpgrade: boolean;
}) {
const organization = useOrganization();
if (limits.used >= limits.limit) {
return (
<InfoPanel
title="Upgrade to get preview branches"
icon={BranchEnvironmentIconSmall}
iconClassName="text-preview"
panelClassName="max-w-full"
accessory={
canUpgrade ? (
<LinkButton variant="primary/small" to={v3BillingPath(organization)}>
Upgrade
</LinkButton>
) : (
<Feedback
button={<Button variant="primary/small">Request more</Button>}
defaultValue="help"
/>
)
}
>
<Paragraph spacing variant="small">
You've reached the limit ({limits.used}/{limits.limit}) of branches for your plan. Upgrade
to get branches.
</Paragraph>
</InfoPanel>
);
}
return (
<InfoPanel
title="Create your first branch"
icon={BranchEnvironmentIconSmall}
iconClassName="text-preview"
panelClassName="max-w-full"
accessory={
<NewBranchPanel
button={
<Button
variant="primary/small"
LeadingIcon={PlusIcon}
leadingIconClassName="text-white"
>
New branch
</Button>
}
parentEnvironment={parentEnvironment}
/>
}
>
<Paragraph spacing variant="small">
Branches are a way to test new features in isolation before merging them into the main
environment.
</Paragraph>
<Paragraph spacing variant="small">
Branches are only available when using <V4Badge inline /> or above. Read our{" "}
<TextLink to={docsPath("upgrade-to-v4")}>v4 upgrade guide</TextLink> to learn more.
</Paragraph>
</InfoPanel>
);
}
export function SwitcherPanel({ title = "Switch to a deployed environment" }: { title?: string }) {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<div className="flex items-center rounded-md border border-grid-bright bg-background-bright p-3">
<Paragraph variant="small" className="grow">
{title}
</Paragraph>
<EnvironmentSelector
organization={organization}
project={project}
environment={environment}
className="w-auto grow-0 rounded-sm bg-grid-bright"
/>
</div>
);
}
export function BulkActionsNone() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
return (
<div>
<div className="mb-6 flex items-center justify-between border-b pb-0.5">
<Header1 spacing>Create a bulk action</Header1>
<div className="flex items-center gap-2">
<LinkButton
variant="primary/small"
LeadingIcon={PlusIcon}
to={v3CreateBulkActionPath(organization, project, environment)}
>
New bulk action
</LinkButton>
</div>
</div>
<StepNumber stepNumber="1" title="Select runs individually" />
<StepContentContainer className="mb-4 flex flex-col gap-4">
<Paragraph>Select runs from the runs page individually.</Paragraph>
<div>
<img src={selectRunsIndividually} alt="Select runs individually" />
</div>
</StepContentContainer>
<div className="mb-5 ml-9 flex items-center gap-2">
<div className="h-px w-full bg-grid-bright" />
<Paragraph variant="extra-small" className="text-text-dimmed">
OR
</Paragraph>
<div className="h-px w-full bg-grid-bright" />
</div>
<StepNumber stepNumber="2" title="Select runs using filters" />
<StepContentContainer className="flex flex-col gap-4">
<Paragraph>
Use the filter menu on the runs page to select just the runs you want to bulk action.
</Paragraph>
<div>
<img src={selectRunsUsingFilters} alt="Select runs using filters" />
</div>
</StepContentContainer>
<StepNumber stepNumber="3" title="Open the bulk action panel" />
<StepContentContainer className="flex flex-col gap-4">
<Paragraph>Click the “Bulk actions” button in the top right of the runs page.</Paragraph>
<div>
<img src={openBulkActionsPanel} alt="Open the bulk action panel" />
</div>
</StepContentContainer>
</div>
);
}
function DeploymentOnboardingSteps() {
const environment = useEnvironment();
const organization = useOrganization();
const project = useProject();
return (
<PackageManagerProvider>
<div className="mb-2 flex items-center justify-between border-b">
<div className="mb-2 flex min-w-0 items-center gap-2">
<EnvironmentIcon environment={environment} className="-ml-1 size-8 shrink-0" />
<Header1 className="truncate">Deploy your tasks to {environmentFullTitle(environment)}</Header1>
</div>
<div className="flex items-center">
<SimpleTooltip
button={
<LinkButton
variant="small-menu-item"
LeadingIcon={BookOpenIcon}
leadingIconClassName="text-blue-500"
to={docsPath("deployment/overview")}
/>
}
content="Deploy docs"
/>
<SimpleTooltip
button={
<LinkButton
variant="small-menu-item"
LeadingIcon={QuestionMarkCircleIcon}
leadingIconClassName="text-blue-500"
to={docsPath("troubleshooting#deployment")}
/>
}
content="Troubleshooting docs"
/>
<AskAI />
</div>
</div>
<ClientTabs defaultValue="github">
<ClientTabsList variant="segmented" className="mb-6">
<ClientTabsTrigger value={"github"} variant="segmented" layoutId="deploy-tabs">
GitHub
</ClientTabsTrigger>
<ClientTabsTrigger value={"cli"} variant="segmented" layoutId="deploy-tabs">
Manual
</ClientTabsTrigger>
<ClientTabsTrigger value={"github-actions"} variant="segmented" layoutId="deploy-tabs">
GitHub Actions
</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"github"}>
<StepNumber stepNumber="1" title="Connect your GitHub repository" />
<StepContentContainer>
<Paragraph spacing>
Deploy automatically with every push. Read the{" "}
<TextLink to={docsPath("github-integration")}>full guide</TextLink>.
</Paragraph>
<div className="w-fit">
<GitHubSettingsPanel
organizationSlug={organization.slug}
projectSlug={project.slug}
environmentSlug={environment.slug}
billingPath={v3BillingPath({ slug: organization.slug })}
/>
</div>
</StepContentContainer>
</ClientTabsContent>
<ClientTabsContent value={"cli"}>
<StepNumber stepNumber="1" title="Run the CLI 'deploy' command" />
<StepContentContainer>
<Paragraph spacing>
This will deploy your tasks to the {environmentFullTitle(environment)} environment.
Read the <TextLink to={docsPath("deployment/overview")}>full guide</TextLink>.
</Paragraph>
<TriggerDeployStep environment={environment} />
</StepContentContainer>
</ClientTabsContent>
<ClientTabsContent value={"github-actions"}>
<StepNumber stepNumber="1" title="Deploy using GitHub Actions" />
<StepContentContainer>
<Paragraph spacing>
Read the <TextLink to={docsPath("github-actions")}>GitHub Actions guide</TextLink> to
get started.
</Paragraph>
</StepContentContainer>
</ClientTabsContent>
</ClientTabs>
<StepNumber stepNumber="2" title="Waiting for tasks to deploy" displaySpinner />
<StepContentContainer>
<Paragraph>This page will automatically refresh when your tasks are deployed.</Paragraph>
</StepContentContainer>
</PackageManagerProvider>
);
}