@@ -7,9 +7,10 @@ import { renderBadgeStatusVariant } from '@/components/ui/utils/badgeStatus';
77import { EmptyCluster } from '@/features/cluster/EmptyCluster' ;
88import { InstanceLogInCell } from '@/features/cluster/InstanceLogInCell' ;
99import { getClusterInfoQueryOptions } from '@/features/cluster/queries/getClusterInfoQuery' ;
10+ import { calculateInstanceFQDN } from '@/features/clusters/upsert/lib/calculateInstanceFQDN' ;
1011import { Instance } from '@/lib/api.patch' ;
12+ import { excludeFalsy } from '@/lib/arrays/excludeFalsy' ;
1113import { humanFileSize } from '@/lib/humanFileSize' ;
12- import { InstanceTypes , renderInstanceTypeOption } from '@/lib/InstanceType' ;
1314import { capitalizeWords } from '@/lib/string/capitalizeWords' ;
1415import { useQuery } from '@tanstack/react-query' ;
1516import { useParams } from '@tanstack/react-router' ;
@@ -21,62 +22,87 @@ export function ClusterIndex() {
2122 const { data : cluster , isLoading : clusterIsLoading } = useQuery (
2223 getClusterInfoQueryOptions ( clusterId , true ) ,
2324 ) ;
25+ const isSelfManaged = useMemo ( ( ) => ! ! cluster ?. plans ?. [ 0 ] ?. planId ?. startsWith ( 'self-hosted' ) , [ cluster ] ) ;
2426
2527 const columns : ColumnDef < Instance > [ ] = useMemo (
26- ( ) => [
28+ ( ) => ( [
2729 {
28- accessorKey : 'name' , // Accessor key for the "name" field from data object
29- header : 'Name' , // Column header
30+ id : 'instanceActions' ,
31+ size : 1 ,
32+ minSize : 1 ,
33+ cell : ( cell ) => ( < div className = "flex justify-end" >
34+ < InstanceLogInCell instance = { cell . row . original } />
35+ </ div > ) ,
3036 } ,
31- {
37+ isSelfManaged && {
3238 accessorKey : 'instanceFqdn' ,
33- header : 'Instance Url' ,
34- cell : ( cell ) => < InstanceLogInCell instance = { cell . row . original } /> ,
35- } ,
36- {
37- accessorKey : 'instanceTypeId' ,
38- header : 'Instance Type' ,
39+ size : 90 ,
40+ header : 'URL' ,
3941 cell : ( cell ) => {
40- return renderInstanceTypeOption ( cell . getValue ( ) as InstanceTypes ) ;
42+ return calculateInstanceFQDN ( {
43+ secure : cell . row . original . operationsApiSecure ? 'true' : 'false' ,
44+ port : cell . row . original . operationsApiPort ,
45+ fqdn : cell . row . original . instanceFqdn ,
46+ } ) ;
4147 } ,
4248 } ,
43- {
49+ ! isSelfManaged && {
50+ accessorKey : 'name' ,
51+ size : 90 ,
52+ header : 'Name' ,
53+ } ,
54+ ! isSelfManaged && {
4455 accessorKey : 'status' ,
4556 header : 'Status' ,
57+ size : 1 ,
58+ minSize : 1 ,
4659 cell : ( cell ) => {
4760 const status = cell . getValue ( ) as string ;
4861 return < Badge variant = { renderBadgeStatusVariant ( status ) } > { capitalizeWords ( status ) } </ Badge > ;
4962 } ,
5063 } ,
51- {
64+ ! isSelfManaged && {
5265 accessorKey : 'version' ,
66+ size : 1 ,
67+ minSize : 1 ,
5368 header : 'Version' ,
5469 } ,
55- {
70+ ! isSelfManaged && {
5671 accessorKey : 'storageGb' ,
72+ size : 1 ,
73+ minSize : 1 ,
5774 header : 'Storage' ,
5875 cell : ( cell ) => {
5976 const value = cell . getValue ( ) as number ;
6077 return humanFileSize ( value , Math . pow ( 1024 , 3 ) ) ;
6178 } ,
6279 } ,
63- {
80+ ! isSelfManaged && {
6481 accessorKey : 'cpuCores' ,
82+ size : 1 ,
83+ minSize : 1 ,
6584 header : 'Cores/Threads' ,
6685 cell : ( cell ) => {
6786 return < > { cell . row . original . cpuCores } / { cell . row . original . threads } </ > ;
6887 } ,
6988 } ,
70- {
89+ ! isSelfManaged && {
7190 accessorKey : 'memoryMb' ,
91+ size : 1 ,
92+ minSize : 1 ,
7293 header : 'Memory' ,
7394 cell : ( cell ) => {
7495 const value = cell . getValue ( ) as number ;
7596 return humanFileSize ( value , Math . pow ( 1024 , 2 ) ) ;
7697 } ,
7798 } ,
78- ] ,
79- [ ] ,
99+ ] satisfies Array < ColumnDef < Instance > | false > ) . filter ( excludeFalsy ) ,
100+ [ isSelfManaged ] ,
101+ ) ;
102+ const instances = useMemo (
103+ ( ) =>
104+ cluster ?. instances ?. filter ( instance => instance . status !== 'REMOVED' ) ?? [ ] ,
105+ [ cluster ] ,
80106 ) ;
81107 return (
82108 < >
@@ -86,8 +112,8 @@ export function ClusterIndex() {
86112 < CardContent className = "p-0 min-h-96" >
87113 { clusterIsLoading
88114 ? < TextLoadingSkeleton />
89- : cluster ?. instances ? .length
90- ? < DataTable data = { cluster . instances } columns = { columns } />
115+ : instances . length
116+ ? < DataTable data = { instances } columns = { columns } />
91117 : < EmptyCluster />
92118 }
93119 </ CardContent >
0 commit comments