@@ -33,6 +33,9 @@ export const HostsClusterDetailTabContent = ({
33
33
const [ day2Cluster , setDay2Cluster ] = useStateSafely < Cluster | null > ( null ) ;
34
34
const pullSecret = usePullSecret ( ) ;
35
35
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ const ocmClusterMemo = React . useMemo ( ( ) => ocmCluster , [ ] ) ;
38
+
36
39
const handleClickTryAgainLink = React . useCallback ( ( ) => {
37
40
setError ( undefined ) ;
38
41
setDay2Cluster ( null ) ;
@@ -53,19 +56,21 @@ export const HostsClusterDetailTabContent = ({
53
56
setDay2Cluster ( null ) ;
54
57
return ;
55
58
}
56
- const day1ClusterHostCount = ocmCluster ?. metrics ?. nodes ?. total || 0 ;
57
- const openshiftClusterId = Day2ClusterService . getOpenshiftClusterId ( ocmCluster ) ;
59
+
60
+ const day1ClusterHostCount = ocmClusterMemo ?. metrics ?. nodes ?. total || 0 ;
61
+ const openshiftClusterId = Day2ClusterService . getOpenshiftClusterId ( ocmClusterMemo ) ;
58
62
if ( day1ClusterHostCount === 0 || ! openshiftClusterId ) {
59
63
setError ( < UnableToAddHostsError onTryAgain = { handleClickTryAgainLink } /> ) ;
64
+ return ;
60
65
}
61
66
62
67
if ( ! day2Cluster && pullSecret ) {
63
- const { apiVipDnsname, errorType } = getApiVipDnsName ( ocmCluster ) ;
68
+ const { apiVipDnsname, errorType } = getApiVipDnsName ( ocmClusterMemo ) ;
64
69
if ( errorType ) {
65
70
const wrongUrlMessage =
66
71
errorType === 'console'
67
- ? `Cluster Console URL is not valid (${ ocmCluster . console ?. url || '' } )`
68
- : `Cluster API URL is not valid (${ ocmCluster . api ?. url || '' } )` ;
72
+ ? `Cluster Console URL is not valid (${ ocmClusterMemo . console ?. url || '' } )`
73
+ : `Cluster API URL is not valid (${ ocmClusterMemo . api ?. url || '' } )` ;
69
74
setError (
70
75
< >
71
76
{ wrongUrlMessage } , you can{ ' ' }
@@ -85,11 +90,11 @@ export const HostsClusterDetailTabContent = ({
85
90
86
91
const loadDay2Cluster = async ( ) => {
87
92
try {
88
- const day2Cluster = await Day2ClusterService . fetchCluster ( ocmCluster , pullSecret ) ;
93
+ const day2Cluster = await Day2ClusterService . fetchCluster ( ocmClusterMemo , pullSecret ) ;
89
94
90
95
const aiCluster = Day2ClusterService . completeAiClusterWithOcmCluster (
91
96
day2Cluster ,
92
- ocmCluster ,
97
+ ocmClusterMemo ,
93
98
) ;
94
99
setDay2Cluster ( aiCluster ?? null ) ;
95
100
} catch ( e ) {
@@ -103,13 +108,12 @@ export const HostsClusterDetailTabContent = ({
103
108
/> ,
104
109
) ;
105
110
}
106
- return ;
107
111
}
108
112
} ;
109
113
110
114
void loadDay2Cluster ( ) ;
111
115
}
112
- } , [ ocmCluster , pullSecret , day2Cluster , setDay2Cluster , isVisible , handleClickTryAgainLink ] ) ;
116
+ } , [ pullSecret , day2Cluster , setDay2Cluster , isVisible , handleClickTryAgainLink , ocmClusterMemo ] ) ;
113
117
114
118
const refreshCluster = React . useCallback ( async ( ) => {
115
119
if ( ! day2Cluster ?. id ) {
0 commit comments