11import { ChevronRightIcon , Cog8ToothIcon } from "@heroicons/react/20/solid" ;
2+ import { DEFAULT_DEV_BRANCH } from "@trigger.dev/core/v3/utils/gitBranch" ;
23import { DropdownIcon } from "~/assets/icons/DropdownIcon" ;
34import { useNavigation } from "@remix-run/react" ;
45import { useEffect , useRef , useState } from "react" ;
@@ -9,8 +10,8 @@ import { useFeatures } from "~/hooks/useFeatures";
910import { useOrganization , type MatchedOrganization } from "~/hooks/useOrganizations" ;
1011import { useProject } from "~/hooks/useProject" ;
1112import { cn } from "~/utils/cn" ;
12- import { branchesPath , docsPath , v3BillingPath } from "~/utils/pathBuilder" ;
13- import { EnvironmentCombo , EnvironmentIcon , EnvironmentLabel , environmentFullTitle } from "../environments/EnvironmentLabel" ;
13+ import { branchesPath , branchesDevPath , docsPath , v3BillingPath } from "~/utils/pathBuilder" ;
14+ import { EnvironmentCombo , EnvironmentIcon , EnvironmentLabel , environmentFullTitle , environmentTextClassName } from "../environments/EnvironmentLabel" ;
1415import { ButtonContent } from "../primitives/Buttons" ;
1516import { Header2 } from "../primitives/Headers" ;
1617import { Paragraph } from "../primitives/Paragraph" ;
@@ -104,18 +105,19 @@ export function EnvironmentSelector({
104105 >
105106 < div className = "flex flex-col gap-1 p-1" >
106107 { project . environments
107- . filter ( ( env ) => env . branchName === null )
108+ . filter ( ( env ) => env . parentEnvironmentId === null )
108109 . map ( ( env ) => {
109110 switch ( env . isBranchableEnvironment ) {
110111 case true : {
111112 const branchEnvironments = project . environments . filter (
112113 ( e ) => e . parentEnvironmentId === env . id
113114 ) ;
115+ const allBranchEnvironments = env . type === "DEVELOPMENT" ? [ env , ...branchEnvironments ] : branchEnvironments ;
114116 return (
115117 < Branches
116118 key = { env . id }
117119 parentEnvironment = { env }
118- branchEnvironments = { branchEnvironments }
120+ branchEnvironments = { allBranchEnvironments }
119121 currentEnvironment = { environment }
120122 />
121123 ) ;
@@ -223,11 +225,13 @@ function Branches({
223225 branchEnvironments . length === 0
224226 ? "no-branches"
225227 : activeBranches . length === 0
226- ? "no-active-branches"
227- : "has-branches" ;
228+ ? "no-active-branches"
229+ : "has-branches" ;
228230
229231 const currentBranchIsArchived = environment . archivedAt !== null ;
230232
233+ const envTextClassName = environmentTextClassName ( parentEnvironment ) ;
234+
231235 return (
232236 < Popover onOpenChange = { ( open ) => setMenuOpen ( open ) } open = { isMenuOpen } >
233237 < div onMouseEnter = { handleMouseEnter } onMouseLeave = { handleMouseLeave } className = "flex" >
@@ -260,11 +264,11 @@ function Branches({
260264 to = { urlForEnvironment ( environment ) }
261265 title = {
262266 < >
263- < span className = "block w-full text-preview" > { environment . branchName } </ span >
267+ < span className = { cn ( "block w-full" , envTextClassName ) } > { environment . branchName } </ span >
264268 < Badge variant = "extra-small" > Archived</ Badge >
265269 </ >
266270 }
267- icon = { < BranchEnvironmentIconSmall className = "size-4 shrink-0 text-preview" /> }
271+ icon = { < BranchEnvironmentIconSmall className = { cn ( "size-4 shrink-0" , envTextClassName ) } /> }
268272 isSelected = { environment . id === currentEnvironment . id }
269273 />
270274 ) }
@@ -276,16 +280,16 @@ function Branches({
276280 < PopoverMenuItem
277281 key = { env . id }
278282 to = { urlForEnvironment ( env ) }
279- title = { < span className = "block w-full text-preview" > { env . branchName } </ span > }
280- icon = { < BranchEnvironmentIconSmall className = "size-4 shrink-0 text-preview" /> }
283+ title = { < span className = { cn ( "block w-full" , envTextClassName ) } > { env . branchName ?? DEFAULT_DEV_BRANCH } </ span > }
284+ icon = { < BranchEnvironmentIconSmall className = { cn ( "size-4 shrink-0" , envTextClassName ) } /> }
281285 isSelected = { env . id === currentEnvironment . id }
282286 />
283287 ) ) }
284288 </ >
285289 ) : state === "no-branches" ? (
286290 < div className = "flex max-w-sm flex-col gap-1 p-2" >
287291 < div className = "flex items-center gap-1" >
288- < BranchEnvironmentIconSmall className = "size-4 text-preview" />
292+ < BranchEnvironmentIconSmall className = { cn ( "size-4" , envTextClassName ) } />
289293 < Header2 > Create your first branch</ Header2 >
290294 </ div >
291295 < Paragraph spacing variant = "small" >
@@ -305,12 +309,21 @@ function Branches({
305309 ) }
306310 </ div >
307311 < div className = "border-t border-charcoal-700 p-1" >
308- < PopoverMenuItem
309- to = { branchesPath ( organization , project , environment ) }
310- title = "Manage branches"
311- icon = { < Cog8ToothIcon className = "size-4 text-text-dimmed" /> }
312- leadingIconClassName = "text-text-dimmed"
313- />
312+ { parentEnvironment . type === "DEVELOPMENT" ? (
313+ < PopoverMenuItem
314+ to = { branchesDevPath ( organization , project , environment ) }
315+ title = "Manage dev branches"
316+ icon = { < Cog8ToothIcon className = "size-4 text-text-dimmed" /> }
317+ leadingIconClassName = "text-text-dimmed"
318+ />
319+ ) : (
320+ < PopoverMenuItem
321+ to = { branchesPath ( organization , project , environment ) }
322+ title = "Manage preview branches"
323+ icon = { < Cog8ToothIcon className = "size-4 text-text-dimmed" /> }
324+ leadingIconClassName = "text-text-dimmed"
325+ />
326+ ) }
314327 </ div >
315328 </ PopoverContent >
316329 </ div >
0 commit comments