@@ -14,35 +14,43 @@ import {
1414
1515type TProps = {
1616 className ?: string ;
17- forcePending ?: boolean ;
17+ isPending ?: boolean ;
1818} ;
1919
20- export default function DeploymentInstances ( { forcePending , className } : TProps ) {
20+ export default function DeploymentInstances ( { isPending : isPendingProp , className } : TProps ) {
2121 const { data, isPending, error } = useInstanceHealth ( ) ;
2222
23- if ( isPending || forcePending )
23+ if ( isPending || isPendingProp ) {
2424 return (
25- < div className = { cn ( "flex w-full flex-wrap gap-1" , className ) } >
26- < div className = "bg-background border-muted-foreground/12 relative z-0 flex overflow-hidden rounded-md border" >
27- < div className = "p-1" >
25+ < div className = { cn ( "flex w-full flex-wrap gap-1.5 " , className ) } >
26+ < div className = "bg-background border-muted-foreground/16 relative z-0 flex overflow-hidden rounded-md border" >
27+ < IconWrapper >
2828 < div className = "bg-muted-foreground animate-skeleton size-3.5 rounded-full" />
29- </ div >
30- < div className = "bg-muted-foreground/12 w-px self-stretch" />
31- < div className = "bg-muted-foreground/6 p-1 " >
29+ </ IconWrapper >
30+ < div className = "bg-muted-foreground/16 w-px self-stretch" />
31+ < IconWrapper className = "bg-muted-foreground/6" >
3232 < div className = "bg-muted-foreground animate-skeleton size-3.5 rounded-full" />
33- </ div >
33+ </ IconWrapper >
3434 </ div >
3535 </ div >
3636 ) ;
37+ }
38+
3739 if ( data ) {
40+ if ( data . data . instances . length === 0 ) return null ;
41+ const orderedInstances = data . data . instances . sort ( ( a , b ) => {
42+ return statusOrder . indexOf ( a . status ) - statusOrder . indexOf ( b . status ) ;
43+ } ) ;
44+
3845 return (
39- < div className = { cn ( "flex w-full flex-wrap gap-1" , className ) } >
40- { data . data . instances . map ( ( instance , i ) => (
46+ < div className = { cn ( "flex w-full flex-wrap gap-1.5 " , className ) } >
47+ { orderedInstances . map ( ( instance , i ) => (
4148 < Instance key = { i } instance = { instance } />
4249 ) ) }
4350 </ div >
4451 ) ;
4552 }
53+
4654 if ( error ) {
4755 return (
4856 < div className = "flex w-full justify-start" >
@@ -62,21 +70,25 @@ function Instance({ instance }: { instance: TInstanceFromHealth }) {
6270 return (
6371 < div
6472 data-status = { instance ?. status }
65- className = "bg-background data-[status=waiting]:border-warning/16 data-[status=starting]:border-process/16 data-[status=not_ready]:border-process/16 data-[status=running]:border-success/16 data-[status=crashing]:border-destructive/16 group/div relative z-0 flex overflow-hidden rounded-md border"
73+ className = "bg-background data-[status=waiting]:border-warning/20 data-[status=starting]:border-process/20 data-[status=not_ready]:border-process/20 data-[status=running]:border-success/20 data-[status=crashing]:border-destructive/20 group/div relative z-0 flex overflow-hidden rounded-md border"
6674 >
67- < div className = "p-1" >
75+ < IconWrapper >
6876 < ServerIcon className = "text-muted-foreground size-3.5" />
69- </ div >
70- < div className = "bg-border group-data-[status=waiting]/div:bg-warning/16 group-data-[status=starting]/div:bg-process/16 group-data-[status=not_ready]/div:bg-process/16 group-data-[status=running]/div:bg-success/16 group-data-[status=crashing]/div:bg-destructive/16 w-px self-stretch" />
71- < div className = "group-data-[status=waiting]/div:bg-warning/8 group-data-[status=starting]/div:bg-process/8 group-data-[status=not_ready]/div:bg-process/8 group-data-[status=running]/div:bg-success/8 group-data-[status=crashing]/div:bg-destructive/8 p-1 " >
77+ </ IconWrapper >
78+ < div className = "bg-border group-data-[status=waiting]/div:bg-warning/20 group-data-[status=starting]/div:bg-process/20 group-data-[status=not_ready]/div:bg-process/20 group-data-[status=running]/div:bg-success/20 group-data-[status=crashing]/div:bg-destructive/20 w-px self-stretch" />
79+ < IconWrapper className = "group-data-[status=waiting]/div:bg-warning/8 group-data-[status=starting]/div:bg-process/8 group-data-[status=not_ready]/div:bg-process/8 group-data-[status=running]/div:bg-success/8 group-data-[status=crashing]/div:bg-destructive/8" >
7280 < div className = "size-3.5 shrink-0" >
7381 < Indicator instance = { instance } />
7482 </ div >
75- </ div >
83+ </ IconWrapper >
7684 </ div >
7785 ) ;
7886}
7987
88+ function IconWrapper ( { className, children } : { className ?: string ; children : React . ReactNode } ) {
89+ return < div className = { cn ( "p-1.25" , className ) } > { children } </ div > ;
90+ }
91+
8092function Indicator ( { instance } : { instance : TInstanceFromHealth } ) {
8193 if ( instance . status === "waiting" ) {
8294 return < HourglassIcon className = "text-warning animate-hourglass size-full" /> ;
@@ -90,8 +102,27 @@ function Indicator({ instance }: { instance: TInstanceFromHealth }) {
90102 if ( instance . status === "crashing" ) {
91103 return < TriangleAlertIcon className = "text-destructive size-full" /> ;
92104 }
105+ if ( instance . status === "image_pull_error" ) {
106+ return < TriangleAlertIcon className = "text-destructive size-full" /> ;
107+ }
108+ if ( instance . status === "terminating" ) {
109+ return (
110+ < CircleSlashIcon className = "text-muted-foreground size-full animate-spin duration-2000" />
111+ ) ;
112+ }
93113 if ( instance . status === "terminated" ) {
94114 return < CircleSlashIcon className = "text-muted-foreground size-full" /> ;
95115 }
96- return < CircleHelpIcon className = "text-foreground size-full" /> ;
116+ return < CircleHelpIcon className = "text-muted- foreground size-full" /> ;
97117}
118+
119+ const statusOrder : TInstanceFromHealth [ "status" ] [ ] = [
120+ "crashing" ,
121+ "image_pull_error" ,
122+ "running" ,
123+ "starting" ,
124+ "not_ready" ,
125+ "waiting" ,
126+ "terminating" ,
127+ "terminated" ,
128+ ] ;
0 commit comments