@@ -25,6 +25,7 @@ import {
25
25
IAcmTableButtonAction ,
26
26
Provider ,
27
27
StatusType ,
28
+ ProviderLongTextMap ,
28
29
} from '../../../../ui-components'
29
30
import { Fragment , useContext , useEffect , useMemo , useState } from 'react'
30
31
import { useNavigate } from 'react-router-dom-v5-compat'
@@ -46,12 +47,13 @@ import {
46
47
ResourceErrorCode ,
47
48
isClusterPoolDeleting ,
48
49
} from '../../../../resources'
49
- import { ClusterStatuses } from '../ClusterSets/components/ClusterStatuses'
50
+ import { ClusterStatuses , getClusterStatusCount } from '../ClusterSets/components/ClusterStatuses'
50
51
import { StatusField } from '../ManagedClusters/components/StatusField'
51
52
import { useAllClusters } from '../ManagedClusters/components/useAllClusters'
52
53
import { ClusterClaimModal , ClusterClaimModalProps } from './components/ClusterClaimModal'
53
54
import { ScaleClusterPoolModal , ScaleClusterPoolModalProps } from './components/ScaleClusterPoolModal'
54
55
import { UpdateReleaseImageModal , UpdateReleaseImageModalProps } from './components/UpdateReleaseImageModal'
56
+ import { getMappedClusterPoolClusterSetClusters } from '../ClusterSets/components/useClusters'
55
57
56
58
export default function ClusterPoolsPage ( ) {
57
59
const alertContext = useContext ( AcmAlertContext )
@@ -152,11 +154,14 @@ export default function ClusterPoolsPage() {
152
154
)
153
155
}
154
156
157
+ function determineProvider ( clusterPool : ClusterPool ) {
158
+ if ( clusterPool . spec ?. platform ?. aws ) return Provider . aws
159
+ if ( clusterPool . spec ?. platform ?. gcp ) return Provider . gcp
160
+ if ( clusterPool . spec ?. platform ?. azure ) return Provider . azure
161
+ }
162
+
155
163
function ClusterPoolProvider ( props : { clusterPool : ClusterPool } ) {
156
- let provider : Provider | undefined
157
- if ( props . clusterPool . spec ?. platform ?. aws ) provider = Provider . aws
158
- if ( props . clusterPool . spec ?. platform ?. gcp ) provider = Provider . gcp
159
- if ( props . clusterPool . spec ?. platform ?. azure ) provider = Provider . azure
164
+ const provider : Provider | undefined = determineProvider ( props . clusterPool )
160
165
161
166
if ( ! provider ) return < > -</ >
162
167
@@ -170,9 +175,32 @@ export function ClusterPoolsTable(props: {
170
175
tableActionButtons ?: IAcmTableButtonAction [ ]
171
176
} ) {
172
177
const { clusters } = props
173
- const { clusterImageSetsState, clusterClaimsState } = useSharedAtoms ( )
178
+ const {
179
+ clusterImageSetsState,
180
+ clusterClaimsState,
181
+ certificateSigningRequestsState,
182
+ clusterDeploymentsState,
183
+ managedClusterAddonsState,
184
+ clusterManagementAddonsState,
185
+ managedClusterInfosState,
186
+ managedClustersState,
187
+ agentClusterInstallsState,
188
+ clusterCuratorsState,
189
+ hostedClustersState,
190
+ nodePoolsState,
191
+ } = useSharedAtoms ( )
174
192
const clusterImageSets = useRecoilValue ( clusterImageSetsState )
175
193
const clusterClaims = useRecoilValue ( clusterClaimsState )
194
+ const managedClusters = useRecoilValue ( managedClustersState )
195
+ const clusterDeployments = useRecoilValue ( clusterDeploymentsState )
196
+ const managedClusterInfos = useRecoilValue ( managedClusterInfosState )
197
+ const certificateSigningRequests = useRecoilValue ( certificateSigningRequestsState )
198
+ const managedClusterAddons = useRecoilValue ( managedClusterAddonsState )
199
+ const clusterManagementAddons = useRecoilValue ( clusterManagementAddonsState )
200
+ const clusterCurators = useRecoilValue ( clusterCuratorsState )
201
+ const agentClusterInstalls = useRecoilValue ( agentClusterInstallsState )
202
+ const hostedClusters = useRecoilValue ( hostedClustersState )
203
+ const nodePools = useRecoilValue ( nodePoolsState )
176
204
177
205
const { clusterPools } = props
178
206
const { t } = useTranslation ( )
@@ -184,6 +212,30 @@ export function ClusterPoolsTable(props: {
184
212
const [ updateReleaseImageModalProps , setUpdateReleaseImageModalProps ] = useState <
185
213
UpdateReleaseImageModalProps | undefined
186
214
> ( )
215
+ const clusterPoolClusters : Record < string , Cluster [ ] > = { }
216
+
217
+ props . clusterPools &&
218
+ props . clusterPools . forEach ( ( clusterPool ) => {
219
+ if ( clusterPool . metadata . name ) {
220
+ const clusters = getMappedClusterPoolClusterSetClusters (
221
+ managedClusters ,
222
+ clusterDeployments ,
223
+ managedClusterInfos ,
224
+ certificateSigningRequests ,
225
+ managedClusterAddons ,
226
+ clusterManagementAddons ,
227
+ clusterClaims ,
228
+ clusterCurators ,
229
+ agentClusterInstalls ,
230
+ hostedClusters ,
231
+ nodePools ,
232
+ undefined ,
233
+ clusterPool ,
234
+ undefined
235
+ )
236
+ clusterPoolClusters [ clusterPool . metadata . name ] = clusters
237
+ }
238
+ } )
187
239
188
240
const modalColumns = useMemo (
189
241
( ) => [
@@ -216,6 +268,15 @@ export function ClusterPoolsTable(props: {
216
268
217
269
const deletingPools = clusterPools ?. filter ( ( clusterPool ) => isClusterPoolDeleting ( clusterPool ) )
218
270
271
+ const getDistributionVersion = ( clusterPool : ClusterPool ) => {
272
+ const imageSetRef = clusterPool . spec ! . imageSetRef . name
273
+ const imageSet = clusterImageSets . find ( ( cis ) => cis . metadata . name === imageSetRef )
274
+ const releaseImage = imageSet ?. spec ?. releaseImage
275
+ const tagStartIndex = releaseImage ?. indexOf ( ':' ) ?? 0
276
+ const version = releaseImage ?. slice ( tagStartIndex + 1 , releaseImage . indexOf ( '-' , tagStartIndex ) )
277
+ return version ? `OpenShift ${ version } ` : '-'
278
+ }
279
+
219
280
return (
220
281
< Fragment >
221
282
< BulkActionModal < ClusterPool > { ...modalProps } />
@@ -225,6 +286,8 @@ export function ClusterPoolsTable(props: {
225
286
< AcmTable < ClusterPool >
226
287
items = { clusterPools }
227
288
disabledItems = { deletingPools }
289
+ showExportButton
290
+ exportFilePrefix = "clusterpool"
228
291
addSubRows = { ( clusterPool : ClusterPool ) => {
229
292
const clusterPoolClusters = clusters . filter (
230
293
( cluster ) =>
@@ -278,6 +341,9 @@ export function ClusterPoolsTable(props: {
278
341
cell : ( clusterPool : ClusterPool ) => {
279
342
return clusterPool . metadata . name
280
343
} ,
344
+ exportContent : ( clusterPool : ClusterPool ) => {
345
+ return clusterPool . metadata . name
346
+ } ,
281
347
} ,
282
348
{
283
349
header : t ( 'table.namespace' ) ,
@@ -286,6 +352,9 @@ export function ClusterPoolsTable(props: {
286
352
cell : ( clusterPool : ClusterPool ) => {
287
353
return clusterPool . metadata . namespace
288
354
} ,
355
+ exportContent : ( clusterPool : ClusterPool ) => {
356
+ return clusterPool . metadata . namespace
357
+ } ,
289
358
} ,
290
359
{
291
360
header : t ( 'table.cluster.statuses' ) ,
@@ -296,6 +365,28 @@ export function ClusterPoolsTable(props: {
296
365
return < ClusterStatuses clusterPool = { clusterPool } />
297
366
}
298
367
} ,
368
+ exportContent : ( clusterPool : ClusterPool ) => {
369
+ if ( isClusterPoolDeleting ( clusterPool ) ) {
370
+ return t ( 'destroying' )
371
+ } else {
372
+ const status = getClusterStatusCount ( clusterPoolClusters [ clusterPool . metadata . name ! ] )
373
+ const clusterStatusAvailable =
374
+ status &&
375
+ Object . values ( status ) . find ( ( val ) => {
376
+ return typeof val === 'number' && val > 0
377
+ } )
378
+
379
+ if ( clusterStatusAvailable ) {
380
+ return (
381
+ `healthy: ${ status ?. healthy } , running: ${ status ?. running } , ` +
382
+ `warning: ${ status ?. warning } , progress: ${ status ?. progress } , ` +
383
+ `danger: ${ status ?. danger } , detached: ${ status ?. detached } , ` +
384
+ `pending: ${ status ?. pending } , sleep: ${ status ?. sleep } , ` +
385
+ `unknown: ${ status ?. unknown } `
386
+ )
387
+ }
388
+ }
389
+ } ,
299
390
} ,
300
391
{
301
392
header : t ( 'table.available' ) ,
@@ -312,24 +403,37 @@ export function ClusterPoolsTable(props: {
312
403
)
313
404
}
314
405
} ,
406
+ exportContent : ( clusterPool : ClusterPool ) => {
407
+ if ( ! isClusterPoolDeleting ( clusterPool ) ) {
408
+ const ready = clusterPool ?. status ?. ready === undefined ? 0 : clusterPool ?. status ?. ready
409
+ return t ( 'outOf' , {
410
+ firstNumber : ready ,
411
+ secondNumber : clusterPool . spec ! . size ,
412
+ } )
413
+ }
414
+ } ,
315
415
} ,
316
416
{
317
417
header : t ( 'table.provider' ) ,
318
418
cell : ( clusterPool : ClusterPool ) => {
319
419
return < ClusterPoolProvider clusterPool = { clusterPool } />
320
420
} ,
421
+ exportContent : ( clusterPool : ClusterPool ) => {
422
+ const provider = determineProvider ( clusterPool )
423
+ if ( provider ) {
424
+ return ProviderLongTextMap [ provider ]
425
+ }
426
+ } ,
321
427
} ,
322
428
{
323
429
header : t ( 'table.distribution' ) ,
324
430
sort : 'spec.imageSetRef.name' ,
325
431
search : 'spec.imageSetRef.name' ,
326
432
cell : ( clusterPool : ClusterPool ) => {
327
- const imageSetRef = clusterPool . spec ! . imageSetRef . name
328
- const imageSet = clusterImageSets . find ( ( cis ) => cis . metadata . name === imageSetRef )
329
- const releaseImage = imageSet ?. spec ?. releaseImage
330
- const tagStartIndex = releaseImage ?. indexOf ( ':' ) ?? 0
331
- const version = releaseImage ?. slice ( tagStartIndex + 1 , releaseImage . indexOf ( '-' , tagStartIndex ) )
332
- return version ? `OpenShift ${ version } ` : '-'
433
+ return getDistributionVersion ( clusterPool )
434
+ } ,
435
+ exportContent : ( clusterPool : ClusterPool ) => {
436
+ return getDistributionVersion ( clusterPool )
333
437
} ,
334
438
} ,
335
439
{
0 commit comments