@@ -18,6 +18,7 @@ import { useProject } from "~/hooks/useProject";
1818import { type MinimumEnvironment } from "~/presenters/SelectBestEnvironmentPresenter.server" ;
1919import {
2020 docsPath ,
21+ v3BillingPath ,
2122 v3EnvironmentPath ,
2223 v3EnvironmentVariablesPath ,
2324 v3NewProjectAlertPath ,
@@ -36,6 +37,11 @@ import { TextLink } from "./primitives/TextLink";
3637import { InitCommandV3 , PackageManagerProvider , TriggerDevStepV3 } from "./SetupCommands" ;
3738import { StepContentContainer } from "./StepContentContainer" ;
3839import { WaitpointTokenIcon } from "~/assets/icons/WaitpointTokenIcon" ;
40+ import { BranchEnvironmentIconSmall } from "~/assets/icons/EnvironmentIcons" ;
41+ import { useFeatures } from "~/hooks/useFeatures" ;
42+ import { DialogContent , DialogTrigger , Dialog } from "./primitives/Dialog" ;
43+ import { V4Badge } from "./V4Badge" ;
44+ import { NewBranchPanel } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.branches/route" ;
3945
4046export function HasNoTasksDev ( ) {
4147 return (
@@ -431,15 +437,128 @@ export function NoWaitpointTokens() {
431437 ) ;
432438}
433439
434- function SwitcherPanel ( ) {
440+ export function BranchesNoBranchableEnvironment ( ) {
441+ const { isManagedCloud } = useFeatures ( ) ;
442+ const organization = useOrganization ( ) ;
443+
444+ if ( ! isManagedCloud ) {
445+ return (
446+ < InfoPanel
447+ title = "Create a preview environment"
448+ icon = { BranchEnvironmentIconSmall }
449+ iconClassName = "text-preview"
450+ panelClassName = "max-w-full"
451+ >
452+ < Paragraph spacing variant = "small" >
453+ To add branches you need to have a < InlineCode > RuntimeEnvironment</ InlineCode > where{ " " }
454+ < InlineCode > isBranchableEnvironment</ InlineCode > is true. We recommend creating a
455+ dedicated one using the "PREVIEW" type.
456+ </ Paragraph >
457+ </ InfoPanel >
458+ ) ;
459+ }
460+
461+ return (
462+ < InfoPanel
463+ title = "Upgrade to get preview branches"
464+ icon = { BranchEnvironmentIconSmall }
465+ iconClassName = "text-preview"
466+ panelClassName = "max-w-full"
467+ accessory = {
468+ < LinkButton variant = "primary/small" to = { v3BillingPath ( organization ) } >
469+ Upgrade
470+ </ LinkButton >
471+ }
472+ >
473+ < Paragraph spacing variant = "small" >
474+ Preview branches in Trigger.dev create isolated environments for testing new features before
475+ production.
476+ </ Paragraph >
477+ </ InfoPanel >
478+ ) ;
479+ }
480+
481+ export function BranchesNoBranches ( {
482+ parentEnvironment,
483+ limits,
484+ canUpgrade,
485+ } : {
486+ parentEnvironment : { id : string } ;
487+ limits : { used : number ; limit : number } ;
488+ canUpgrade : boolean ;
489+ } ) {
490+ const organization = useOrganization ( ) ;
491+
492+ if ( limits . used >= limits . limit ) {
493+ return (
494+ < InfoPanel
495+ title = "Upgrade to get preview branches"
496+ icon = { BranchEnvironmentIconSmall }
497+ iconClassName = "text-preview"
498+ panelClassName = "max-w-full"
499+ accessory = {
500+ canUpgrade ? (
501+ < LinkButton variant = "primary/small" to = { v3BillingPath ( organization ) } >
502+ Upgrade
503+ </ LinkButton >
504+ ) : (
505+ < Feedback
506+ button = { < Button variant = "primary/small" > Request more</ Button > }
507+ defaultValue = "help"
508+ />
509+ )
510+ }
511+ >
512+ < Paragraph spacing variant = "small" >
513+ You've reached the limit ({ limits . used } /{ limits . limit } ) of branches for your plan. Upgrade
514+ to get branches.
515+ </ Paragraph >
516+ </ InfoPanel >
517+ ) ;
518+ }
519+
520+ return (
521+ < InfoPanel
522+ title = "Create your first branch"
523+ icon = { BranchEnvironmentIconSmall }
524+ iconClassName = "text-preview"
525+ panelClassName = "max-w-full"
526+ accessory = {
527+ < NewBranchPanel
528+ button = {
529+ < Button
530+ variant = "primary/small"
531+ LeadingIcon = { PlusIcon }
532+ leadingIconClassName = "text-white"
533+ >
534+ New branch
535+ </ Button >
536+ }
537+ parentEnvironment = { parentEnvironment }
538+ />
539+ }
540+ >
541+ < Paragraph spacing variant = "small" >
542+ Branches are a way to test new features in isolation before merging them into the main
543+ environment.
544+ </ Paragraph >
545+ < Paragraph spacing variant = "small" >
546+ Branches are only available when using < V4Badge inline /> or above. Read our{ " " }
547+ < TextLink to = { docsPath ( "upgrade-to-v4" ) } > v4 upgrade guide</ TextLink > to learn more.
548+ </ Paragraph >
549+ </ InfoPanel >
550+ ) ;
551+ }
552+
553+ export function SwitcherPanel ( { title = "Switch to a deployed environment" } : { title ?: string } ) {
435554 const organization = useOrganization ( ) ;
436555 const project = useProject ( ) ;
437556 const environment = useEnvironment ( ) ;
438557
439558 return (
440559 < div className = "flex items-center rounded-md border border-grid-bright bg-background-bright p-3" >
441560 < Paragraph variant = "small" className = "grow" >
442- Switch to a deployed environment
561+ { title }
443562 </ Paragraph >
444563 < EnvironmentSelector
445564 organization = { organization }
0 commit comments