1414 * limitations under the License.
1515 */
1616
17+ import { useMemo } from 'react'
1718import { generatePath , Link } from 'react-router-dom'
1819
1920import {
@@ -51,35 +52,29 @@ const ClusterListRow = ({
5152 onChangeShowKubeConfigModal,
5253 setSelectedClusterName,
5354} : ClusterListRowTypes ) => {
54- const { selectedIdentifiers : bulkSelectionState , getSelectedIdentifiersCount } =
55+ const { selectedIdentifiers, getSelectedIdentifiersCount } =
5556 useBulkSelection < BulkSelectionIdentifiersType < ClusterDetail > > ( )
56- const errorCount = clusterData . nodeErrors ? Object . keys ( clusterData . nodeErrors ) . length : 0
5757 const identifierCount = getSelectedIdentifiersCount ( )
58+ const isIdentifierSelected = Boolean ( selectedIdentifiers [ clusterData . name ] )
5859
59- const hideDataOnLoad = ( value ) => {
60- if ( clusterListLoader ) {
61- return null
62- }
63- return value
64- }
65-
66- const renderClusterStatus = ( { errorInNodeListing, status } : ClusterDetail ) => {
67- if ( ! status ) {
68- return null
69- }
70-
71- return < ClusterStatus status = { status } errorInNodeListing = { errorInNodeListing } />
72- }
73-
74- const isIdentifierSelected = ! ! bulkSelectionState [ clusterData . name ]
60+ const errorCount = useMemo (
61+ ( ) => ( clusterData . nodeErrors ? Object . keys ( clusterData . nodeErrors ) . length : 0 ) ,
62+ [ clusterData . nodeErrors ] ,
63+ )
7564
76- const isClusterInCreationPhase = ! ! clusterData . installationId && ! clusterData . id
65+ const isClusterInCreationPhase = Boolean ( clusterData . installationId && ! clusterData . id )
7766
78- const clusterLinkURL = getClusterChangeRedirectionUrl (
79- isClusterInCreationPhase ,
80- String ( isClusterInCreationPhase ? clusterData . installationId : clusterData . id ) ,
67+ const clusterLinkURL = useMemo (
68+ ( ) =>
69+ getClusterChangeRedirectionUrl (
70+ isClusterInCreationPhase ,
71+ String ( isClusterInCreationPhase ? clusterData . installationId : clusterData . id ) ,
72+ ) ,
73+ [ isClusterInCreationPhase , clusterData . installationId , clusterData . id ] ,
8174 )
8275
76+ const hideDataOnLoad = ( value ) => ( clusterListLoader ? null : value )
77+
8378 const wrapWithLinkForClusterName = ( children ) => (
8479 < Link className = "dc__ellipsis-right dc__no-decor" to = { clusterLinkURL } >
8580 { children }
@@ -88,9 +83,8 @@ const ClusterListRow = ({
8883
8984 return (
9085 < div
91- key = { `cluster-${ clusterData . id } ` }
9286 className = { `cluster-list-row fw-4 cn-9 fs-13 dc__border-bottom-n1 py-12 px-20 hover-class dc__visible-hover dc__visible-hover--parent
93- ${ clusterListLoader ? 'show-shimmer-loading dc__align-items-center' : '' } ` }
87+ ${ clusterListLoader ? 'show-shimmer-loading dc__align-items-center' : '' } ` }
9488 >
9589 { KubeConfigRowCheckbox && < KubeConfigRowCheckbox clusterData = { clusterData } /> }
9690 { ! isIdentifierSelected && identifierCount === 0 && (
@@ -125,9 +119,11 @@ const ClusterListRow = ({
125119 } }
126120 />
127121 ) }
122+
128123 { CompareClusterButton && clusterData . status !== ClusterStatusType . CONNECTION_FAILED && (
129124 < CompareClusterButton sourceClusterId = { clusterData . id } isIconButton />
130125 ) }
126+
131127 { KubeConfigButton && (
132128 < KubeConfigButton
133129 onChangeShowKubeConfigModal = { onChangeShowKubeConfigModal }
@@ -139,8 +135,18 @@ const ClusterListRow = ({
139135 </ div >
140136 ) }
141137 </ div >
142- < div className = "child-shimmer-loading" > { hideDataOnLoad ( renderClusterStatus ( clusterData ) ) } </ div >
143- { }
138+
139+ < div className = "child-shimmer-loading" >
140+ { hideDataOnLoad (
141+ clusterData . status && (
142+ < ClusterStatus
143+ status = { clusterData . status }
144+ errorInNodeListing = { clusterData . errorInNodeListing }
145+ />
146+ ) ,
147+ ) }
148+ </ div >
149+
144150 < div className = "child-shimmer-loading" >
145151 { hideDataOnLoad ( clusterData . isProd ? CLUSTER_PROD_TYPE . PRODUCTION : CLUSTER_PROD_TYPE . NON_PRODUCTION ) }
146152 </ div >
0 commit comments